97bd8d90a5a2b39e22ed3e293d877c9e8180b58d
[tine20] / scripts / packaging / debian / tine20-webstack.postinst
1 #!/bin/sh
2 #
3 # Copyright 2012-2012 by Metaways Infosystems GmbH
4 #
5 # http://www.metaways.de/
6 #
7 # All rights reserved.
8 #
9 # The source code of this program is made available
10 # under the terms of the GNU Affero General Public License version 3
11 # (GNU AGPL V3) as published by the Free Software Foundation.
12 #
13 # Binary versions of this program provided by Univention to you as
14 # well as other copyrighted, protected or trademarked materials like
15 # Logos, graphics, fonts, specific documentations and configurations,
16 # cryptographic keys etc. are subject to a license agreement between
17 # you and Univention and not subject to the GNU AGPL V3.
18 #
19 # In the case you use this program under the terms of the GNU AGPL V3,
20 # the program is provided in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU Affero General Public License for more details.
24 #
25 # You should have received a copy of the GNU Affero General Public
26 # License with the Debian GNU/Linux or Univention distribution in file
27 # /usr/share/common-licenses/AGPL-3; if not, see
28 # <http://www.gnu.org/licenses/>.
29
30 #DEBHELPER#
31
32 . /usr/share/debconf/confmodule
33 db_version 2.0
34
35 if [ "$1" = "configure" ]; then
36
37     # setup webserver
38     db_get tine20/webserver_type
39     webserver="$RET"
40     
41     case "$webserver" in
42         apache2)
43             # check if webserver is installed
44             if [ -x /usr/sbin/$webserver ]; then 
45
46                 if [ -d /etc/apache2/mods-enabled ]; then
47                     if [ ! -f /etc/apache2/mods-enabled/rewrite.load -a ! -h /etc/apache2/mods-enabled/rewrite.load ]; then
48                         /usr/sbin/a2enmod rewrite
49                     fi
50                     if [ ! -f /etc/apache2/mods-enabled/expires.load -a ! -h /etc/apache2/mods-enabled/expires.load ]; then
51                         /usr/sbin/a2enmod expires
52                     fi
53                     if [ -f /etc/apache2/mods-available/php5.load ]; then
54                         if [ ! -f /etc/apache2/mods-enabled/php5.load -a ! -h /etc/apache2/mods-enabled/php5.load ]; then
55                             /usr/sbin/a2enmod php5
56                         fi 
57                     fi
58                 fi
59                 
60                 # create Apache 2.x configuration links
61                 if [ -d /etc/apache2/conf.d/ ]; then
62                     if [ ! -e /etc/apache2/conf.d/tine20.conf ]; then
63                         ln -s ../../tine20/apache.conf /etc/apache2/conf.d/tine20.conf
64                     fi
65                     
66                 elif [ -d /etc/apache2/conf-available ]; then
67                     if [ ! -e /etc/apache2/conf-available/tine20.conf ]; then
68                         ln -s ../../tine20/apache.conf /etc/apache2/conf-available/tine20.conf
69                     fi
70                     
71                     /usr/sbin/a2enconf tine20
72                 fi
73                 
74                 # mark webserver for restart (used by restart.sh)
75                 servers="apache2"
76                 restart="$restart $webserver"
77             
78             fi
79             ;;
80             
81         lighttpd)
82             # check if webserver is installed
83             if [ -x /usr/sbin/$webserver ]; then 
84
85                 # create vhost configuration links
86                 servers="$webserver"
87                 linkdestination_lighttpd="../../tine20/lighttpd.conf"
88                 linkname="15-tine20.conf"
89     
90                 if [ -e /usr/share/wwwconfig-common/confd-link.sh ]; then
91                     . /usr/share/wwwconfig-common/confd-link.sh
92                 fi
93                 
94                 if [ -d /etc/$webserver/conf-available ]; then
95                     if [ ! -f /etc/$webserver/conf-enabled/10-expire.conf -a ! -h /etc/$webserver/conf-enabled/10-expire.conf ]; then
96                         /usr/sbin/lighttpd-enable-mod expire
97                     fi
98     
99                     if [ ! -f /etc/$webserver/conf-enabled/15-tine20.conf -a ! -h /etc/$webserver/conf-enabled/15-tine20.conf ]; then
100                         /usr/sbin/lighttpd-enable-mod tine20
101                     fi
102                 fi
103                 
104                 # mark webserver for restart (used by restart.sh)
105                 restart="$restart $webserver"
106             
107             fi
108             ;;
109         
110     esac
111     
112     # restart webserver
113     if [ -e /usr/share/wwwconfig-common/restart.sh ]; then
114         . /usr/share/wwwconfig-common/restart.sh
115     fi
116
117 fi
118
119 exit 0