diff options
| author | Joshua Boniface <joshua@boniface.me> | 2018-08-08 01:18:59 -0400 |
|---|---|---|
| committer | Vasily <just.one.man@yandex.ru> | 2018-10-22 01:56:13 +0300 |
| commit | c0953e51b5019c968fe5d9c8f25f47f08ed4e829 (patch) | |
| tree | bd8a44c47c18050550e17a2ffd1dd9bed56e5d88 /debian/prerm | |
| parent | 48facb797ed912e4ea6b04b17d1ff190ac2daac4 (diff) | |
Add patches and debian build information for emby-server
Diffstat (limited to 'debian/prerm')
| -rw-r--r-- | debian/prerm | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/debian/prerm b/debian/prerm new file mode 100644 index 000000000..341df6cd0 --- /dev/null +++ b/debian/prerm @@ -0,0 +1,64 @@ +#!/bin/bash +set -e + +NAME=emby-server +CONF_FILE=/etc/${NAME}.conf +DEFAULT_FILE=/etc/default/${NAME} + +# Source Emby server default configuration +if [[ -f $DEFAULT_FILE ]]; then + . $DEFAULT_FILE +fi + +# Source Emby server user configuration overrides +if [[ -f $CONF_FILE ]]; then + . $CONF_FILE +fi + +# Data directory where Emby database, cache and logs are stored +PROGRAMDATA=${EMBY_DATA-/var/lib/$NAME} + +case "$1" in + remove|upgrade|deconfigure) + echo "Stopping Emby Server!" + # 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 "emby*.pid" -print -quit) + [[ -n "$PIDFILE" ]] && [[ -s "$PIDFILE" ]] && EMBY_PID=$(cat ${PIDFILE}) + # if its running, let's stop it + if [[ -n "$EMBY_PID" ]]; then + # if emby is still running, kill it + if [[ -n "$(ps -p $EMBY_PID -o pid=)" ]]; then + CPIDS=$(pgrep -P $EMBY_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 $EMBY_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/emby-server/bin/MediaBrowser.Server.Mono.exe.so ]]; then + rm /usr/lib/emby-server/bin/MediaBrowser.Server.Mono.exe.so + fi + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 |
