Update init scripts for compatibility with Devuan

Include start, stop, restart and status option for /etc/init.d/jellyfin
Use start-stop-daemon to make the script refer to systemctl mechanism
on systems that have systemd installed
This commit is contained in:
Torsten 2019-03-20 20:00:23 +01:00
parent 7b01de8db1
commit bd31091648

View File

@ -8,42 +8,54 @@
# Description: Runs Jellyfin Server # Description: Runs Jellyfin Server
### END INIT INFO ### END INIT INFO
set -e
# Carry out specific functions when asked to by the system # Carry out specific functions when asked to by the system
pidfile="/var/run/jellyfin.pid" if test -f /etc/default/jellyfin; then
pid=`cat $pidfile` . /etc/default/jellyfin
fi
. /lib/lsb/init-functions
PIDFILE="/run/jellyfin.pid"
case "$1" in case "$1" in
start) start)
if [ "$pid" == "" ]; then log_daemon_msg "Starting Jellyfin Media Server" "jellyfin" || true
echo "Starting Jellyfin..."
. /etc/default/jellyfin if start-stop-daemon --start --quiet --oknodo --background --pidfile $PIDFILE --make-pidfile --user $JELLYFIN_USER --chuid $JELLYFIN_USER --exec /usr/bin/jellyfin -- $JELLYFIN_ARGS; then
nohup su -u $JELLYFIN_USER -c /usr/bin/jellyfin $JELLYFIN_ARGS log_end_msg 0 || true
echo ?? > $pidfile
else else
echo "Jellyfin already running" log_end_msg 1 || true
fi fi
;; ;;
stop) stop)
if [ "$pid" != "" ]; then log_daemon_msg "Stopping Jellyfin Media Server" "jellyfin" || true
echo "Stopping Jellyfin..." if start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --remove-pidfile; then
kill $pid log_end_msg 0 || true
sleep 2
rm -f $pidfile
else else
echo "Jellyfin not running" log_end_msg 1 || true
fi fi
;; ;;
restart)
log_daemon_msg "Restarting Jellyfin Media Server" "jellyfin" || true
start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PIDFILE --remove-pidfile
if start-stop-daemon --start --quiet --oknodo --background --pidfile $PIDFILE --make-pidfile --user $JELLYFIN_USER --chuid $JELLYFIN_USER --exec /usr/bin/jellyfin -- $JELLYFIN_ARGS; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
status) status)
if [ "$pid" != "" ]; then status_of_proc -p $PIDFILE /usr/bin/jellyfin jellyfin && exit 0 || exit $?
echo "Jellyfin running as $pid"
ps -f $pid
else
echo "Jellyfin is not running"
fi
;; ;;
*) *)
echo "Usage: $0 {start|stop}" echo "Usage: $0 {start|stop|restart|status}"
exit 1 exit 1
;; ;;
esac esac