File: fex.postrm

package info (click to toggle)
fex 20160919-2
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,944 kB
  • sloc: perl: 17,699; sh: 346; makefile: 67
file content (117 lines) | stat: -rw-r--r-- 4,578 bytes parent folder | download | duplicates (3)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/sh
# postrm script for fex
#
# see: dh_installdeb(1)

set -e

. /usr/share/debconf/confmodule

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <overwriter>
#          <overwriter-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    purge)
    rm -rf /etc/fex/
    rm -rf /var/lib/fex/
    rm -rf /var/log/fex/
    rm -rf /var/spool/fex/
    for file in /etc/fex/fex.ph /etc/fex/fup.pl /usr/bin/fac /usr/share/fex/bin/fex_cleanup /usr/bin/fac /usr/share/fex/bin/logwatch /usr/bin/fac /usr/share/fex/bin/fexwall;do
        dpkg-statoverride --list ${file} >/dev/null && dpkg-statoverride --remove ${file}
    done
    # cleanup user's files (like .bash_history et al.)
    find /usr/share/fex/ -maxdepth 1 -type f  2>/dev/null|xargs --no-run-if-empty rm -f
    if [ -d /etc/xinetd.d ];then
        if [ -x /usr/bin/ucf ];then
            ucf --debconf-ok --purge /etc/xinetd.d/fex
        fi
        rm -f /etc/xinetd.d/fex
        remainingdpkg=`ls -1 /etc/xinetd.d/fex.*-* 2>/dev/null|xargs --no-run-if-empty -n 1 basename||true`
        if [ ! -z "$remainingdpkg" ];then
            echo "DPKG-templates for F*EX service in xinetd not removed:"
            echo "${remainingdpkg}"
            echo "Please remove yourself if no longer required."
        fi
        remainingsrv=`grep -r /usr/share/fex/bin/fexsrv /etc/xinetd.d|grep -v '^/etc/xinetd.d/fex:'|sed -e 's#^/etc/xinetd.d/\([^:]\+\):.*#\1#'|grep -v 'fex.*-*'||true`
        if [ ! -z "$remainingsrv" ];then
            echo "User-defined services in xinetd not removed:"
            echo "${remainingsrv}"
            echo "Please remove yourself!"
        fi
        if [ -x /etc/init.d/xinetd ]; then
            if [ -x /usr/sbin/invoke-rc.d ]; then
                invoke-rc.d xinetd reload || true
            else
                /etc/init.d/xinetd reload
            fi
        else
            # xinetd is already purged
            [ -d /etc/xinetd.d/ ]&&rmdir --ignore-fail-on-non-empty /etc/xinetd.d/
            [ -d /etc/xinetd.d/ ]&&echo 1>&2 "Cannot remove /etc/xinetd.d/ even though xinetd is no longer installed due to customized services"
        fi
    elif [ -r /etc/inetd.conf ];then
        # We're running openbsd-inetd or something similar
        fextcpport=`grep /usr/share/fex/bin/fexsrv /etc/inetd.conf 2>/dev/null|awk '{print $1}'||true`
        if [ ! -z "$fextcpport" -a -x /usr/sbin/update-inetd ];then
            # as --multi is ugly we'll only support v4 through inetd.conf
            # whoever wants IPv6 needs to go xinetd or hack his own version
            # i.e. replace tcp with tcp6
            echo "$fextcpport"|while read fexport;do
            update-inetd --remove $fexport
            done
        else
            echo 'Unable to automatically update inetd.conf'
            echo 'Please update yourself and restart inetd'
        fi
    fi
    if [ -f /etc/aliases -o -L /etc/aliases ]; then
        if grep -qi "^\s*fex\s*:" /etc/aliases; then
            echo "Removing email alias for fex in /etc/aliases ..."
            sed -i -e '/^\s*fex\s*:/d' /etc/aliases
            # run newaliases for e.g. postfix
            newal=`which newaliases || true`
            if [ -n "$newal" ] && [ -x "$newal" ]; then
                $newal || true
            fi
        fi
    fi
    # make sure to run this once fexsrv is shut down or we get a "user is logged in error"
    if [ -x "$(command -v deluser)" ]; then
        echo "Removing fex user account"
        deluser --quiet --system fex > /dev/null || true
    elif [ -x "$(command -v userdel)" ];then
        echo "Removing fex user account"
        userdel fex||true
    else
        echo >&2 "not removing fex system account because deluser command was not found"
    fi
    # Remove my changes to the db.
    db_purge
    ;;
    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
    ;;
    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

# vi: set smartindent ts=4 sw=4 expandtab autoindent sts=4: