Skip to content

Commit

Permalink
Generate random JWT_SECRET value in install.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
bo0tzz committed Oct 12, 2022
1 parent 00549ee commit 9869b92
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

populate_upload_location() {
echo "Populating default UPLOAD_LOCATION value..."

cd ./immich-app/immich-data

upload_location=$(pwd)

# Replace value of UPLOAD_LOCATION in .env with upload_location path
replace_env_value() {
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s|UPLOAD_LOCATION=.*|UPLOAD_LOCATION=$upload_location|" ../.env
sed -i '' "s|$1=.*|$1=$2|" ./.env
else
sed -i "s|UPLOAD_LOCATION=.*|UPLOAD_LOCATION=$upload_location|" ../.env
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 ..
generate_jwt_secret() {
echo "Generating JWT_SECRET value..."
jwt_secret=$(openssl rand -base64 128)
replace_env_value "JWT_SECRET" $jwt_secret
}

start_docker_compose() {
Expand Down Expand Up @@ -88,4 +92,5 @@ create_immich_directory
download_docker_compose_file
download_dot_env_file
populate_upload_location
generate_jwt_secret
start_docker_compose

0 comments on commit 9869b92

Please sign in to comment.