mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-16 02:18:54 -07:00
177c4835a5
1. Add log and config flags to init and config 2. Move the existing logs and config dirs to the right places 3. Some cleanups in the control scripts 4. Prune the changelog of pre-Jellyfin entries
75 lines
2.2 KiB
Bash
75 lines
2.2 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
NAME=jellyfin
|
|
DEFAULT_FILE=/etc/default/${NAME}
|
|
|
|
# Source Jellyfin default configuration
|
|
if [[ -f $DEFAULT_FILE ]]; then
|
|
. $DEFAULT_FILE
|
|
fi
|
|
|
|
# Data directories for program data (cache, db), configs, and logs
|
|
PROGRAMDATA=${JELLYFIN_DATA_DIRECTORY-/var/lib/$NAME}
|
|
CONFIGDATA=${JELLYFIN_CONFIG_DIRECTORY-/etc/$NAME}
|
|
LOGDATA=${JELLYFIN_DATA_DIRECTORY-/var/log/$NAME}
|
|
|
|
# In case this system is running systemd, we make systemd reload the unit files
|
|
# to pick up changes.
|
|
if [[ -d /run/systemd/system ]] ; then
|
|
systemctl --system daemon-reload >/dev/null || true
|
|
fi
|
|
|
|
case "$1" in
|
|
install|upgrade)
|
|
# 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
|
|
# try and figure out if jellyfin is running
|
|
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
|
|
echo "Stopping Jellyfin!"
|
|
# 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 JellyfinServer, please do so before uninstalling."
|
|
exit 1
|
|
else
|
|
[[ -f $PIDFILE ]] && rm $PIDFILE
|
|
fi
|
|
fi
|
|
|
|
# Clean up old Emby cruft that can break the user's system
|
|
[[ -f /etc/sudoers.d/emby ]] && rm -f /etc/sudoers.d/emby
|
|
|
|
# If we have existing config or log dirs in /var/lib/jellyfin, move them into the right place
|
|
if [[ -d $PROGRAMDATA/config ]]; then
|
|
mv $PROGRAMDATA/config $CONFIGDATA
|
|
fi
|
|
if [[ -d $PROGRAMDATA/logs ]]; then
|
|
mv $PROGRAMDATA/logs $LOGDATA
|
|
fi
|
|
|
|
;;
|
|
abort-upgrade)
|
|
;;
|
|
*)
|
|
echo "preinst called with unknown argument \`$1'" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
#DEBHELPER#
|
|
|
|
exit 0
|