immich_version_checker.sh
· 711 B · Bash
Raw
#!/bin/bash
set -euo pipefail
API_URL="http://localhost:2283/api/server/version-check"
# API Key med bare les på server.versionCheck
# Account Settings -> API Keys -> + New API Key -> velg
API_KEY="696969696969696969696969"
GITHUB_URL="https://api.github.com/repos/immich-app/immich/releases/latest"
get_local_version() {
curl -fsS -H "x-api-key: $API_KEY" "$API_URL" | jq -r '.releaseVersion'
}
get_latest_version() {
curl -fsS "$GITHUB_URL" jq -r '.tag_name'
}
LOCAL=$(get_local_version)
LATEST=$(get_latest_version)
printf "Local : %s\n" "$LOCAL"
printf "Latest: %s\n" "$LATEST"
if [[ "$LOCAL" != "$LATEST" ]]; then
echo "New version available!!"
exit 1
else
echo "Up to date"
exit 0
fi
| 1 | #!/bin/bash |
| 2 | |
| 3 | set -euo pipefail |
| 4 | |
| 5 | API_URL="http://localhost:2283/api/server/version-check" |
| 6 | # API Key med bare les på server.versionCheck |
| 7 | # Account Settings -> API Keys -> + New API Key -> velg |
| 8 | API_KEY="696969696969696969696969" |
| 9 | GITHUB_URL="https://api.github.com/repos/immich-app/immich/releases/latest" |
| 10 | |
| 11 | get_local_version() { |
| 12 | curl -fsS -H "x-api-key: $API_KEY" "$API_URL" | jq -r '.releaseVersion' |
| 13 | } |
| 14 | |
| 15 | get_latest_version() { |
| 16 | curl -fsS "$GITHUB_URL" jq -r '.tag_name' |
| 17 | } |
| 18 | |
| 19 | LOCAL=$(get_local_version) |
| 20 | LATEST=$(get_latest_version) |
| 21 | |
| 22 | printf "Local : %s\n" "$LOCAL" |
| 23 | printf "Latest: %s\n" "$LATEST" |
| 24 | |
| 25 | if [[ "$LOCAL" != "$LATEST" ]]; then |
| 26 | echo "New version available!!" |
| 27 | exit 1 |
| 28 | else |
| 29 | echo "Up to date" |
| 30 | exit 0 |
| 31 | fi |
| 32 |