Prva inacica paketa za Debian wheezy distribuciju.
[apache2-cn.git] / debian / postrm
1 #!/bin/sh
2
3 set -e
4
5 # Debconf
6 . /usr/share/debconf/confmodule
7
8 # Include CARNet functions.
9 . /usr/share/carnet-tools/functions.sh
10
11 CONFDIR="/etc/apache2"
12 sitesdir=${CONFDIR}/sites-available
13 HOST=$(hostname -f)
14 DOMAIN=$(hostname -d)
15 sitefiles=
16
17
18 case "$1" in
19     purge)
20         # continue below
21         ;;
22     *)
23         exit 0
24         ;;
25 esac
26
27 # Get CARNet config files in /etc/apache2/sites-available directory.
28 if [ -d "${sitesdir}" ] && [ -n "$(ls ${sitesdir}/)" ]; then
29     for file in ${sitesdir}/*; do
30         if [ -f "$file" ]; then
31             if egrep -q "^## Begin - Generated by CARNet package apache2-cn$" $file; then
32                 site=`echo "$file" | sed 's/^\/.*\///'`
33                 sitefiles="$sitefiles $site"
34             fi
35         fi
36     done
37 fi
38
39 # Remove our vhosts.
40 if [ -n "$sitefiles" ]; then
41     for site in $sitefiles; do
42         if [ -e "$sitesdir/$site" ]; then
43             cp_echo "CN: Removing $site site configuration file."
44             rm -f $sitesdir/$site
45         fi
46     done
47 fi
48
49 # Remove default DocumentRoot if there's only a one line index.html there
50 docroots="/var/www/$HOST /var/www/www.$DOMAIN"
51
52 if [ -d "/var/www" ]; then
53     for docroot in $docroots; do
54         if [ -d $docroot ]; then
55             if [ "x$(echo ${docroot}/*)" = "x${docroot}/index.html" ]; then
56                 if [ "$(wc -l ${docroot}/index.html | awk '{print $1}')" -eq 1 ]; then
57                     cp_echo "CN: Removing document root directory ${docroot}."
58                     rm -f $docroot/index.html
59                     rmdir $docroot || true
60                 fi
61             fi
62         fi
63     done
64 fi
65
66 # Remove CARNet specific configuration.
67 if [ -d "${CONFDIR}/conf.d" ] && [ -n "$(ls ${CONFDIR}/conf.d/)" ]; then
68     cp_echo "CN: Disabling CARNet specific configuration."
69     for file in ${CONFDIR}/conf.d/*; do
70         if [ -f "$file" ]; then
71             if egrep -q "^## Begin - Generated by CARNet package apache2-cn$" $file; then
72                 rm -f $file
73             fi
74         fi
75     done
76 fi
77
78 # dh_installdeb will replace this with shell code automatically
79 # generated by other debhelper scripts.
80
81 #DEBHELPER#
82
83 # Mail root
84 cp_mail "apache2-cn"
85
86 exit 0