aboutsummaryrefslogtreecommitdiff
path: root/debian/prerm.jellyfin-server
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2024-02-03 16:08:56 -0500
committerJoshua M. Boniface <joshua@boniface.me>2024-02-03 16:09:29 -0500
commit9a2248e1d20ebc1826d246bf5bcb194e3499408e (patch)
tree87fbcfa2325e85797ad68d172208a4427aa470fb /debian/prerm.jellyfin-server
parentAdd submodule checkout tool (diff)
downloadjellyfin-packaging-9a2248e1d20ebc1826d246bf5bcb194e3499408e.tar.gz
jellyfin-packaging-9a2248e1d20ebc1826d246bf5bcb194e3499408e.tar.bz2
jellyfin-packaging-9a2248e1d20ebc1826d246bf5bcb194e3499408e.zip
Add combined Debian build
Diffstat (limited to 'debian/prerm.jellyfin-server')
-rw-r--r--debian/prerm.jellyfin-server61
1 files changed, 61 insertions, 0 deletions
diff --git a/debian/prerm.jellyfin-server b/debian/prerm.jellyfin-server
new file mode 100644
index 0000000..e965cb7
--- /dev/null
+++ b/debian/prerm.jellyfin-server
@@ -0,0 +1,61 @@
+#!/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_LOG_DIRECTORY-/var/log/$NAME}
+CACHEDATA=${JELLYFIN_CACHE_DIRECTORY-/var/cache/$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 Jellyfin, 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
bgstack15