File: postrm

package info (click to toggle)
amavis-stats 0.1.12-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 380 kB
  • ctags: 142
  • sloc: sh: 2,861; perl: 508; php: 473; makefile: 207
file content (78 lines) | stat: -rw-r--r-- 2,107 bytes parent folder | download
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
#!/bin/sh
# postrm script for netsaint
#
# see: dh_installdeb(1)

set -e

# Source debconf library.
. /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' <r>overwrit>r> <new-version>
# for details, see /usr/doc/packaging-manual/

configapache () {
    for apache in $webservers; do
	conf=httpd.conf

	if [ -f "/etc/$apache/$conf" ] ; then
	    # Remove from httpd.conf (current method)
	    perl -pe 's/Include \/etc\/amavis-stats\/apache.conf//s;' \
		< /etc/$apache/$conf > /etc/$apache/$conf-dpkg.amavis-stats
	    mv /etc/$apache/$conf-dpkg.amavis-stats /etc/$apache/$conf
	fi
    done

    if /bin/ps ax | grep -v grep | grep -q $apache; then
	if [ -x "/etc/init.d/$apache" ]; then
	    set +e ; invoke-rc.d $apache  reload ; set -e
	fi
    fi
}

case "$1" in
    remove|abort-install|abort-upgrade|failed-upgrade|disappear)
    	# Remove apache config if wanted.
	db_get amavis-stats/config_apache
    	webserver="$RET"
    	case "$webserver" in
    		Apache)        webservers="apache";;
    		Apache-SSL)    webservers="apache-ssl";;
	        Apache2)       webservers="apache2";;
    		Both)          webservers="apache apache-ssl";;
    		*)             webservers="";;
    	esac

   	if [ ! -z "$webservers" ]; then
    		configapache
    	fi
        ;;
    purge)
	dpkg-statoverride --remove /var/lib/amavis-stats
	dpkg-statoverride --remove /var/cache/amavis-stats

    	db_get amavis-stats/stay_on_purge
    	if [ "$RET" = "true" ]; then
			rm -rf /var/lib/amavis-stats
    			rm -rf /var/cache/amavis-stats
    	fi

	getent passwd amavis-stats >/dev/null && deluser amavis-stats
    	db_purge
    	;;	
    upgrade)
	;;
    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 0
esac

exit 0