From 89034a5c69b4952f7641b2140b63573f773a18e5 Mon Sep 17 00:00:00 2001 From: Gartisk <> Date: Sun, 17 Mar 2024 01:11:53 +0000 Subject: [PATCH] Add script to upgrade immich-server vectors --- casaos-immich-vectors-upgrade/README.md | 5 ++ casaos-immich-vectors-upgrade/run.sh | 93 +++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 casaos-immich-vectors-upgrade/README.md create mode 100644 casaos-immich-vectors-upgrade/run.sh diff --git a/casaos-immich-vectors-upgrade/README.md b/casaos-immich-vectors-upgrade/README.md new file mode 100644 index 0000000..e501add --- /dev/null +++ b/casaos-immich-vectors-upgrade/README.md @@ -0,0 +1,5 @@ +# Run command + +```bash +bash -c "$(wget -qO - https://raw.githubusercontent.com/gartisk/big-bear-scripts/master/casaos-immich-vectors-upgrade/run.sh)" -- -u casaos -p 0.1.11 -n 0.2.0 +``` \ No newline at end of file diff --git a/casaos-immich-vectors-upgrade/run.sh b/casaos-immich-vectors-upgrade/run.sh new file mode 100644 index 0000000..a4a2336 --- /dev/null +++ b/casaos-immich-vectors-upgrade/run.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +######################################################################################### +# # +# Script: upgrade immich vectors # +# --------------------------------- # +# # +# Description: This script upgrade immich vectors to a new version # +# How to Use: ./run.sh -u casaos -p 0.1.11 -n 0.2.0 # +# # +# Author: Guilherme Araujo aka Gartisk # +# https://github.com/gartisk # +# # +# Date: 2024-03-16 # +# Version: 1.0 # +# # +# Reference: Thanks to Glitch3dPenguin for the solution in the discussion below: # +# - https://github.com/immich-app/immich/discussions/7310#discussioncomment-8647872 # +# # +######################################################################################### + +restartContainers(){ + local containers=("$@") + + for container in "${containers[@]}" + do + if docker inspect -f '{{.State.Running}}' $container >/dev/null 2>&1; then + echo "$container is running, stopping..." + docker restart $container + echo "$container has been restarted." + else + echo "$container is not running." + fi + done +} + +waitContainers(){ + # Wait for containers to start + local containers=("$@") + for container in "${containers[@]}" + do + while ! docker inspect -f '{{.State.Running}}' $container >/dev/null 2>&1; do + echo "$container is not running yet, waiting..." + sleep 5 + done + echo "$container is running." + done +} + +# INIT HERE +declare -a containers=("immich-machine-learning" "immich-postgres" "immich-server" "immich-microservices" "immich-redis") + +# Parse command line arguments +while getopts ":u:p:n:" opt; do + case $opt in + u) PSQL_USERNAME="$OPTARG";; + p) PREVIOUS_VERSION="$OPTARG";; + n) NEW_VERSION="$OPTARG";; + \?) echo "Invalid option -$OPTARG" >&2; exit 1;; + :) echo "Option -$OPTARG requires an argument." >&2; exit 1;; + esac +done + +# Check if required arguments are provided +if [ -z "$PSQL_USERNAME" ] || [ -z "$PREVIOUS_VERSION" ] || [ -z "$NEW_VERSION" ]; then + echo "Usage: $0 -u -v -V " >&2 + exit 1 +fi + +# Step 1: Log into the Docker container hosting PostgreSQL and Run the SQL commands +docker exec -i immich-postgres psql -U $PSQL_USERNAME -d immich <