diff options
| author | AJ Jordan <alex@strugee.net> | 2020-11-29 03:39:28 -0500 |
|---|---|---|
| committer | AJ Jordan <alex@strugee.net> | 2020-11-29 03:43:03 -0500 |
| commit | a4e1732e3553b7c039d23f89082fe23b058aac59 (patch) | |
| tree | 14fcdad47eeaaf35bb828f001c1a3275478f23d2 /debian | |
| parent | e936d0872bf4dd58c73ea38afc99d1e0d4e33538 (diff) | |
Fix restart.sh to look at what's actually booted
The old code was wrong because e.g. systemd can be *installed* on the
system, but not actually used as PID1. In that case we would pick
`systemctl`, but it wouldn't actually work because PID1 was some other
init system.
Diffstat (limited to 'debian')
| -rwxr-xr-x | debian/bin/restart.sh | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/debian/bin/restart.sh b/debian/bin/restart.sh index 34fce0670..acbec3dc7 100755 --- a/debian/bin/restart.sh +++ b/debian/bin/restart.sh @@ -11,16 +11,29 @@ # # This script is used by the Debian/Ubuntu/Fedora/CentOS packages. -get_service_command() { - for command in systemctl service; do - if which $command &>/dev/null; then - echo $command && return +# This is the Right Way(tm) to check if we are booted with +# systemd, according to sd_booted(3) +if [ -d /run/systemd/system ]; then + cmd=systemctl +else + # Everything else is really hard to figure out, so we just use + # service(8) if it's available - that works with most init + # systems/distributions I know of, including FreeBSD + if type service >/dev/null 2>&1; then + cmd=service + else + # If even service(8) isn't available, we just try /etc/init.d + # and hope for the best + if [ -d /etc/init.d ]; then + cmd=sysv + else + echo "Unable to detect a way to restart Jellyfin; bailing out" 1>&2 + echo "Please report this bug to https://github.com/jellyfin/jellyfin/issues" 1>&2 + exit 1 fi - done - echo "sysv" -} + fi +fi -cmd="$( get_service_command )" echo "Detected service control platform '$cmd'; using it to restart Jellyfin..." case $cmd in 'systemctl') |
