root/alternc/tags/0.9.7/debian/postinst

Revision 1999, 5.8 kB (checked in by anarcat, 1 year ago)

include unconditionnaly our phpmyadmin config, because in the etch
version (2.9), config.inc.php gets called multiple times, which ends up
not including our config in later includes

Closes: #1052

Line 
1 #!/bin/sh
2
3 set -e
4
5 # Source debconf library.
6 . /usr/share/debconf/confmodule
7
8 CONFIGFILE="/etc/alternc/local.sh"
9
10 update_var() {
11     local question="$1"
12     local var="$2"
13     db_get "$question"
14     if [ ! -z "$RET" ]; then
15         grep -Eq "^ *$var=" $CONFIGFILE || echo "$var=" >> $CONFIGFILE
16         SED_SCRIPT="$SED_SCRIPT;s\\^ *$var=.*\\$var=\"$RET\"\\"
17     fi
18 }
19
20 # summary of how this script can be called:
21 #        * <postinst> `configure' <most-recently-configured-version>
22 #        * <old-postinst> `abort-upgrade' <new version>
23 #        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
24 #          <new-version>
25 #        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
26 #          <failed-install-package> <version> `removing'
27 #          <conflicting-package> <version>
28 # for details, see http://www.debian.org/doc/debian-policy/ or
29 # the debian-policy package
30 #
31 # quoting from the policy:
32 #     Any necessary prompting should almost always be confined to the
33 #     post-installation script, and should be protected with a conditional
34 #     so that unnecessary prompting doesn't happen if a package's
35 #     installation fails and the `postinst' is called with `abort-upgrade',
36 #     `abort-remove' or `abort-deconfigure'.
37
38 case "$1" in
39   configure)
40
41     # ajoute l'user postfix au groupe sasl
42     adduser --quiet postfix sasl
43
44     # build local.sh if it does not exist
45     if [ ! -f $CONFIGFILE ]; then
46         cat > $CONFIGFILE <<EOF
47 #!/bin/sh
48 #
49 # AlternC - Web Hosting System - Configuration
50 # This file will be modified on package configuration
51 # (e.g. upgrade or dpkg-reconfigure alternc)
52
53 # Hosting service name
54 HOSTING=""
55
56 # Primary hostname for this box (will be used to access the management panel)
57 FQDN=""
58
59 # Public IP
60 PUBLIC_IP=""
61
62 # Internal IP
63 # (most of the time, should be equal to PUBLIC_IP, unless you are behind
64 # firewall doing address translation)
65 INTERNAL_IP=""
66
67 # Monitoring IP or network (will be allowed to access Apache status)
68 MONITOR_IP=""
69
70 # Primary DNS hostname
71 NS1_HOSTNAME=""
72
73 # Secondary DNS hostname
74 NS2_HOSTNAME=""
75
76 # IP that have privilegied access to the DNS server. Separated by ';'.
77 BIND_INTERNAL=""
78
79 # Mail server hostname
80 DEFAULT_MX=""
81
82 # MySQL configuration
83 MYSQL_HOST=""
84 MYSQL_DATABASE=""
85 MYSQL_USER=""
86 MYSQL_PASS=""
87 # quels clients mysql sont permis (%, localhost, etc)
88 MYSQL_CLIENT=""
89
90 # Folder holding data (used for quota management)
91 ALTERNC_LOC=""
92
93 # Networks that SMTP should relay, separated with spaces
94 SMTP_RELAY_NETWORKS=""
95 EOF
96
97         chown root:www-data $CONFIGFILE
98         chmod 640 $CONFIGFILE
99     fi
100
101     # Update local.sh
102     # 1. use cp to keep permissions
103     # 2. add missing variable to local.sh
104     # 3. use sed to set variables with current values
105     echo "Updating $CONFIGFILE"
106     cp -a -f $CONFIGFILE $CONFIGFILE.tmp
107     # SED_SCRIPT will be modified by update_var
108     SED_SCRIPT=""
109     update_var alternc/hostingname HOSTING
110     update_var alternc/desktopname FQDN
111     update_var alternc/public_ip PUBLIC_IP
112     update_var alternc/internal_ip INTERNAL_IP
113     update_var alternc/monitor_ip MONITOR_IP
114     update_var alternc/ns1 NS1_HOSTNAME
115     update_var alternc/ns2 NS2_HOSTNAME
116     update_var alternc/bind_internal BIND_INTERNAL
117     update_var alternc/default_mx DEFAULT_MX
118     update_var alternc/mysql/host MYSQL_HOST
119     update_var alternc/mysql/db MYSQL_DATABASE
120     update_var alternc/mysql/user MYSQL_USER
121     update_var alternc/mysql/password MYSQL_PASS
122     update_var alternc/mysql/client MYSQL_CLIENT
123     update_var alternc/alternc_location ALTERNC_LOC
124     update_var alternc/mynetwork SMTP_RELAY_NETWORKS
125     sed -e "$SED_SCRIPT" < $CONFIGFILE > $CONFIGFILE.tmp
126     mv -f $CONFIGFILE.tmp $CONFIGFILE
127
128     # forget the password
129     db_reset alternc/mysql/password || true
130     db_fset alternc/mysql/password "seen" "false" || true
131
132     if [ -e $CONFIGFILE ]; then
133       # source local.sh variables
134       . $CONFIGFILE
135     fi
136
137     # Erase all apacheconf file
138     # They will be regenerated without the bug by upgrade_check.sh below.
139     if dpkg --compare-versions "$2" le "0.9.3.9-globenet14"; then
140         rm -f /var/alternc/apacheconf/*/*
141         rm -f /var/alternc/apacheconf/override_php.conf
142     fi
143
144     echo "checking for upgrades"
145     /usr/share/alternc/install/upgrade_check.sh $2
146
147     echo "config phpmyadmin"
148     include_str='include("/etc/alternc/phpmyadmin.inc.php")'
149     pma_config=/etc/phpmyadmin/config.inc.php
150     if ! grep -e "$include_str" $pma_config > /dev/null 2>&1; then
151         echo "<?php $include_str ?>" >> $pma_config
152     fi
153
154     # important: postinst gele sans ca
155     db_stop
156
157     echo "running alternc.install"
158     alternc.install
159
160     if [ -x /usr/sbin/apache ]; then
161         if [ ! -h /etc/apache-ssl/conf.d/alternc.conf ]; then
162             ln -sf /etc/alternc/apache-ssl.conf \
163                 /etc/apache-ssl/conf.d/alternc.conf
164         fi
165
166         if [ ! -h /etc/apache/conf.d/alternc.conf ]; then
167             ln -sf /etc/alternc/apache.conf \
168                 /etc/apache/conf.d/alternc.conf
169         fi
170
171         if [ ! -h /etc/apache/conf.d/override_php.conf ]; then
172             ln -sf /var/alternc/apacheconf/override_php.conf \
173                 /etc/apache/conf.d/override_php.conf
174         fi
175     fi
176     if [ -x /usr/sbin/apache2 ]; then
177         if [ ! -h /etc/apache2/conf.d/alternc.conf ]; then
178             ln -sf /etc/alternc/apache.conf \
179                 /etc/apache/conf.d/alternc.conf
180         fi
181         if [ ! -h /etc/apache2/conf.d/override_php.conf ]; then
182             ln -sf /var/alternc/apacheconf/override_php.conf \
183                 /etc/apache/conf.d/override_php.conf
184         fi
185
186     fi
187     ;;
188
189     abort-upgrade|abort-remove|abort-deconfigure)
190
191     ;;
192
193     *)
194         echo "postinst called with unknown argument \`$1'" >&2
195         exit 1
196     ;;
197
198 esac
199
200 # dh_installdeb will replace this with shell code automatically
201 # generated by other debhelper scripts.
202
203 #DEBHELPER#
204
205 exit 0
206
207 # vim: et sw=4
208
Note: See TracBrowser for help on using the browser.