File: postrm

package info (click to toggle)
ipplan 4.92a-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 7,256 kB
  • ctags: 11,121
  • sloc: php: 44,277; sh: 387; perl: 257; xml: 97; makefile: 57; sql: 32
file content (102 lines) | stat: -rw-r--r-- 2,578 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#! /bin/sh

set -e

if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
    for websvrs in apache2; do
	rm -f /etc/$websvrs/conf.d/ipplan
    done

    if [ -f /usr/share/debconf/confmodule ]; then
	. /usr/share/debconf/confmodule
	db_version 2.0 || [ $? -lt 30 ]

	db_get ipplan/reconfigure || true

	if [ "$1" = "purge" ]; then
	    db_get ipplan/mysql/configure

	    if [ "$RET" = true ]; then
		db_get ipplan/purge

		if [ "$RET" = true ]; then
		    db_get ipplan/mysql/dbserver
		    dbserver=$RET
		    db_get ipplan/mysql/dbadmin
		    dbadmin=$RET
		    db_input critical ipplan/mysql/dbadmpass || true
		    db_go || true

		    db_get ipplan/mysql/dbadmpass || true
		    dbadmpass=$RET

		    if [ -x /usr/share/wwwconfig-common/mysql-dropdb.sh ]; then
			# remove the database
			db_get ipplan/mysql/dbname
			dbname=$RET
			. /usr/share/wwwconfig-common/mysql-dropdb.sh || true
		    fi

		    if [ -x /usr/share/wwwconfig-common/mysql-dropuser.sh ]; then
			# remove user
			db_get ipplan/mysql/dbuser
			dbuser=$RET
			. /usr/share/wwwconfig-common/mysql-dropuser.sh || true
		    fi
		fi
	    fi
	fi

	db_get ipplan/webserver_type
	webservers="$RET"

	for webserver in $webservers; do
	    webserver=${webserver%,}

	    case "$webserver" in
		apache2)
		    test -x /usr/sbin/$webserver || continue
		    # Redirection of 3 is needed because Debconf uses it and it might
		    # be inherited by webserver. See bug #446324.
		    if [ -x /usr/sbin/invoke-rc.d ]; then
			invoke-rc.d $webserver reload 3>/dev/null || true
		    else
			/etc/init.d/$webserver reload 3>/dev/null || true
		    fi
		    ;;
	    esac
	done

	if [ "$1" = "purge" ]; then
		db_purge
	        for conffile in /etc/ipplan/db.php; do
			# we mimic dpkg as closely as possible, so we remove configuration
			# files with dpkg backup extensions too:
			for ext in '~' '%' .bak .dpkg-tmp .dpkg-new .dpkg-old .dpkg-dist .dpkg-bak .dpkg-del;  do
				rm -f $conffile$ext
			done
			# remove the configuration file itself
			rm -f $conffile
			# and finally clear it out from the ucf database
			if which ucf >/dev/null; then
				ucf --purge $conffile
			fi
			if which ucfr >/dev/null; then
				ucfr --purge ipplan $conffile
			fi
			rm /usr/share/ipplan/mconf/`basename $conffile`
		done
		if [ -f /etc/ipplan/local_conf.php ]; then
			rm /etc/ipplan/local_conf.php
		fi
		if [ -d /etc/ipplan ]; then
			rmdir --ignore-fail-on-non-empty /etc/ipplan || true
		fi
		if [ -d /var/spool/ipplan ]; then
			rmdir --ignore-fail-on-non-empty /var/spool/ipplan || true
		fi
	fi
    fi
fi

#DEBHELPER#