From 0c4968dc302194d9aac46e4d3d404f667424801b Mon Sep 17 00:00:00 2001 From: bo0tzz Date: Tue, 11 Oct 2022 21:13:37 +0200 Subject: [PATCH 1/3] Fix: Remove default JWT_SECRET value in .env --- docker/.env.example | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docker/.env.example b/docker/.env.example index 33b4925514..dc09e9da91 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -38,7 +38,10 @@ LOG_LEVEL=simple # JWT SECRET ################################################################################### -JWT_SECRET=randomstringthatissolongandpowerfulthatnoonecanguess +# This JWT_SECRET is used to sign the authentication keys for user login +# You should set it to a long randomly generated value +# You can use this command to generate one: openssl rand -base64 128 +#JWT_SECRET= ################################################################################### # Reverse Geocoding From 00549eed790c7c99b01ddea3bd7e065739f34a98 Mon Sep 17 00:00:00 2001 From: bo0tzz Date: Wed, 12 Oct 2022 09:18:43 +0200 Subject: [PATCH 2/3] Uncomment JWT_SECRET in default .env Co-authored-by: Alex --- docker/.env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/.env.example b/docker/.env.example index dc09e9da91..7b398969da 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -41,7 +41,7 @@ LOG_LEVEL=simple # This JWT_SECRET is used to sign the authentication keys for user login # You should set it to a long randomly generated value # You can use this command to generate one: openssl rand -base64 128 -#JWT_SECRET= +JWT_SECRET= ################################################################################### # Reverse Geocoding From 9869b92c2b3269d3eaa6c145a0ed30d61d2cdba2 Mon Sep 17 00:00:00 2001 From: bo0tzz Date: Wed, 12 Oct 2022 09:34:10 +0200 Subject: [PATCH 3/3] Generate random JWT_SECRET value in install.sh --- install.sh | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/install.sh b/install.sh index 1701d33cc2..dbe0d8db6a 100755 --- a/install.sh +++ b/install.sh @@ -18,33 +18,37 @@ get_release_version() { create_immich_directory() { echo "Creating Immich directory..." mkdir -p ./immich-app/immich-data + cd ./immich-app } download_docker_compose_file() { echo "Downloading docker-compose.yml..." - curl -L https://raw.githubusercontent.com/immich-app/immich/$release_version/docker/docker-compose.yml -o ./immich-app/docker-compose.yml >/dev/null 2>&1 + curl -L https://raw.githubusercontent.com/immich-app/immich/$release_version/docker/docker-compose.yml -o ./docker-compose.yml >/dev/null 2>&1 } download_dot_env_file() { echo "Downloading .env file..." - curl -L https://raw.githubusercontent.com/immich-app/immich/$release_version/docker/.env.example -o ./immich-app/.env >/dev/null 2>&1 + curl -L https://raw.githubusercontent.com/immich-app/immich/$release_version/docker/.env.example -o ./.env >/dev/null 2>&1 +} + +replace_env_value() { + if [[ "$OSTYPE" == "darwin"* ]]; then + sed -i '' "s|$1=.*|$1=$2|" ./.env + else + sed -i "s|$1=.*|$1=$2|" ./.env + fi } populate_upload_location() { echo "Populating default UPLOAD_LOCATION value..." + upload_location=$(pwd)/immich-data + replace_env_value "UPLOAD_LOCATION" $upload_location +} - cd ./immich-app/immich-data - - upload_location=$(pwd) - - # Replace value of UPLOAD_LOCATION in .env with upload_location path - if [[ "$OSTYPE" == "darwin"* ]]; then - sed -i '' "s|UPLOAD_LOCATION=.*|UPLOAD_LOCATION=$upload_location|" ../.env - else - sed -i "s|UPLOAD_LOCATION=.*|UPLOAD_LOCATION=$upload_location|" ../.env - fi - - cd .. +generate_jwt_secret() { + echo "Generating JWT_SECRET value..." + jwt_secret=$(openssl rand -base64 128) + replace_env_value "JWT_SECRET" $jwt_secret } start_docker_compose() { @@ -88,4 +92,5 @@ create_immich_directory download_docker_compose_file download_dot_env_file populate_upload_location +generate_jwt_secret start_docker_compose