root/alternc/trunk/debian/postinst

Revision 2259, 6.7 kB (checked in by anarcat, 2 weeks ago)

add some of the sqlbackup options to the local.sh global configuration.
note that we discarded some suggestions options:

F_LOG: replaced with syslog
DAEMON: will be considered for inclusion later
VERBOSE/DEBUG: available through command line flags

TYPE_NAME_BACKUP and ALLOW_OVERWRITE_BACKUP are being renamed to
SQLBACKUP_TYPE and SQLBACKUP_OVERWRITE. this is to be more consistent
with the global configurations

See: #1081

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     # corriger les permissions du chroot
45     mkdir -p /var/spool/postfix/var/run/saslauthd || true
46     dpkg-statoverride --quiet --update --add root sasl 710 /var/spool/postfix/var/run/saslauthd  || true
47
48     # build local.sh if it does not exist
49     if [ ! -f $CONFIGFILE ]; then
50         cat > $CONFIGFILE <<EOF
51 #!/bin/sh
52 #
53 # AlternC - Web Hosting System - Configuration
54 # This file will be modified on package configuration
55 # (e.g. upgrade or dpkg-reconfigure alternc)
56
57 # Hosting service name
58 HOSTING=""
59
60 # Primary hostname for this box (will be used to access the management panel)
61 FQDN=""
62
63 # Public IP
64 PUBLIC_IP=""
65
66 # Internal IP
67 # (most of the time, should be equal to PUBLIC_IP, unless you are behind
68 # firewall doing address translation)
69 INTERNAL_IP=""
70
71 # Monitoring IP or network (will be allowed to access Apache status)
72 MONITOR_IP=""
73
74 # Primary DNS hostname
75 NS1_HOSTNAME=""
76
77 # Secondary DNS hostname
78 NS2_HOSTNAME=""
79
80 # IP that have privilegied access to the DNS server. Separated by ';'.
81 BIND_INTERNAL=""
82
83 # Mail server hostname
84 DEFAULT_MX=""
85
86 # Note: MySQL username/password configuration now stored in /etc/alternc/my.cnf
87
88 # quels clients mysql sont permis (%, localhost, etc)
89 MYSQL_CLIENT=""
90
91 # Folder holding data (used for quota management)
92 ALTERNC_LOC=""
93
94 # Networks that SMTP should relay, separated with spaces
95 SMTP_RELAY_NETWORKS=""
96
97 # the type of backup created by the sql backup script
98 # valid options are "rotate" (newsyslog-style) or "date" (suffix is the date)
99 SQLBACKUP_TYPE=""
100
101 # overwrite existing files when backing up
102 SQLBACKUP_OVERWRITE=""
103 EOF
104
105         chown root:www-data $CONFIGFILE
106         chmod 640 $CONFIGFILE
107     fi
108
109     # Update local.sh
110     # 1. use cp to keep permissions
111     # 2. add missing variable to local.sh
112     # 3. use sed to set variables with current values
113     echo "Updating $CONFIGFILE"
114     cp -a -f $CONFIGFILE $CONFIGFILE.tmp
115     # SED_SCRIPT will be modified by update_var
116     SED_SCRIPT=""
117     update_var alternc/hostingname HOSTING
118     update_var alternc/desktopname FQDN
119     update_var alternc/public_ip PUBLIC_IP
120     update_var alternc/internal_ip INTERNAL_IP
121     update_var alternc/monitor_ip MONITOR_IP
122     update_var alternc/ns1 NS1_HOSTNAME
123     update_var alternc/ns2 NS2_HOSTNAME
124     update_var alternc/bind_internal BIND_INTERNAL
125     update_var alternc/default_mx DEFAULT_MX
126     update_var alternc/mysql/client MYSQL_CLIENT
127     update_var alternc/sql/backup_type SQLBACKUP_TYPE
128     update_var alternc/sql/backup_overwrite SQLBACKUP_OVERWRITE
129     update_var alternc/alternc_location ALTERNC_LOC
130     update_var alternc/mynetwork SMTP_RELAY_NETWORKS
131     sed -e "$SED_SCRIPT" < $CONFIGFILE > $CONFIGFILE.tmp
132     mv -f $CONFIGFILE.tmp $CONFIGFILE
133
134     # Setup grants
135     db_get "alternc/mysql/host"
136     MYSQL_HOST="$RET"
137     if [ "$MYSQL_HOST" != "localhost" -o -e /usr/sbin/mysqld ]; then
138         # compatibility shims with my.cnf
139         host="$RET"
140         db_get "alternc/mysql/db"
141         database="$RET"
142         db_get "alternc/mysql/user"
143         user="$RET"
144         db_get "alternc/mysql/password"
145         password="$RET"
146        
147         # we source (instead of forking) mysql.sh so that it gets the local environment above
148         . /usr/share/alternc/install/mysql.sh
149     fi
150
151     # forget the password
152     db_reset alternc/mysql/password || true
153     db_fset alternc/mysql/password "seen" "false" || true
154
155     if [ -e $CONFIGFILE ]; then
156       # source local.sh variables
157       . $CONFIGFILE
158     fi
159
160     # Erase all apacheconf file
161     # They will be regenerated without the bug by upgrade_check.sh below.
162     if dpkg --compare-versions "$2" le "0.9.3.9-globenet14"; then
163         rm -f /var/alternc/apacheconf/*/*
164         rm -f /var/alternc/apacheconf/override_php.conf
165     fi
166
167     echo "checking for upgrades"
168     /usr/share/alternc/install/upgrade_check.sh $2
169
170     echo "config phpmyadmin"
171     include_str='include("/etc/alternc/phpmyadmin.inc.php")'
172     pma_config=/etc/phpmyadmin/config.inc.php
173     if ! grep -e "$include_str" $pma_config > /dev/null 2>&1; then
174         echo "<?php $include_str ?>" >> $pma_config
175     fi
176
177     # important: postinst gele sans ca
178     db_stop
179
180     echo "running alternc.install"
181     alternc.install
182
183     if [ -x /usr/sbin/apache ]; then
184         if [ ! -h /etc/apache-ssl/conf.d/alternc.conf ]; then
185             ln -sf /etc/alternc/apache-ssl.conf \
186                 /etc/apache-ssl/conf.d/alternc.conf
187         fi
188
189         if [ ! -h /etc/apache/conf.d/alternc.conf ]; then
190             ln -sf /etc/alternc/apache.conf \
191                 /etc/apache/conf.d/alternc.conf
192         fi
193
194         if [ ! -h /etc/apache/conf.d/override_php.conf ]; then
195             ln -sf /var/alternc/apacheconf/override_php.conf \
196                 /etc/apache/conf.d/override_php.conf
197         fi
198     fi
199     if [ -x /usr/sbin/apache2 ]; then
200         if [ ! -h /etc/apache2/conf.d/alternc.conf ]; then
201             ln -sf /etc/alternc/apache.conf \
202                 /etc/apache/conf.d/alternc.conf
203         fi
204         if [ ! -h /etc/apache2/conf.d/override_php.conf ]; then
205             ln -sf /var/alternc/apacheconf/override_php.conf \
206                 /etc/apache/conf.d/override_php.conf
207         fi
208
209     fi
210     ;;
211
212     abort-upgrade|abort-remove|abort-deconfigure)
213
214     ;;
215
216     *)
217         echo "postinst called with unknown argument \`$1'" >&2
218         exit 1
219     ;;
220
221 esac
222
223 # dh_installdeb will replace this with shell code automatically
224 # generated by other debhelper scripts.
225
226 #DEBHELPER#
227
228 exit 0
229
230 # vim: et sw=4
231
Note: See TracBrowser for help on using the browser.