root/alternc/branches/larpoux-unstable/debian/postinst

Revision 858, 5.8 kB (checked in by larpoux, 3 years ago)

Ticket #577


MYSQL_HOST=localhost (semble marcher beaucoup mieux)

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     # build local.sh if it does not exist
42     if [ ! -f $CONFIGFILE ]; then
43         cat > $CONFIGFILE <<EOF
44 #!/bin/sh
45 #
46 # AlternC - Web Hosting System - Configuration
47 # This file will be modified on package configuration
48 # (e.g. upgrade or dpkg-reconfigure alternc)
49
50 # Hosting service name
51 HOSTING=""
52
53 # Primary hostname for this box (will be used to access the management panel)
54 FQDN=""
55
56 # Public IP
57 PUBLIC_IP=""
58
59 # Internal IP
60 # (most of the time, should be equal to PUBLIC_IP, unless you are behind
61 # firewall doing address translation)
62 INTERNAL_IP=""
63
64 # Monitoring IP or network (will be allowed to access Apache status)
65 MONITOR_IP=""
66
67 # Primary DNS hostname
68 NS1_HOSTNAME=""
69
70 # Secondary DNS hostname
71 NS2_HOSTNAME=""
72
73 # IP that have privilegied access to the DNS server. Separated by ';'.
74 BIND_INTERNAL=""
75
76 # Mail server hostname
77 DEFAULT_MX=""
78
79 # MySQL configuration
80 MYSQL_HOST=""
81 MYSQL_DATABASE=""
82 MYSQL_USER=""
83 MYSQL_PASS=""
84
85 # Folder holding data (used for quota management)
86 ALTERNC_LOC=""
87
88 # Networks that SMTP should relay, separated with spaces
89 SMTP_RELAY_NETWORKS=""
90 EOF
91
92         chown root:www-data $CONFIGFILE
93     fi
94
95     for pair in \
96     "alternc/desktopname FQDN" \
97     "alternc/default_mx DEFAULT_MX" \
98     "alternc/alternc_location ALTERNC_LOC" \
99     "alternc/mysql/host MYSQL_HOST" \
100     "alternc/mysql/db MYSQL_DATABASE" \
101     "alternc/mysql/user MYSQL_USER" \
102     "alternc/mysql/password MYSQL_PASS" \
103     "alternc/public_ip DEFAULT_IP"
104     do
105       skip=0
106       for single in $pair
107       do
108         if [ "$skip" = "0" ]; then
109           db_get "$single" || true
110           skip=1
111         else
112           echo "$single=\"$RET\"" >> /etc/alternc/local.sh
113         fi
114       done
115     done
116
117     # forget the password
118     db_reset alternc/mysql/password || true
119     db_fset alternc/mysql/password "seen" "false" || true
120
121     if [ -e $CONFIGFILE ]; then
122       # source local.sh variables
123       . $CONFIGFILE
124     fi
125
126     # Erase all apacheconf file
127     # They will be regenerated without the bug by upgrade_check.sh below.
128     if dpkg --compare-versions "$2" le "0.9.3.9-globenet14"; then
129         rm -f /var/alternc/apacheconf/*/*
130         rm -f /var/alternc/apacheconf/override_php.conf
131     fi
132
133     echo "checking for upgrades"
134     /usr/share/alternc/install/upgrade_check.sh $2
135
136     # important: postinst gele sans ca
137     db_stop
138
139     # ensure our run dir for saslauthd is present in Debian stat database
140     # (needed by /etc/init.d/saslauthd)
141     PWDIR=/var/spool/postfix/var/run/saslauthd
142     dpkg-statoverride --list $PWDIR 2>&1 >/dev/null ||
143         dpkg-statoverride --update --add root sasl 710 $PWDIR
144    
145     # postfix needs to be in the sasl group for saslauthd connection
146     adduser --quiet postfix sasl
147
148     echo "config phpmyadmin"
149     include_str='include_once("/etc/alternc/phpmyadmin.inc.php")'
150     pma_config=/etc/phpmyadmin/config.inc.php
151     if ! grep -e "$include_str" $pma_config > /dev/null 2>&1; then
152         echo "<?php $include_str ?>" >> $pma_config
153     fi
154
155    if ! test -e /etc/apache-ssl/conf.d/phpmyadmin.conf; then
156       if test -e /etc/phpmyadmin/apache.conf; then
157                 ln -s /etc/phpmyadmin/apache.conf /etc/apache-ssl/conf.d/phpmyadmin.conf
158       fi
159    fi
160
161    if ! test -e /etc/apache/conf.d/phpmyadmin.conf; then
162       if test -e /etc/phpmyadmin/apache.conf; then
163                 ln -s /etc/phpmyadmin/apache.conf /etc/apache/conf.d/phpmyadmin.conf
164       fi
165    fi
166
167
168    if ! test -e /etc/apache-ssl/conf.d/squirrelmail.conf; then
169       if test -e /etc/squirrelmail/apache.conf; then
170                 ln -s /etc/squirrelmail/apache.conf /etc/apache-ssl/conf.d/squirrelmail.conf
171       fi
172    fi
173
174    if ! test -e /etc/apache/conf.d/squirrelmail.conf; then
175       if test -e /etc/squirrelmail/apache.conf; then
176                 ln -s /etc/squirrelmail/apache.conf /etc/apache/conf.d/squirrelmail.conf
177       fi
178    fi
179
180
181 # Apache will not start without this file
182 touch /var/alternc/apacheconf/override_php.conf
183
184    if ! test -e /etc/apache-ssl/conf.d/override_php.conf; then
185                 ln -s /var/alternc/apacheconf/override_php.conf /etc/apache-ssl/conf.d/override_php.conf
186    fi
187
188
189    if ! test -e /etc/apache/conf.d/override_php.conf; then
190                 ln -s /var/alternc/apacheconf/override_php.conf /etc/apache/conf.d/override_php.conf
191    fi
192
193
194
195     echo "running alternc.install"
196     alternc.install
197
198     ;;
199
200     abort-upgrade|abort-remove|abort-deconfigure)
201
202     ;;
203
204     *)
205         echo "postinst called with unknown argument \`$1'" >&2
206         exit 1
207     ;;
208
209 esac
210
211 # dh_installdeb will replace this with shell code automatically
212 # generated by other debhelper scripts.
213
214 #DEBHELPER#
215
216 exit 0
217
218 # vim: et sw=4
219
Note: See TracBrowser for help on using the browser.