updated on Sun Jan 22 16:00:49 UTC 2012
[aur-mirror.git] / sabnzbd / sabnzbd.install
blob14eb3d4092c28c55ca4eed4a8ba6332e3515ed38
1 ## arg 1:  the new package version
2 post_install() {
3   . /etc/conf.d/sabnzbd
5   # add x-nzb mimetype
6   xdg-mime install --mode system "${SABNZBD_DIR}/x-nzb.xml"
7   xdg-icon-resource install --context mimetypes --size 64 "${SABNZBD_DIR}/nzb-2.png" application-x-nzb
9   post_upgrade
11   cat << "EOM"
12 ==> Don't forget to edit /etc/conf.d/sabnzbd!
13 ==> Add your Session key and if necessary your username and password to ensure a proper shutdown.
14 ==> If you want to associate .nzb-files with SABnzbd, run 'xdg-mime default sabnzbd.desktop applications/x-nzb'
15 EOM
18 ## arg 1:  the new package version
19 ## arg 2:  the old package version
20 pre_upgrade() {
21   PID="$(pgrep -f SABnzbd.py)"
22   if [ -f /run/daemons/sabnzbd ]; then
23     /etc/rc.d/sabnzbd stop # kill the daemon
24   fi
25   if [ -n "${PID}" ];then
26     kill "${PID}"          # kill the daemon finaly
27   fi
29 #remove with 0.7.x release {{{
30  grep -q "SABNZBD_GROUP" /etc/conf.d/sabnzbd || \
31   echo 'SABNZBD_GROUP="sabnzbd"' >> /etc/conf.d/sabnzbd
32  grep -q "SABNZBD_DIR" /etc/conf.d/sabnzbd || \
33   echo 'SABNZBD_DIR="/opt/sabnzbd"' >> /etc/conf.d/sabnzbd
34 #}}}
37 ## arg 1:  the new package version
38 ## arg 2:  the old package version
39 post_upgrade() {
40   . /etc/conf.d/sabnzbd
42   if [ "${USE_SYSTEM_IDS}" == "1" ]; then
43     if grep -q "^sabnzbd:" /etc/group &> /dev/null; then
44       if grep -q "^SABNZBD_GID=" /etc/conf.d/sabnzbd &> /dev/null; then
45         groupmod -g "${SABNZBD_GID}" -n sabnzbd sabnzbd &> /dev/null
46       else
47         groupmod -r -n sabnzbd sabnzbd &> /dev/null
48       fi
49     else
50       if grep -q "^SABNZBD_GID=" /etc/conf.d/sabnzbd &> /dev/null; then
51         groupadd -g "${SABNZBD_GID}" sabnzbd &> /dev/null
52       else
53         groupadd -r sabnzbd &> /dev/null
54       fi
55     fi
57     if grep -q "^SABNZBD_AGROUP=" /etc/conf.d/sabnzbd &> /dev/null; then
58       SABNZBD_GS="-G ${SABNZBD_AGROUP}"
59     else
60       SABNZBD_GS=""
61     fi
63     if grep -q "^sabnzbd:" /etc/passwd 2> /dev/null; then
64       if grep -q "^SABNZBD_UID=" /etc/conf.d/sabnzbd &> /dev/null; then
65         usermod -s /sbin/nologin -c "SABnzbd user" -d "${SABNZBD_DIR}" \
66           -u "${SABNZBD_UID}" -g sabnzbd ${SABNZBD_GS} sabnzbd &> /dev/null
67       else
68         usermod -s /sbin/nologin -c "SABnzbd user" -d "${SABNZBD_DIR}" \
69           -g sabnzbd ${SABNZBD_GS} -r sabnzbd &> /dev/null
70       fi
71     else
72       if grep -q "^SABNZBD_UID=" /etc/conf.d/sabnzbd &> /dev/null; then
73         useradd -s /sbin/nologin -c "SABnzbd user" -d "${SABNZBD_DIR}" \
74           -u ${SABNZBD_UID} -g sabnzbd "${SABNZBD_GS}" -r sabnzbd &> /dev/null
75       else
76         useradd -s /sbin/nologin -c "SABnzbd user" -d "${SABNZBD_DIR}" \
77           -g sabnzbd ${SABNZBD_GS} -r sabnzbd &> /dev/null
78       fi
79     fi
80   fi
82   chown -R "${SABNZBD_USER}:${SABNZBD_GROUP}" "${SABNZBD_DIR}"
85 ## arg 1:  the old package version
86 pre_remove() {
87   . /etc/conf.d/sabnzbd
89   pre_upgrade
91   xdg-mime uninstall --mode system "${SABNZBD_DIR}/x-nzb.xml"
92   xdg-icon-resource uninstall --context mimetypes --size 64 application-x-nzb
95 ## arg 1:  the old package version
96 post_remove() {
97   userdel sabnzbd &> /dev/null
98   groupdel sabnzbd &> /dev/null || /bin/true
99   echo "==> There may be some files left in /opt/sabnzbd."
102 # vim:set ts=2 sw=2 et: