parent
919f685e79
commit
c591b6d751
@ -1,88 +1,44 @@
|
||||
#!/bin/bash
|
||||
### BEGIN INIT INFO
|
||||
# Provides: jellyfin
|
||||
# Required-Start: $remote_fs $local_fs $network
|
||||
# Required-Stop: $remote_fs $local_fs $network
|
||||
# Provides: Emby Server
|
||||
# Required-Start: $local_fs $network
|
||||
# Required-Stop: $local_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: starts instance of Emby
|
||||
# Description: starts instance of Emby
|
||||
# Short-Description: Emby Server
|
||||
# Description: Runs Emby Server
|
||||
### END INIT INFO
|
||||
|
||||
|
||||
# chkconfig: 2345 20 80
|
||||
#The above indicates that the script should be started in levels 2, 3, 4, and 5, #that its start priority should be 20, and that its stop priority should be 80.
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
. /lib/init/vars.sh
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
NAME=jellyfin
|
||||
CONF_FILE=/etc/${NAME}.conf
|
||||
DEFAULT_FILE=/etc/default/${NAME}
|
||||
|
||||
# Source Jellyfin default configuration
|
||||
. $DEFAULT_FILE
|
||||
|
||||
# Source Jellyfin user configuration overrides
|
||||
if [[ -f $CONF_FILE ]]; then
|
||||
. $CONF_FILE
|
||||
else
|
||||
echo "${CONF_FILE} not found using default settings.";
|
||||
fi
|
||||
|
||||
# Path of jellyfin binary
|
||||
JELLYFINSERVER=/usr/bin/jellyfin
|
||||
PIDFILE=${JELLYFIN_PIDFILE-/var/run/jellyfin.pid}
|
||||
# Carry out specific functions when asked to by the system
|
||||
pid=`ps -fA|grep dotnet|grep EmbyServer|awk '{print $2}'| tr -d '\n'`
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
log_daemon_msg "Starting $NAME daemon"
|
||||
if [[ -s $PIDFILE ]] && [[ -n "$(ps -p $(cat $PIDFILE) -o pid=)" ]]; then
|
||||
log_daemon_msg "apparently already running"
|
||||
log_end_msg 0
|
||||
exit 0
|
||||
fi
|
||||
exec $JELLYFINSERVER start &
|
||||
sleep 2
|
||||
if [[ -s $PIDFILE ]] && [[ -n "$(ps -p $(cat $PIDFILE) -o pid=)" ]]; then
|
||||
log_end_msg 0
|
||||
if [ "$pid" == "" ]; then
|
||||
echo "Starting Emby..."
|
||||
nohup dotnet /usr/lib/jellyfin/bin/EmbyServer.dll >/dev/null 2>&1 &
|
||||
else
|
||||
log_end_msg 1
|
||||
echo "Emby already running"
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
log_daemon_msg "Stopping $NAME daemon"
|
||||
if [[ ! -s $PIDFILE ]] || [[ -z "$(ps -p $(cat $PIDFILE) -o pid=)" ]]; then
|
||||
[[ -e $PIDFILE ]] && rm -rf $PIDFILE
|
||||
log_success_msg "apparently already stopped"
|
||||
log_end_msg 0
|
||||
exit 0
|
||||
fi
|
||||
PID=$(cat $PIDFILE)
|
||||
CPIDS=$(pgrep -P $PID)
|
||||
sleep 2 && kill -KILL $CPIDS
|
||||
kill -TERM $CPIDS > /dev/null 2>&1
|
||||
if [ "$pid" != "" ]; then
|
||||
echo "Stopping Emby..."
|
||||
kill $pid
|
||||
sleep 2
|
||||
if [[ -z "$(ps -p $PID -o pid=)" ]]; then
|
||||
rm -rf $PIDFILE
|
||||
log_end_msg 0
|
||||
else
|
||||
log_end_msg 1
|
||||
echo "Emby not running"
|
||||
fi
|
||||
;;
|
||||
status)
|
||||
status_of_proc -p $PIDFILE "$JELLYFINSERVER" "$NAME"
|
||||
exit $? # notreached due to set -e
|
||||
;;
|
||||
restart|force-reload)
|
||||
$0 stop || exit $?
|
||||
$0 start || exit $?
|
||||
if [ "$pid" != "" ]; then
|
||||
echo "Emby running as $pid"
|
||||
ps -f $pid
|
||||
else
|
||||
echo "Emby is not running"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Usage: /etc/init.d/jellyfin {start|stop|status|restart|force-reload}" >&2
|
||||
exit 3
|
||||
echo "Usage: $0 {start|stop}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
Loading…
Reference in new issue