root/alternc/trunk/debian/alternc-slave.postinst

Revision 2424, 6.0 kB (checked in by anarcat, 1 month ago)

configure alternc-slave as a primary MX for the main server

this aims to resolve a lot of mail problems we are having on our deployment at Koumbit

  • Property svn:mergeinfo set to
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
12     local var
13     question="$1"
14     var="$2"
15     db_get "$question"
16     if [ ! -z "$RET" ]; then
17         grep -Eq "^ *$var=" $CONFIGFILE || echo "$var=" >> $CONFIGFILE
18         SED_SCRIPT="$SED_SCRIPT;s\\^ *$var=.*\\$var=\"$RET\"\\"
19     fi
20 }
21
22 # summary of how this script can be called:
23 #        * <postinst> `configure' <most-recently-configured-version>
24 #        * <old-postinst> `abort-upgrade' <new version>
25 #        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
26 #          <new-version>
27 #        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
28 #          <failed-install-package> <version> `removing'
29 #          <conflicting-package> <version>
30 # for details, see http://www.debian.org/doc/debian-policy/ or
31 # the debian-policy package
32 #
33 # quoting from the policy:
34 #     Any necessary prompting should almost always be confined to the
35 #     post-installation script, and should be protected with a conditional
36 #     so that unnecessary prompting doesn't happen if a package's
37 #     installation fails and the `postinst' is called with `abort-upgrade',
38 #     `abort-remove' or `abort-deconfigure'.
39
40 case "$1" in
41   configure)
42
43     # ajoute l'user postfix au groupe sasl
44     adduser --quiet postfix sasl
45
46     db_get "alternc-slave/mergelog-key"
47     key="$RET"
48     if [ "X$key" != "" ]; then
49         echo "Creating alternc-mergelog account"
50         adduser --quiet --system --home /var/run/alternc-mergelog --shell /usr/bin/scponly --ingroup adm alternc-mergelog
51         if ! grep -q "$key" /var/run/alternc-mergelog/.ssh/authorized_keys ; then
52             echo "Authorizing requested key to access alternc-mergelog account"
53             mkdir -p /var/run/alternc-mergelog/.ssh
54             echo "$key" >> /var/run/alternc-mergelog/.ssh/authorized_keys
55             chown -R alternc-mergelog:adm /var/run/alternc-mergelog/.ssh
56             chmod -R og-rwx /var/run/alternc-mergelog/.ssh
57         fi
58     fi
59
60     # corriger les permissions du chroot
61     mkdir -p /var/spool/postfix/var/run/saslauthd || true
62     dpkg-statoverride --quiet --update --add root sasl 710 /var/spool/postfix/var/run/saslauthd  || true
63
64     # build local.sh if it does not exist
65     if [ ! -f $CONFIGFILE ]; then
66         cat > $CONFIGFILE <<EOF
67 #!/bin/sh
68 #
69 # AlternC - Web Hosting System - Configuration
70 # This file will be modified on package configuration
71 # (e.g. upgrade or dpkg-reconfigure alternc)
72
73 # Hosting service name
74 HOSTING=""
75
76 # Primary hostname for this box (will be used to access the management panel)
77 FQDN=""
78
79 # Public IP
80 PUBLIC_IP=""
81
82 # Internal IP
83 # (most of the time, should be equal to PUBLIC_IP, unless you are behind
84 # firewall doing address translation)
85 INTERNAL_IP=""
86
87 # Monitoring IP or network (will be allowed to access Apache status)
88 MONITOR_IP=""
89
90 # Primary DNS hostname
91 NS1_HOSTNAME=""
92
93 # Secondary DNS hostname
94 NS2_HOSTNAME=""
95
96 # Mail server hostname
97 DEFAULT_MX=""
98
99 # Note: MySQL username/password configuration now stored in /etc/alternc/my.cnf
100
101 # quels clients mysql sont permis (%, localhost, etc)
102 MYSQL_CLIENT=""
103
104 # Folder holding data (used for quota management)
105 ALTERNC_LOC=""
106
107 # the type of backup created by the sql backup script
108 # valid options are "rotate" (newsyslog-style) or "date" (suffix is the date)
109 SQLBACKUP_TYPE=""
110
111 # overwrite existing files when backing up
112 SQLBACKUP_OVERWRITE=""
113 EOF
114
115         chown root:www-data $CONFIGFILE
116         chmod 640 $CONFIGFILE
117     fi
118
119     # Update local.sh
120     # 1. use cp to keep permissions
121     # 2. add missing variable to local.sh
122     # 3. use sed to set variables with current values
123     echo "Updating $CONFIGFILE"
124     cp -a -f $CONFIGFILE $CONFIGFILE.tmp
125     # SED_SCRIPT will be modified by update_var
126     SED_SCRIPT=""
127     update_var alternc-slave/hostingname HOSTING
128     update_var alternc-slave/desktopname FQDN
129     update_var alternc-slave/public_ip PUBLIC_IP
130     update_var alternc-slave/internal_ip INTERNAL_IP
131     update_var alternc-slave/monitor_ip MONITOR_IP
132     update_var alternc-slave/ns1 NS1_HOSTNAME
133     update_var alternc-slave/ns2 NS2_HOSTNAME
134     update_var alternc-slave/default_mx DEFAULT_MX
135     update_var alternc-slave/mysql/client MYSQL_CLIENT
136     update_var alternc-slave/sql/backup_type SQLBACKUP_TYPE
137     update_var alternc-slave/sql/backup_overwrite SQLBACKUP_OVERWRITE
138     update_var alternc-slave/alternc_location ALTERNC_LOC
139     sed -e "$SED_SCRIPT" < $CONFIGFILE > $CONFIGFILE.tmp
140     mv -f $CONFIGFILE.tmp $CONFIGFILE
141
142     # Setup grants
143     db_get "alternc-slave/mysql/host"
144     MYSQL_HOST="$RET"
145     if [ "$MYSQL_HOST" != "localhost" -o -e /usr/sbin/mysqld ]; then
146         # compatibility shims with my.cnf
147         host="$RET"
148         db_get "alternc-slave/mysql/db"
149         database="$RET"
150         db_get "alternc-slave/mysql/user"
151         user="$RET"
152         db_get "alternc-slave/mysql/password"
153         password="$RET"
154        
155         # we source (instead of forking) mysql.sh so that it gets the local environment above
156         . /usr/share/alternc/install/mysql.sh
157     fi
158
159     # forget the password
160     db_reset alternc-slave/mysql/password || true
161     db_fset alternc-slave/mysql/password "seen" "false" || true
162
163     if [ -e $CONFIGFILE ]; then
164       # source local.sh variables
165       . $CONFIGFILE
166     fi
167
168     echo "checking for upgrades"
169     /usr/share/alternc/install/upgrade_check.sh $2
170
171     echo "config phpmyadmin"
172     include_str='include("/etc/alternc/phpmyadmin.inc.php")'
173     pma_config=/etc/phpmyadmin/config.inc.php
174     if ! grep -e "$include_str" $pma_config > /dev/null 2>&1; then
175         echo "<?php $include_str ?>" >> $pma_config
176     fi
177
178     # important: postinst gele sans ca
179     db_stop
180
181     echo "running alternc.install"
182     alternc.install -s
183     ;;
184
185     abort-upgrade|abort-remove|abort-deconfigure)
186
187     ;;
188
189     *)
190         echo "postinst called with unknown argument \`$1'" >&2
191         exit 1
192     ;;
193
194 esac
195
196 # dh_installdeb will replace this with shell code automatically
197 # generated by other debhelper scripts.
198
199 #DEBHELPER#
200
201 exit 0
202
203 # vim: et sw=4
204
Note: See TracBrowser for help on using the browser.