diff --git a/scripts/rcstack/rcstack b/scripts/rcstack/rcstack index 80f5d85..05f3548 100755 --- a/scripts/rcstack/rcstack +++ b/scripts/rcstack/rcstack @@ -2123,10 +2123,24 @@ config_rhodecode_ini() { # src/lib/send_completions.sh # src/lib/utils.sh + +generate_md5() { + local input_string="$1" + + if command -v md5 &> /dev/null; then + echo -n "$input_string" | md5 + elif command -v md5sum &> /dev/null; then + echo -n "$input_string" | md5sum | awk '{print $1}' + else + echo "Error: Neither md5 nor md5sum command is available. Please make sure this is installed in your system" + return 1 + fi +} + random_str() { len=$1 - random_generate=$(echo $RANDOM | md5sum | head -c $len) - echo $random_generate + random_generate=$(generate_md5 $RANDOM | head -c $len) + echo "$random_generate" } # function to copy files with --backup=numbered option @@ -2517,7 +2531,7 @@ rcstack_init_command() { bootstrap_config() { shared_key=$(random_str 32) - shared_key_md5=$(echo $shared_key | md5sum | head -c 32) + shared_key_md5=$(generate_md5 $shared_key | head -c 32) db_key=$(random_str 32) if [[ ! $no_prompt ]]; then @@ -4265,13 +4279,6 @@ rcstack_init_parse_requirements() { exit 1 fi - if command -v md5sum >/dev/null 2>&1; then - deps['md5sum']="$(command -v md5sum | head -n1)" - else - printf "missing dependency: md5sum\n" >&2 - exit 1 - fi - if command -v find >/dev/null 2>&1; then deps['find']="$(command -v find | head -n1)" else @@ -6786,7 +6793,7 @@ rcstack__completions_parse_requirements() { # :command.initialize initialize() { - version="5.0.3" + version="5.0.4" long_usage='' set -e