mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-26 02:31:51 +02:00
Update 99-run.sh
This commit is contained in:
@@ -132,25 +132,38 @@ wait_for_postgres() {
|
|||||||
restart_immich_addons_if_flagged() {
|
restart_immich_addons_if_flagged() {
|
||||||
if [ -f "$RESTART_FLAG_FILE" ]; then
|
if [ -f "$RESTART_FLAG_FILE" ]; then
|
||||||
bashio::log.warning "Detected pending Immich add-on restart flag. Restarting all running Immich add-ons..."
|
bashio::log.warning "Detected pending Immich add-on restart flag. Restarting all running Immich add-ons..."
|
||||||
local addons slug found=0
|
|
||||||
addons=$(curl -s -H "Authorization: Bearer $SUPERVISOR_TOKEN" http://supervisor/addons)
|
local addons_json slug found=0
|
||||||
|
|
||||||
|
# Get the add-ons list, fail on HTTP errors, show errors if API call fails
|
||||||
|
addons_json=$(curl -fsSL -H "Authorization: Bearer $SUPERVISOR_TOKEN" http://supervisor/addons) || {
|
||||||
|
bashio::log.error "Supervisor API call failed or unauthorized: $addons_json"
|
||||||
|
rm -f "$RESTART_FLAG_FILE"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
if command -v jq >/dev/null; then
|
if command -v jq >/dev/null; then
|
||||||
for slug in $(echo "$addons" | jq -r '.data.addons[] | select(.state=="started") | .slug'); do
|
# Use correct JSON path for modern Supervisor API
|
||||||
|
for slug in $(echo "$addons_json" | jq -r '.addons[] | select(.state=="started") | .slug'); do
|
||||||
if [[ "$slug" == *immich* ]]; then
|
if [[ "$slug" == *immich* ]]; then
|
||||||
bashio::log.info "Restarting addon $slug"
|
bashio::log.info "Restarting addon $slug"
|
||||||
curl -s -X POST -H "Authorization: Bearer $SUPERVISOR_TOKEN" "http://supervisor/addons/$slug/restart"
|
curl -fsSL -X POST -H "Authorization: Bearer $SUPERVISOR_TOKEN" \
|
||||||
|
"http://supervisor/addons/$slug/restart"
|
||||||
found=1
|
found=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
for slug in $(echo "$addons" | grep -o '"slug":"[^"]*"' | cut -d: -f2 | tr -d '"'); do
|
# Fallback: grep/cut for legacy environments, less robust
|
||||||
|
for slug in $(echo "$addons_json" | grep -o '"slug":"[^"]*"' | cut -d: -f2 | tr -d '"'); do
|
||||||
if [[ "$slug" == *immich* ]]; then
|
if [[ "$slug" == *immich* ]]; then
|
||||||
bashio::log.info "Restarting addon $slug"
|
bashio::log.info "Restarting addon $slug"
|
||||||
curl -s -X POST -H "Authorization: Bearer $SUPERVISOR_TOKEN" "http://supervisor/addons/$slug/restart"
|
curl -fsSL -X POST -H "Authorization: Bearer $SUPERVISOR_TOKEN" \
|
||||||
|
"http://supervisor/addons/$slug/restart"
|
||||||
found=1
|
found=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$found" -eq 0 ]; then
|
if [ "$found" -eq 0 ]; then
|
||||||
bashio::log.info "No Immich-related addon found running."
|
bashio::log.info "No Immich-related addon found running."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user