| 1 |
#!/bin/sh |
| 2 |
# postrm script for fex |
| 3 |
# |
| 4 |
# see: dh_installdeb(1) |
| 5 |
|
| 6 |
set -e |
| 7 |
|
| 8 |
. /usr/share/debconf/confmodule |
| 9 |
|
| 10 |
# summary of how this script can be called: |
| 11 |
# * <postrm> `remove' |
| 12 |
# * <postrm> `purge' |
| 13 |
# * <old-postrm> `upgrade' <new-version> |
| 14 |
# * <new-postrm> `failed-upgrade' <old-version> |
| 15 |
# * <new-postrm> `abort-install' |
| 16 |
# * <new-postrm> `abort-install' <old-version> |
| 17 |
# * <new-postrm> `abort-upgrade' <old-version> |
| 18 |
# * <disappearer's-postrm> `disappear' <overwriter> |
| 19 |
# <overwriter-version> |
| 20 |
# for details, see http://www.debian.org/doc/debian-policy/ or |
| 21 |
# the debian-policy package |
| 22 |
|
| 23 |
|
| 24 |
case "$1" in |
| 25 |
purge) |
| 26 |
if [ -d /etc/xinetd.d ];then |
| 27 |
if [ -x /usr/bin/ucf ];then |
| 28 |
ucf --debconf-ok --purge /etc/xinetd.d/fex |
| 29 |
fi |
| 30 |
rm -f /etc/xinetd.d/fex |
| 31 |
remainingdpkg=`ls -1 /etc/xinetd.d/fex.*-* 2>/dev/null|xargs --no-run-if-empty -n 1 basename||true` |
| 32 |
if [ ! -z "$remainingdpkg" ];then |
| 33 |
echo "DPKG-templates for F*EX service in xinetd not removed:" |
| 34 |
echo "${remainingdpkg}" |
| 35 |
echo "Please remove yourself if no longer required." |
| 36 |
fi |
| 37 |
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` |
| 38 |
if [ ! -z "$remainingsrv" ];then |
| 39 |
echo "User-defined services in xinetd not removed:" |
| 40 |
echo "${remainingsrv}" |
| 41 |
echo "Please remove yourself!" |
| 42 |
fi |
| 43 |
if [ -x /etc/init.d/xinetd ]; then |
| 44 |
if [ -x /usr/sbin/invoke-rc.d ]; then |
| 45 |
invoke-rc.d xinetd reload || true |
| 46 |
else |
| 47 |
/etc/init.d/xinetd reload |
| 48 |
fi |
| 49 |
else |
| 50 |
# xinetd is already purged |
| 51 |
[ -d /etc/xinetd.d ]&&rmdir --ignore-fail-on-non-empty /etc/xinetd.d |
| 52 |
[ -d /etc/xinetd.d ]&&echo 1>&2 "Cannot remove /etc/xinetd.d/ even though xinetd is no longer installed due to customized services" |
| 53 |
fi |
| 54 |
elif [ -r /etc/inetd.conf ];then |
| 55 |
# We're running openbsd-inetd or something similar |
| 56 |
fextcpport=`grep /usr/share/fex/bin/fexsrv /etc/inetd.conf 2>/dev/null|awk '{print $1}'||true` |
| 57 |
if [ ! -z "$fextcpport" -a -x /usr/sbin/update-inetd ];then |
| 58 |
# as --multi is ugly we'll only support v4 through inetd.conf |
| 59 |
# whoever wants IPv6 needs to go xinetd or hack his own version |
| 60 |
# i.e. replace tcp with tcp6 |
| 61 |
echo "$fextcpport"|while read fexport;do |
| 62 |
update-inetd --remove $fexport |
| 63 |
done |
| 64 |
else |
| 65 |
echo 'Unable to automatically update inetd.conf' |
| 66 |
echo 'Please update yourself and restart inetd' |
| 67 |
fi |
| 68 |
fi |
| 69 |
echo 'Cleaning up files...' |
| 70 |
rm -rf /etc/fex/ |
| 71 |
rm -rf /var/lib/fex/ |
| 72 |
rm -rf /var/log/fex/ |
| 73 |
rm -rf /var/spool/fex/ |
| 74 |
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 |
| 75 |
dpkg-statoverride --list ${file} >/dev/null && dpkg-statoverride --remove ${file} |
| 76 |
done |
| 77 |
# cleanup user's files (like .bash_history et al.) |
| 78 |
find /usr/share/fex/ -maxdepth 1 -type f 2>/dev/null|xargs --no-run-if-empty rm -f |
| 79 |
if [ -f /etc/aliases -o -L /etc/aliases ]; then |
| 80 |
if grep -qi "^\s*fex\s*:" /etc/aliases; then |
| 81 |
echo "Removing email alias for fex in /etc/aliases ..." |
| 82 |
sed -i -e '/^\s*fex\s*:/d' /etc/aliases |
| 83 |
# run newaliases for e.g. postfix |
| 84 |
newal=`which newaliases || true` |
| 85 |
if [ -n "$newal" ] && [ -x "$newal" ]; then |
| 86 |
$newal || true |
| 87 |
fi |
| 88 |
fi |
| 89 |
fi |
| 90 |
# make sure to run this once fexsrv is shut down or we get a "user is logged in error" |
| 91 |
if [ -x "$(command -v deluser)" ]; then |
| 92 |
echo "Removing fex user account" |
| 93 |
deluser --quiet --system fex > /dev/null || true |
| 94 |
elif [ -x "$(command -v userdel)" ];then |
| 95 |
echo "Removing fex user account" |
| 96 |
userdel fex||true |
| 97 |
else |
| 98 |
echo >&2 "not removing fex system account because deluser command was not found" |
| 99 |
fi |
| 100 |
# Remove my changes to the db. |
| 101 |
db_purge |
| 102 |
;; |
| 103 |
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) |
| 104 |
;; |
| 105 |
*) |
| 106 |
echo "postrm called with unknown argument \`$1'" >&2 |
| 107 |
exit 1 |
| 108 |
;; |
| 109 |
esac |
| 110 |
|
| 111 |
# dh_installdeb will replace this with shell code automatically |
| 112 |
# generated by other debhelper scripts. |
| 113 |
|
| 114 |
#DEBHELPER# |
| 115 |
|
| 116 |
exit 0 |
| 117 |
|
| 118 |
# vi: set smartindent ts=4 sw=4 expandtab autoindent sts=4: |