2022-08-07 06:42:50 +02:00
|
|
|
echo "Starting Immich installation..."
|
|
|
|
|
|
|
|
ip_address=$(hostname -I | awk '{print $1}')
|
|
|
|
|
2022-09-14 18:07:37 +02:00
|
|
|
release_version=$(curl --silent "https://api.github.com/repos/immich-app/immich/releases/latest" |
|
|
|
|
grep '"tag_name":' |
|
|
|
|
sed -E 's/.*"([^"]+)".*/\1/')
|
2022-08-07 06:42:50 +02:00
|
|
|
RED='\033[0;31m'
|
|
|
|
GREEN='\032[0;31m'
|
|
|
|
NC='\033[0m' # No Color
|
|
|
|
|
2022-09-14 18:07:37 +02:00
|
|
|
get_release_version() {
|
|
|
|
curl --silent "https://api.github.com/repos/immich-app/immich/releases/latest" | # Get latest release from GitHub api
|
|
|
|
grep '"tag_name":' | # Get tag line
|
|
|
|
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
|
|
|
|
}
|
|
|
|
|
2022-08-07 06:42:50 +02:00
|
|
|
create_immich_directory() {
|
|
|
|
echo "Creating Immich directory..."
|
|
|
|
mkdir -p ./immich-app/immich-data
|
2022-10-12 09:34:10 +02:00
|
|
|
cd ./immich-app
|
2022-08-07 06:42:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
download_docker_compose_file() {
|
|
|
|
echo "Downloading docker-compose.yml..."
|
2022-10-12 09:34:10 +02:00
|
|
|
curl -L https://raw.githubusercontent.com/immich-app/immich/$release_version/docker/docker-compose.yml -o ./docker-compose.yml >/dev/null 2>&1
|
2022-08-07 06:42:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
download_dot_env_file() {
|
|
|
|
echo "Downloading .env file..."
|
2023-01-24 17:26:58 +02:00
|
|
|
curl -L https://raw.githubusercontent.com/immich-app/immich/$release_version/docker/example.env -o ./.env >/dev/null 2>&1
|
2022-08-07 06:42:50 +02:00
|
|
|
}
|
|
|
|
|
2022-10-12 09:34:10 +02:00
|
|
|
replace_env_value() {
|
2022-08-07 06:42:50 +02:00
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
2022-10-12 09:34:10 +02:00
|
|
|
sed -i '' "s|$1=.*|$1=$2|" ./.env
|
2022-08-07 06:42:50 +02:00
|
|
|
else
|
2022-10-12 09:34:10 +02:00
|
|
|
sed -i "s|$1=.*|$1=$2|" ./.env
|
2022-08-07 06:42:50 +02:00
|
|
|
fi
|
2022-10-12 09:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
populate_upload_location() {
|
|
|
|
echo "Populating default UPLOAD_LOCATION value..."
|
|
|
|
upload_location=$(pwd)/immich-data
|
|
|
|
replace_env_value "UPLOAD_LOCATION" $upload_location
|
|
|
|
}
|
2022-08-07 06:42:50 +02:00
|
|
|
|
|
|
|
start_docker_compose() {
|
|
|
|
echo "Starting Immich's docker containers"
|
|
|
|
|
2022-09-14 18:07:37 +02:00
|
|
|
if docker compose &>/dev/null; then
|
2022-09-10 18:48:50 +02:00
|
|
|
docker_bin="docker compose"
|
2022-09-14 18:07:37 +02:00
|
|
|
elif docker-compose &>/dev/null; then
|
2022-09-10 18:48:50 +02:00
|
|
|
docker_bin="docker-compose"
|
|
|
|
else
|
|
|
|
echo 'Cannot find `docker compose` or `docker-compose`.'
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-08-07 06:42:50 +02:00
|
|
|
|
2022-09-10 18:48:50 +02:00
|
|
|
if $docker_bin up --remove-orphans -d; then
|
2022-08-07 06:42:50 +02:00
|
|
|
show_friendly_message
|
|
|
|
exit 0
|
2022-09-10 18:48:50 +02:00
|
|
|
else
|
|
|
|
echo "Could not start. Check for errors above."
|
|
|
|
exit 1
|
2022-08-07 06:42:50 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
show_friendly_message() {
|
|
|
|
echo "Succesfully deployed Immich!"
|
|
|
|
echo "You can access the website at http://$ip_address:2283 and the server URL for the mobile app is http://$ip_address:2283/api"
|
|
|
|
echo "The backup (or upload) location is $upload_location"
|
|
|
|
echo "---------------------------------------------------"
|
2022-09-14 13:53:34 +02:00
|
|
|
echo "If you want to configure custom information of the server, including the database, Redis information, or the backup (or upload) location, etc.
|
2022-08-07 06:42:50 +02:00
|
|
|
|
|
|
|
1. First bring down the containers with the command 'docker-compose down' in the immich-app directory,
|
|
|
|
|
|
|
|
2. Then change the information that fits your needs in the '.env' file,
|
|
|
|
|
|
|
|
3. Finally, bring the containers back up with the command 'docker-compose up --remove-orphans -d' in the immich-app directory"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# MAIN
|
|
|
|
create_immich_directory
|
|
|
|
download_docker_compose_file
|
|
|
|
download_dot_env_file
|
|
|
|
populate_upload_location
|
|
|
|
start_docker_compose
|