webcit_before_automake is now the trunk
[citadel.git] / webcit / debian / citadel-webcit-apache.postinst
1 #! /bin/sh
2 # postinst.skeleton
3 # Skeleton maintainer script showing all the possible cases.
4 # Written by Charles Briscoe-Smith, March-June 1998.  Public Domain.
5
6 # Abort if any command returns an error value
7 set -e
8 . /usr/share/debconf/confmodule
9
10
11 uninclude() {
12         if [ ! -a /etc/$server/conf.d/webcit     ]; then
13                 if [ -f /etc/$server/httpd.conf \
14                         -a -f /usr/share/wwwconfig-common/apache-uninclude_all.sh ]
15                 then
16                         includefile=$1
17                         . /usr/share/wwwconfig-common/apache-uninclude_all.sh
18                 fi
19         fi
20 }
21
22
23 case "$1" in
24   configure)
25     # Configure this package.  If the package must prompt the user for
26     # information, do it here.
27                 . /usr/share/debconf/confmodule
28                 db_version 2.0
29                 db_get "citadel/baseurl" && baseurl="$RET"
30                 if echo "$baseurl"|grep -q "http"; then
31                         if echo "$baseurl"|grep -q "https"; then
32                                 HOSTNAME=    ServerName `echo "$baseurl" |sed "s;https://\(.*\)/.*;\1;"`
33                                 BASEURL=`echo "$baseurl" |sed "s;http://.*\..*/.*;\1;"`
34                         else
35                                 HOSTNAME=    ServerName `echo "$baseurl" |sed "s;https://\(.*\)/.*;\1;"`
36                                 BASEURL=`echo "$baseurl" |sed "s;https://.*\..*/.*;\1;"`
37                         fi
38                 else
39                         HOSTNAME="ServerName *"
40                         BASEURL="$baseurl"
41                 fi
42                 echo "
43 <VirtualHost *>
44 ${SERVERNAME}
45         DocumentRoot /var/www/
46 #    ProxyPass /dotskip http://127.0.0.1:2000/dotskip
47 #    ProxyPassReverse /dotskip http://127.0.0.1:2000/dotskip
48     ProxyPass /webcit/ http://127.0.0.1:2000/
49     ProxyPassReverse /webcit/ http://127.0.0.1:2000/
50     ProxyPass /listsub/ http://127.0.0.1:2000/listsub/
51     ProxyPassReverse /listsub/ http://127.0.0.1:2000/listsub/
52     ProxyPass /groupdav/ http://127.0.0.1:2000/groupdav/
53     ProxyPassReverse /groupdav/ http://127.0.0.1:2000/groupdav/
54 </VirtualHost>
55 " >/tmp/apache.conf
56         ucf /tmp/apache.conf /etc/citadel/apache.conf
57                 db_get "citadel/webserver" && webserver="$RET"
58                 case "$webserver" in
59                         Apache)         webservers="apache";;
60                         Apache-SSL)     webservers="apache-ssl";;
61                         Apache-Perl)    webservers="apache-perl";;
62                         Apache2)                
63                                 webservers="apache2"
64                                 a2enmod proxy
65                                 ;;
66                         
67                         *)                              webservers="";;
68                 esac
69                 
70                 
71                 
72                 for server in $webservers; do
73                         test -d /etc/$server || continue
74                         
75                         if [ -n "$2" ]; then
76                                 uninclude 
77                         fi
78                         
79                         if [ ! -e /etc/$server/conf.d/webcit ]
80                                 then
81                                 ln -s /etc/citadel/apache.conf /etc/$server/conf.d/webcit
82                         fi
83                         restart=$server
84                         servers=$webservers
85                         . /usr/share/wwwconfig-common/restart.sh
86                 done
87
88                 ;;
89
90         abort-upgrade|abort-remove|abort-deconfigure)
91
92         ;;
93
94         *)
95                 echo "postinst called with unknown argument \`$1'" >&2
96                 exit 1
97         ;;
98 esac
99
100 exit 0