#!/bin/bash
# After an upgrade: refresh the unit from the new package and bring the
# service back, unless the user had stopped the app (main stop disables the
# unit). fnOS only says it "may" restart apps after an upgrade, and a
# gateway that stays down until the next reboot takes its clients with it.

# shellcheck source=common
. "$(dirname "$0")/common"

log "upgrade_callback"
install_unit
if systemctl is-enabled --quiet "$UNIT"; then
	systemctl restart "$UNIT" >>"$LOG" 2>&1 || log "restart after upgrade failed"
fi
exit 0
