From 462f0f76a41edea78e81373f2395aa8ca4436e91 Mon Sep 17 00:00:00 2001 From: xiagw Date: Tue, 14 May 2024 17:58:28 +0800 Subject: [PATCH] fix install.sh add random password for .env (#9282) * fix install.sh add random password for .env * fix generate random password * remove comment --- install.sh | 55 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/install.sh b/install.sh index 92d9c1b8be..e9c65b3283 100755 --- a/install.sh +++ b/install.sh @@ -2,14 +2,15 @@ set -o nounset set -o pipefail -create_immich_directory() { local -r Tgt='./immich-app' +create_immich_directory() { + local -r Tgt='./immich-app' echo "Creating Immich directory..." if [[ -e $Tgt ]]; then echo "Found existing directory $Tgt, will overwrite YAML files" else mkdir "$Tgt" || return - fi - cd "$Tgt" || return + fi + cd "$Tgt" || return 1 } download_docker_compose_file() { @@ -22,6 +23,16 @@ download_dot_env_file() { "${Curl[@]}" "$RepoUrl"/example.env -o ./.env } +generate_random_password() { + echo "Generate random password for .env file..." + rand_pass=$(echo "$RANDOM$(date)$RANDOM" | sha256sum | base64 | head -c10) + if [ -z "$rand_pass" ]; then + sed -i -e "s/DB_PASSWORD=postgres/DB_PASSWORD=postgres${RANDOM}${RANDOM}/" ./.env + else + sed -i -e "s/DB_PASSWORD=postgres/DB_PASSWORD=${rand_pass}/" ./.env + fi +} + start_docker_compose() { echo "Starting Immich's docker containers" @@ -40,16 +51,16 @@ start_docker_compose() { show_friendly_message() { local ip_address ip_address=$(hostname -I | awk '{print $1}') - cat << EOF + cat <