Enable php 7.3.
[apache2-cn.git] / debian / postrm
1 #!/bin/sh
2
3 set -e
4
5 # Debconf
6 . /usr/share/debconf/confmodule
7
8 case "$1" in
9   purge)
10     # continue below
11     ;;
12   *)
13     exit 0
14     ;;
15 esac
16
17 CONFDIR="/etc/apache2"
18 HOST=$(hostname -f)
19 DOMAIN=$(hostname -d)
20
21 # purge_conf()
22 #
23 #   Purge Apache2 configuration files located in specified directory.
24 #
25 purge_conf () {
26   local ctype dir file
27
28   ctype="$1"
29   dir="$2"
30
31   case "$ctype" in
32     site|conf)
33       # continue below
34       ;;
35     *)
36       return 1
37       ;;
38   esac
39
40   if [ -d "${dir}" ] && [ -n "$(ls -A ${dir}/)" ]; then
41     for file in ${dir}/*.conf; do
42       if [ -f "$file" ]; then
43         if egrep -q "^## Begin - Generated by CARNet package apache2-cn$" "$file"; then
44           a2dis$ctype -p -f -q "`basename "$file" .conf`" || exit $?
45           rm -f "$file"
46         fi
47       fi
48     done
49   fi
50 }
51
52 # Configuration generated by this CARNet package.
53 echo "CN: Purging $PKG configuration for Apache2."
54 purge_conf site ${CONFDIR}/sites-available
55 purge_conf conf ${CONFDIR}/conf-available
56
57 # Remove default DocumentRoot if there's only a one line index.html there
58 docroots="/var/www/$HOST /var/www/www.$DOMAIN"
59
60 if [ -d "/var/www" ]; then
61   for docroot in $docroots; do
62     if [ -d $docroot ]; then
63       if [ "x$(echo ${docroot}/*)" = "x${docroot}/index.html" ]; then
64         if [ "$(wc -l ${docroot}/index.html | awk '{print $1}')" -eq 1 ]; then
65           echo "CN: Removing document root directory ${docroot}."
66           rm -f $docroot/index.html
67           rmdir $docroot || true
68         fi
69       fi
70     fi
71   done
72 fi
73
74 #DEBHELPER#
75
76 exit 0