2024-02-18 16:03:01 -07:00
|
|
|
#!/usr/bin/env bash
|
2024-04-08 16:01:57 -07:00
|
|
|
set -o nounset
|
|
|
|
set -o pipefail
|
2024-02-18 16:03:01 -07:00
|
|
|
|
2024-04-08 16:01:57 -07:00
|
|
|
create_immich_directory() { local -r Tgt='./immich-app'
|
2022-08-06 21:42:50 -07:00
|
|
|
echo "Creating Immich directory..."
|
2024-04-08 16:01:57 -07:00
|
|
|
if [[ -e $Tgt ]]; then
|
|
|
|
echo "Found existing directory $Tgt, will overwrite YAML files"
|
|
|
|
else
|
|
|
|
mkdir "$Tgt" || return
|
|
|
|
fi
|
|
|
|
cd "$Tgt" || return
|
2022-08-06 21:42:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
download_docker_compose_file() {
|
|
|
|
echo "Downloading docker-compose.yml..."
|
2024-04-08 16:01:57 -07:00
|
|
|
"${Curl[@]}" "$RepoUrl"/docker-compose.yml -o ./docker-compose.yml
|
2022-08-06 21:42:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
download_dot_env_file() {
|
|
|
|
echo "Downloading .env file..."
|
2024-04-08 16:01:57 -07:00
|
|
|
"${Curl[@]}" "$RepoUrl"/example.env -o ./.env
|
2022-08-06 21:42:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
start_docker_compose() {
|
|
|
|
echo "Starting Immich's docker containers"
|
|
|
|
|
2024-04-08 16:01:57 -07:00
|
|
|
if ! docker compose >/dev/null 2>&1; then
|
|
|
|
echo "failed to find 'docker compose'"
|
|
|
|
return 1
|
2022-09-10 09:48:50 -07:00
|
|
|
fi
|
2022-08-06 21:42:50 -07:00
|
|
|
|
2024-04-08 16:01:57 -07:00
|
|
|
if ! docker compose up --remove-orphans -d; then
|
2022-09-10 09:48:50 -07:00
|
|
|
echo "Could not start. Check for errors above."
|
2024-04-08 16:01:57 -07:00
|
|
|
return 1
|
2022-08-06 21:42:50 -07:00
|
|
|
fi
|
2024-04-08 16:01:57 -07:00
|
|
|
show_friendly_message
|
2022-08-06 21:42:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
show_friendly_message() {
|
2024-04-08 16:01:57 -07:00
|
|
|
local ip_address
|
|
|
|
ip_address=$(hostname -I | awk '{print $1}')
|
|
|
|
cat << EOF
|
|
|
|
Successfully deployed Immich!
|
|
|
|
You can access the website at http://$ip_address:2283 and the server URL for the mobile app is http://$ip_address:2283/api
|
|
|
|
---------------------------------------------------
|
|
|
|
If you want to configure custom information of the server, including the database, Redis information, or the backup (or upload) location, etc.
|
2022-08-06 21:42:50 -07:00
|
|
|
|
2024-04-08 16:01:57 -07:00
|
|
|
1. First bring down the containers with the command 'docker compose down' in the immich-app directory,
|
2022-08-06 21:42:50 -07:00
|
|
|
|
|
|
|
2. Then change the information that fits your needs in the '.env' file,
|
|
|
|
|
2024-04-08 16:01:57 -07:00
|
|
|
3. Finally, bring the containers back up with the command 'docker compose up --remove-orphans -d' in the immich-app directory
|
|
|
|
EOF
|
2022-08-06 21:42:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
# MAIN
|
2024-04-08 16:01:57 -07:00
|
|
|
main() {
|
|
|
|
echo "Starting Immich installation..."
|
|
|
|
local -r RepoUrl='https://github.com/immich-app/immich/releases/latest/download'
|
|
|
|
local -a Curl
|
|
|
|
if command -v curl >/dev/null; then
|
|
|
|
Curl=(curl -fsSL)
|
|
|
|
else
|
|
|
|
echo 'no curl binary found; please install curl and try again'
|
|
|
|
return 14
|
|
|
|
fi
|
|
|
|
|
|
|
|
create_immich_directory || { echo 'error creating Immich directory'; return 10; }
|
|
|
|
download_docker_compose_file || { echo 'error downloading Docker Compose file'; return 11; }
|
|
|
|
download_dot_env_file || { echo 'error downloading .env'; return 12; }
|
|
|
|
start_docker_compose || { echo 'error starting Docker'; return 13; }
|
|
|
|
return 0; }
|
|
|
|
|
|
|
|
main
|
|
|
|
Exit=$?
|
|
|
|
[[ $Exit == 0 ]] || echo "There was an error installing Immich. Exit code: $Exit. Please provide these logs when asking for assistance."
|
|
|
|
exit "$Exit"
|