jellyfin-server/debian/prerm
Joshua Boniface 8fcec19936 Rename numerous debian control elements
Replace the name emby/emby-server with jellyfin everywhere.
2018-12-09 16:51:38 -05:00

65 lines
1.8 KiB
Bash

#!/bin/bash
set -e
NAME=jellyfin
CONF_FILE=/etc/${NAME}.conf
DEFAULT_FILE=/etc/default/${NAME}
# Source Jellyfin default configuration
if [[ -f $DEFAULT_FILE ]]; then
. $DEFAULT_FILE
fi
# Source Jellyfin user configuration overrides
if [[ -f $CONF_FILE ]]; then
. $CONF_FILE
fi
# Data directory where Emby database, cache and logs are stored
PROGRAMDATA=${JELLYFIN_DATA-/var/lib/$NAME}
case "$1" in
remove|upgrade|deconfigure)
echo "Stopping Jellyfin!"
# try graceful termination;
if [[ -d /run/systemd/system ]]; then
deb-systemd-invoke stop ${NAME}.service > /dev/null 2>&1 || true
elif [ -x "/etc/init.d/${NAME}" ] || [ -e "/etc/init/${NAME}.conf" ]; then
invoke-rc.d ${NAME} stop > /dev/null 2>&1 || true
fi
# Ensure that it is shutdown
PIDFILE=$(find /var/run/ -maxdepth 1 -mindepth 1 -name "jellyfin*.pid" -print -quit)
[[ -n "$PIDFILE" ]] && [[ -s "$PIDFILE" ]] && JELLYFIN_PID=$(cat ${PIDFILE})
# if its running, let's stop it
if [[ -n "$JELLYFIN_PID" ]]; then
# if jellyfin is still running, kill it
if [[ -n "$(ps -p $JELLYFIN_PID -o pid=)" ]]; then
CPIDS=$(pgrep -P $JELLYFIN_PID)
sleep 2 && kill -KILL $CPIDS
kill -TERM $CPIDS > /dev/null 2>&1
fi
sleep 1
# if it's still running, show error
if [[ -n "$(ps -p $JELLYFIN_PID -o pid=)" ]]; then
echo "Could not successfully stop EmbyServer, please do so before uninstalling."
exit 1
else
[[ -f $PIDFILE ]] && rm $PIDFILE
fi
fi
if [[ -f /usr/lib/jellyfin/bin/MediaBrowser.Server.Mono.exe.so ]]; then
rm /usr/lib/jellyfin/bin/MediaBrowser.Server.Mono.exe.so
fi
;;
failed-upgrade)
;;
*)
echo "prerm called with unknown argument \`$1'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0