Th novaboot-delayed-power-off.service was meant to activate
system-level systemd timer at uses session shutdown. However, this
never worked, because an user service cannot be activated as a part of
session shutdown, because each service depends on app.slice and this
slice is being stopped in the shutdown sequence, which results in
removing the service start request from the shutdown transaction. This
behavior is demonstrated by the systemd debug log below:
Pulling in novaboot-delayed-power-off.service/start from shutdown.target/start
Added job novaboot-delayed-power-off.service/start to transaction.
Pulling in app.slice/start from novaboot-delayed-power-off.service/start
Pulling in novaboot-delayed-power-off.service/stop from app.slice/stop
Added job novaboot-delayed-power-off.service/stop to transaction.
Keeping job novaboot-delayed-power-off.service/stop because of app.slice/stop
novaboot-delayed-power-off.service: Deleting job novaboot-delayed-power-off.service/start as dependency of job app.slice/start
Keeping job novaboot-delayed-power-off.service/stop because of app.slice/stop
Keeping job novaboot-delayed-power-off.service/stop because of app.slice/stop
Keeping job novaboot-delayed-power-off.service/stop because of app.slice/stop
Found redundant job novaboot-delayed-power-off.service/stop, dropping from transaction.
Therefore, we don't use a service with ExecStart, but use ExecStop to
start the shutdown timer and start the service by novaboot-shell
whenever the board is powered on.
if [ "$PPID" -ne 1 ] && systemctl --user is-enabled --quiet novaboot-delayed-power-off.service; then
sudo novaboot-power "$1"
+ if [ "$1" = "on" ]; then systemctl --user start novaboot-delayed-power-off.service; fi
else
eval "$cmd"
fi
Description=Delayed power-off of the novaboot target
ConditionGroup=novaboot
ConditionFileNotEmpty=%h/.novaboot-shell
-Before=shutdown.target
-DefaultDependencies=no
[Service]
Type=oneshot
-ExecStart=/usr/bin/sudo novaboot-power delayed-off
-
-[Install]
-WantedBy=shutdown.target
+ExecStop=/usr/bin/sudo novaboot-power delayed-off
+RemainAfterExit=true