2018-12-09 16:45:08 -07:00
|
|
|
### BEGIN INIT INFO
|
2018-12-09 17:09:43 -07:00
|
|
|
# Provides: Jellyfin Media Server
|
2018-12-09 15:33:40 -07:00
|
|
|
# Required-Start: $local_fs $network
|
|
|
|
# Required-Stop: $local_fs
|
2018-12-09 16:45:08 -07:00
|
|
|
# Default-Start: 2 3 4 5
|
|
|
|
# Default-Stop: 0 1 6
|
2018-12-09 17:09:43 -07:00
|
|
|
# Short-Description: Jellyfin Media Server
|
|
|
|
# Description: Runs Jellyfin Server
|
2018-12-09 16:45:08 -07:00
|
|
|
### END INIT INFO
|
|
|
|
|
2018-12-09 15:33:40 -07:00
|
|
|
# Carry out specific functions when asked to by the system
|
2018-12-12 17:14:20 -07:00
|
|
|
pid=`ps -fA|grep dotnet|grep jellyfin|awk '{print $2}'| tr -d '\n'`
|
2018-12-09 16:45:08 -07:00
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
2018-12-09 15:33:40 -07:00
|
|
|
if [ "$pid" == "" ]; then
|
2018-12-09 17:09:43 -07:00
|
|
|
echo "Starting Jellyfin..."
|
2018-12-12 17:14:20 -07:00
|
|
|
. /etc/default/jellyfin
|
|
|
|
nohup su -u $JELLYFIN_USER -c $JELLYFIN_DOTNET $JELLYFIN_COMMAND
|
2018-12-09 15:33:40 -07:00
|
|
|
else
|
2018-12-09 17:09:43 -07:00
|
|
|
echo "Jellyfin already running"
|
2018-12-09 15:33:40 -07:00
|
|
|
fi
|
2018-12-09 16:45:08 -07:00
|
|
|
;;
|
|
|
|
stop)
|
2018-12-09 15:33:40 -07:00
|
|
|
if [ "$pid" != "" ]; then
|
2018-12-09 17:09:43 -07:00
|
|
|
echo "Stopping Jellyfin..."
|
2018-12-09 15:33:40 -07:00
|
|
|
kill $pid
|
|
|
|
sleep 2
|
|
|
|
else
|
2018-12-09 17:09:43 -07:00
|
|
|
echo "Jellyfin not running"
|
2018-12-09 15:33:40 -07:00
|
|
|
fi
|
2018-12-09 16:45:08 -07:00
|
|
|
;;
|
|
|
|
status)
|
2018-12-09 15:33:40 -07:00
|
|
|
if [ "$pid" != "" ]; then
|
2018-12-09 17:09:43 -07:00
|
|
|
echo "Jellyfin running as $pid"
|
2018-12-09 15:33:40 -07:00
|
|
|
ps -f $pid
|
|
|
|
else
|
2018-12-09 17:09:43 -07:00
|
|
|
echo "Jellyfin is not running"
|
2018-12-09 15:33:40 -07:00
|
|
|
fi
|
|
|
|
;;
|
2018-12-09 16:45:08 -07:00
|
|
|
*)
|
2018-12-09 15:33:40 -07:00
|
|
|
echo "Usage: $0 {start|stop}"
|
|
|
|
exit 1
|
2018-12-09 16:45:08 -07:00
|
|
|
;;
|
|
|
|
esac
|