aboutsummaryrefslogtreecommitdiff
path: root/sysutils/dtc/files/dtc-deinstall.in
blob: 6929330f665c61125256be0a7ee4592f8bf7765c (plain) (blame)
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
#!/bin/sh

# Tarball uninstall sh script for DTC
# Written by Thomas GOIRAND <thomas@goirand.fr>
# under LGPL Licence

UNIX_TYPE=freebsd

PREFIX=%%PREFIX%%
LOCALBASE=%%LOCALBASE%%
QMAIL_PREFIX=%%QMAIL_PREFIX%%

echo "### DEAMON PATH CONFIGURATION ###"
PATH_HTTPD_CONF="${LOCALBASE}/etc/apache/httpd.conf"
PATH_NAMED_CONF="/etc/namedb/named.conf"
PATH_PROFTPD_CONF="${LOCALBASE}/etc/proftpd.conf"
PATH_QMAIL_CTRL="${QMAIL_PREFIX}/control"

# Multi OS (Unix system) uninstall sh script for DTC
# Written by Thomas GOIRAND <thomas@goirand.fr>
# under LGPL Licence

# The configuration for all thoses variables must be written BEFORE this
# script. Do the start of the script for your operating system.
# I did mine for debian in debian/postinst

# Please note this script
# doeas not start with a :

#!/bin/sh

# because it's up to you to write it ! :)
# Do a "cat uninstall_deamons.sh >> your_OS_vars_setup_script.sh"

#
# uninstall named.conf
#

if grep "Configured by DTC" $PATH_NAMED_CONF
then
	echo "===> Uninstalling inclusion from named.conf"
	grep -v "Configured by DTC" $PATH_NAMED_CONF >/tmp/dtc_uninstall.named.conf
	grep -v "include \"$PATH_DTC_ETC/named.conf\"" /tmp/dtc_uninstall.named.conf >/tmp/dtc_uninstall2.named.conf
	cp -f $PATH_NAMED_CONF $PATH_NAMED_CONF.DTC.removed
	mv /tmp/dtc_uninstall2.named.conf $PATH_NAMED_CONF
	rm -f /tmp/dtc_uninstall.named.conf
fi

#
# uninstall httpd.conf
#
if grep "Configured by DTC" $PATH_HTTPD_CONF
then
	echo "===> Uninstalling inclusion from httpd.conf"
	if grep "Configured by DTC v0.10" $PATH_HTTPD_CONF >/dev/null 2>&1
	then
		grep -v "Configured by DTC" $PATH_HTTPD_CONF | grep -v "Include $PATH_DTC_ETC/vhosts.conf" >/tmp/dtc_uninstall.httpd.conf
		cp -f $PATH_HTTPD_CONF $PATH_HTTPD_CONF.DTC.removed
		mv /tmp/dtc_uninstall.httpd.conf $PATH_HTTPD_CONF
	else
		start_line=`grep -n "Configured by DTC" $PATH_HTTPD_CONF | cut -d":" -f1`
		end_line=`grep -n "End of DTC configuration" $PATH_HTTPD_CONF| cut -d":" -f1`
		nbr_line=`cat $PATH_HTTPD_CONF | wc -l`
		cat $PATH_HTTPD_CONF | head -n $(($start_line - 1 )) >/tmp/DTC_uninstall.httpd.conf
		cat $PATH_HTTPD_CONF | tail -n $(($nbr_line - $end_line )) >>/tmp/DTC_uninstall.httpd.conf
		cat </tmp/DTC_uninstall.httpd.conf >$PATH_HTTPD_CONF
	fi
fi

#
# uninstall proftpd.conf
#

echo "===> Uninstalling inclusion from proftpd.conf"
if grep "Configured by DTC" $PATH_PROFTPD_CONF
then
	start_line=`grep -n "Configured by DTC" $PATH_PROFTPD_CONF | cut -d":" -f1`
	end_line=`grep -n "End of DTC configuration" $PATH_PROFTPD_CONF| cut -d":" -f1`
	nbr_line=`cat $PATH_PROFTPD_CONF | wc -l`
	cat $PATH_PROFTPD_CONF | head -n $(($start_line - 1 )) >/tmp/DTC_uninstall.profptd.conf
	cat $PATH_PROFTPD_CONF | tail -n $(($nbr_line - $end_line )) >>/tmp/DTC_uninstall.profptd.conf
	cp -f $PATH_PROFTPD_CONF $PATH_PROFTPD_CONF.DTC.removed
	mv /tmp/DTC_uninstall.profptd.conf $PATH_PROFTPD_CONF
fi

#
# Uninstall qmail
#

echo "===> Uninstalling from qmail"
#if ! [ -f $PATH_QMAIL_CTRL/rcpthosts.DTC.backup ] ; then
#	rm -f $PATH_QMAIL_CTRL/rcpthosts
#	mv -f $PATH_QMAIL_CTRL/rcpthosts.DTC.backup $PATH_QMAIL_CTRL/rcpthosts
#fi

if ! [ -f $PATH_QMAIL_CTRL/virtualdomains.DTC.backup ] ; then
	rm -f $PATH_QMAIL_CTRL/virtualdomains.DTC.backup
	mv -f $PATH_QMAIL_CTRL/virtualdomains.DTC.backup $PATH_QMAIL_CTRL/virtualdomains
fi

#if ! [ -f $PATH_QMAIL_CTRL/users/assign.DTC.backup ] ; then
#	rm -f $PATH_QMAIL_CTRL/users/assign.DTC.backup
#	mv -f $PATH_QMAIL_CTRL/users/assign.DTC.backup $PATH_QMAIL_CTRL/users/assign
#fi

if ! [ -f /etc/poppasswd.DTC.backup ] ; then
	rm -f /etc/poppasswd.DTC.backup
	mv -f/etc/poppasswd.DTC.backup /etc/poppasswd
fi