Use systemd-run(1) in restart.sh
systemd-run(1) runs `systemctl restart` in an isolated systemd unit that is not subject to process termination as jellyfin.service is shut down. We adjust the sudoers configuration for this new usage, removing the old config, since restart.sh is the only user of the sudoers policy. Additionally we change `systemctl start` to `systemctl restart` since there was a race condition where jellyfin.service was not fully stopped by the time this ran, so `systemctl start` became a noop. `systemctl restart` on the other hand works whether jellyfin.service is stopped or not. The at(1) hack (and the usage of `start` instead of `restart`) is left in for other init systems since I cannot test on those systems, and because I don't know of any systemd-run(1) equivalent (although it may be a non-issue since alternate init systems do not keep track of daemon children nearly as aggressively as systemd does).
This commit is contained in:
parent
b528816b2a
commit
d251c701b9
3
debian/bin/restart.sh
vendored
3
debian/bin/restart.sh
vendored
|
@ -43,7 +43,8 @@ fi
|
||||||
echo "Detected service control platform '$cmd'; using it to restart Jellyfin..."
|
echo "Detected service control platform '$cmd'; using it to restart Jellyfin..."
|
||||||
case $cmd in
|
case $cmd in
|
||||||
'systemctl')
|
'systemctl')
|
||||||
echo "sleep 0.5; $sudo_command systemctl start jellyfin" | at now
|
# Without systemd-run here, `jellyfin.service`'s shutdown terminates this process too
|
||||||
|
$sudo_command systemd-run --scope systemctl restart jellyfin
|
||||||
;;
|
;;
|
||||||
'service')
|
'service')
|
||||||
echo "sleep 0.5; $sudo_command service jellyfin start" | at now
|
echo "sleep 0.5; $sudo_command service jellyfin start" | at now
|
||||||
|
|
6
debian/conf/jellyfin-sudoers
vendored
6
debian/conf/jellyfin-sudoers
vendored
|
@ -2,9 +2,9 @@
|
||||||
Cmnd_Alias RESTARTSERVER_SYSV = /sbin/service jellyfin restart, /usr/sbin/service jellyfin restart
|
Cmnd_Alias RESTARTSERVER_SYSV = /sbin/service jellyfin restart, /usr/sbin/service jellyfin restart
|
||||||
Cmnd_Alias STARTSERVER_SYSV = /sbin/service jellyfin start, /usr/sbin/service jellyfin start
|
Cmnd_Alias STARTSERVER_SYSV = /sbin/service jellyfin start, /usr/sbin/service jellyfin start
|
||||||
Cmnd_Alias STOPSERVER_SYSV = /sbin/service jellyfin stop, /usr/sbin/service jellyfin stop
|
Cmnd_Alias STOPSERVER_SYSV = /sbin/service jellyfin stop, /usr/sbin/service jellyfin stop
|
||||||
Cmnd_Alias RESTARTSERVER_SYSTEMD = /usr/bin/systemctl restart jellyfin, /bin/systemctl restart jellyfin
|
Cmnd_Alias RESTARTSERVER_SYSTEMD = /usr/bin/systemd-run --scope systemctl restart jellyfin
|
||||||
Cmnd_Alias STARTSERVER_SYSTEMD = /usr/bin/systemctl start jellyfin, /bin/systemctl start jellyfin
|
Cmnd_Alias STARTSERVER_SYSTEMD = /usr/bin/systemd-run --scope systemctl start jellyfin
|
||||||
Cmnd_Alias STOPSERVER_SYSTEMD = /usr/bin/systemctl stop jellyfin, /bin/systemctl stop jellyfin
|
Cmnd_Alias STOPSERVER_SYSTEMD = /usr/bin/systemd-run --scope systemctl stop jellyfin
|
||||||
Cmnd_Alias RESTARTSERVER_INITD = /etc/init.d/jellyfin restart
|
Cmnd_Alias RESTARTSERVER_INITD = /etc/init.d/jellyfin restart
|
||||||
Cmnd_Alias STARTSERVER_INITD = /etc/init.d/jellyfin start
|
Cmnd_Alias STARTSERVER_INITD = /etc/init.d/jellyfin start
|
||||||
Cmnd_Alias STOPSERVER_INITD = /etc/init.d/jellyfin stop
|
Cmnd_Alias STOPSERVER_INITD = /etc/init.d/jellyfin stop
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
# Allow jellyfin group to start, stop and restart itself
|
# Allow jellyfin group to start, stop and restart itself
|
||||||
Cmnd_Alias RESTARTSERVER_SYSTEMD = /usr/bin/systemctl restart jellyfin, /bin/systemctl restart jellyfin
|
Cmnd_Alias RESTARTSERVER_SYSTEMD = /usr/bin/systemd-run --scope systemctl restart jellyfin
|
||||||
Cmnd_Alias STARTSERVER_SYSTEMD = /usr/bin/systemctl start jellyfin, /bin/systemctl start jellyfin
|
Cmnd_Alias STARTSERVER_SYSTEMD = /usr/bin/systemd-run --scope systemctl start jellyfin
|
||||||
Cmnd_Alias STOPSERVER_SYSTEMD = /usr/bin/systemctl stop jellyfin, /bin/systemctl stop jellyfin
|
Cmnd_Alias STOPSERVER_SYSTEMD = /usr/bin/systemd-run --scope systemctl stop jellyfin
|
||||||
|
|
||||||
|
|
||||||
jellyfin ALL=(ALL) NOPASSWD: RESTARTSERVER_SYSTEMD
|
jellyfin ALL=(ALL) NOPASSWD: RESTARTSERVER_SYSTEMD
|
||||||
jellyfin ALL=(ALL) NOPASSWD: STARTSERVER_SYSTEMD
|
jellyfin ALL=(ALL) NOPASSWD: STARTSERVER_SYSTEMD
|
||||||
|
|
|
@ -43,7 +43,8 @@ fi
|
||||||
echo "Detected service control platform '$cmd'; using it to restart Jellyfin..."
|
echo "Detected service control platform '$cmd'; using it to restart Jellyfin..."
|
||||||
case $cmd in
|
case $cmd in
|
||||||
'systemctl')
|
'systemctl')
|
||||||
echo "sleep 0.5; $sudo_command systemctl start jellyfin" | at now
|
# Without systemd-run here, `jellyfin.service`'s shutdown terminates this process too
|
||||||
|
$sudo_command systemd-run --scope systemctl restart jellyfin
|
||||||
;;
|
;;
|
||||||
'service')
|
'service')
|
||||||
echo "sleep 0.5; $sudo_command service jellyfin start" | at now
|
echo "sleep 0.5; $sudo_command service jellyfin start" | at now
|
||||||
|
|
Loading…
Reference in New Issue
Block a user