mirror of https://github.com/jellyfin/jellyfin.git
Add nicer restart script
The old restart script was buggy, as reported in #1320. This updated script seems to work far more reliably and conforms to the existing jellyfin-sudoers packages sudo configuration.
This commit is contained in:
parent
c52e8a2027
commit
c08c0272b5
|
@ -1,20 +1,36 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
NAME=jellyfin
|
# restart.sh - Jellyfin server restart script
|
||||||
|
# Part of the Jellyfin project (https://github.com/jellyfin)
|
||||||
|
#
|
||||||
|
# This script restarts the Jellyfin daemon on Linux when using
|
||||||
|
# the Restart button on the admin dashboard. It supports the
|
||||||
|
# systemctl, service, and traditional /etc/init.d (sysv) restart
|
||||||
|
# methods, chosen automatically by which one is found first (in
|
||||||
|
# that order).
|
||||||
|
#
|
||||||
|
# This script is used by the Debian/Ubuntu/Fedora/CentOS packages.
|
||||||
|
|
||||||
restart_cmds=(
|
get_service_command() {
|
||||||
"systemctl restart ${NAME}"
|
for command in systemctl service; do
|
||||||
"service ${NAME} restart"
|
if which $command &>/dev/null; then
|
||||||
"/etc/init.d/${NAME} restart"
|
echo $command && return
|
||||||
"s6-svc -t /var/run/s6/services/${NAME}"
|
fi
|
||||||
)
|
done
|
||||||
|
echo "sysv"
|
||||||
|
}
|
||||||
|
|
||||||
for restart_cmd in "${restart_cmds[@]}"; do
|
cmd="$( get_service_command )"
|
||||||
cmd=$(echo "$restart_cmd" | awk '{print $1}')
|
echo "Using system control command '$cmd' to restart Jellyfin..."
|
||||||
cmd_loc=$(command -v ${cmd})
|
case $cmd in
|
||||||
if [[ -n "$cmd_loc" ]]; then
|
'systemctl')
|
||||||
restart_cmd=$(echo "$restart_cmd" | sed -e "s%${cmd}%${cmd_loc}%")
|
echo "sleep 2; /usr/bin/sudo /usr/bin/systemctl restart jellyfin" | at now
|
||||||
echo "sleep 2; sudo $restart_cmd > /dev/null 2>&1" | at now > /dev/null 2>&1
|
;;
|
||||||
exit 0
|
'service')
|
||||||
fi
|
echo "sleep 2; /usr/bin/sudo /sbin/service jellyfin restart" | at now
|
||||||
done
|
;;
|
||||||
|
'sysv')
|
||||||
|
echo "sleep 2; /usr/bin/sudo /etc/init.d/jellyfin restart" | at now
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
exit 0
|
||||||
|
|
|
@ -1,6 +1,36 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
NAME=jellyfin
|
# restart.sh - Jellyfin server restart script
|
||||||
restart_cmd="/usr/bin/systemctl restart ${NAME}"
|
# Part of the Jellyfin project (https://github.com/jellyfin)
|
||||||
echo "sleep 2; sudo $restart_cmd > /dev/null 2>&1" | at now > /dev/null 2>&1
|
#
|
||||||
exit 0
|
# This script restarts the Jellyfin daemon on Linux when using
|
||||||
|
# the Restart button on the admin dashboard. It supports the
|
||||||
|
# systemctl, service, and traditional /etc/init.d (sysv) restart
|
||||||
|
# methods, chosen automatically by which one is found first (in
|
||||||
|
# that order).
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "sysv"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd="$( get_service_command )"
|
||||||
|
echo "Using system control command '$cmd' to restart Jellyfin..."
|
||||||
|
case $cmd in
|
||||||
|
'systemctl')
|
||||||
|
echo "sleep 2; /usr/bin/sudo /usr/bin/systemctl restart jellyfin" | at now
|
||||||
|
;;
|
||||||
|
'service')
|
||||||
|
echo "sleep 2; /usr/bin/sudo /sbin/service jellyfin restart" | at now
|
||||||
|
;;
|
||||||
|
'sysv')
|
||||||
|
echo "sleep 2; /usr/bin/sudo /etc/init.d/jellyfin restart" | at now
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue