aboutsummaryrefslogtreecommitdiff
path: root/debian/postrm.jellyfin-server
blob: 3d56a5f1e896c89c702a2448a09a63422b76dc04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/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}

# 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
  purge)
    echo PURGE | debconf-communicate $NAME > /dev/null 2>&1 || true

    if [[ -x "/etc/init.d/jellyfin" ]] || [[ -e "/etc/init/jellyfin.conf" ]]; then
      update-rc.d jellyfin remove >/dev/null 2>&1 || true
    fi

    if [[ -x "/usr/bin/deb-systemd-helper" ]]; then
      deb-systemd-helper purge jellyfin.service >/dev/null
      deb-systemd-helper unmask jellyfin.service >/dev/null
    fi

    # Remove user and group
    userdel jellyfin > /dev/null 2>&1 || true
    delgroup --quiet jellyfin > /dev/null 2>&1 || true
    # Remove config dir
    if [[ -d $CONFIGDATA ]]; then
      rm -rf $CONFIGDATA
    fi
    # Remove log dir
    if [[ -d $LOGDATA ]]; then
      rm -rf $LOGDATA
    fi
    # Remove cache dir
    if [[ -d $CACHEDATA ]]; then
      rm -rf $CACHEDATA
    fi
    # Remove program data dir
    if [[ -d $PROGRAMDATA ]]; then
      rm -rf $PROGRAMDATA
    fi
    # Remove binary symlink
    rm -f /usr/bin/jellyfin
    # Remove sudoers config
    [[ -f /etc/sudoers.d/jellyfin-sudoers ]] && rm /etc/sudoers.d/jellyfin-sudoers
    # Remove anything at the default locations; catches situations where the user moved the defaults
    [[ -e /etc/jellyfin ]] && rm -rf /etc/jellyfin
    [[ -e /var/log/jellyfin ]] && rm -rf /var/log/jellyfin
    [[ -e /var/cache/jellyfin ]] && rm -rf /var/cache/jellyfin
    [[ -e /var/lib/jellyfin ]] && rm -rf /var/lib/jellyfin
    ;;
  remove)
    if [[ -x "/usr/bin/deb-systemd-helper" ]]; then
      deb-systemd-helper mask jellyfin.service >/dev/null
    fi
    ;;
  upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
    ;;
  *)
    echo "postrm called with unknown argument \`$1'" >&2
    exit 1
    ;;
esac

#DEBHELPER#

exit 0
bgstack15