summaryrefslogtreecommitdiff
path: root/debian/taler-merchant.postrm
blob: 0f7a8baad76f9cc9aa809cfbbed0f6cb598fb3ba (plain)
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
#!/bin/sh

set -e

pathfind() {
	OLDIFS="$IFS"
	IFS=:
	for p in $PATH; do
		if [ -x "$p/$*" ]; then
			IFS="$OLDIFS"
			return 0
		fi
	done
	IFS="$OLDIFS"
	return 1
}

apache_remove() {
    if [ diff /etc/taler-merchant/apache.conf /etc/apache2/conf-available/taler-merchant.conf >/dev/null 2>&1 ];
    then
	    rm -f /etc/apache2/conf-available/taler-merchant.conf
    fi
}

nginx_remove() {
    if [ diff /etc/taler-exchange/nginx.conf /etc/apache2/conf-available/taler-exchange.conf >/dev/null 2>&1 ];
    then
	    rm -f /etc/nginx/conf-available/taler-merchant.conf
    fi
}

if [ -f /usr/share/debconf/confmodule ]; then
    . /usr/share/debconf/confmodule
fi

if [ -f /usr/share/dbconfig-common/dpkg/postrm.pgsql ]; then
    . /usr/share/dbconfig-common/dpkg/postrm.pgsql
    dbc_go taler-merchant "$@"
fi


if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
	if [ -f /usr/share/debconf/confmodule ]; then
		. /usr/share/debconf/confmodule
		db_version 2.0
		db_get taler-merchant/reconfigure-webserver
		webservers="$RET"
		for webserver in $webservers; do
			webserver=${webserver%,}
			if [ "$webserver" = "nginx" ] ; then
				nginx_remove
			else
				apache_remove
			fi
		done
	fi
fi

case "${1}" in
	purge)
    rm -f /var/lib/taler-merchant/master-api-key.txt
    rmdir /var/lib/taler-merchant/httpd/
  	if [ -e /usr/share/debconf/confmodule ]
		then
			. /usr/share/debconf/confmodule
			db_version 2.0

			db_get taler-merchant/username
			_USERNAME="${RET:-taler-merchant-httpd}"

			db_get taler-merchant/groupname
			_GROUPNAME="${RET:-taler-merchant-httpd}"
		else
			_USERNAME="taler-merchant-httpd"
			_GROUPNAME="taler-merchant-httpd"
		fi

		if pathfind deluser
		then
			deluser --quiet --system ${_USERNAME} || true
		fi

		if pathfind delgroup
		then
			delgroup --quiet --system --only-if-empty ${_GROUPNAME} || true
		fi
        ;;
    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
		;;

	*)
		echo "postrm called with unknown argument \`${1}'" >&2
		exit 1
		;;
esac

#DEBHELPER#

exit 0