source: alternc/trunk/debian/postinst @ 1778

Revision 1778, 5.3 KB checked in by anarcat, 8 years ago (diff)

fix the real problem: add postfix to the sasl group in postinst, so that we don't need postfix in pre-depends

Line 
1#!/bin/sh
2
3set -e
4
5# Source debconf library.
6. /usr/share/debconf/confmodule
7
8CONFIGFILE="/etc/alternc/local.sh"
9
10update_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
38case "$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
54HOSTING=""
55
56# Primary hostname for this box (will be used to access the management panel)
57FQDN=""
58
59# Public IP
60PUBLIC_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)
65INTERNAL_IP=""
66
67# Monitoring IP or network (will be allowed to access Apache status)
68MONITOR_IP=""
69
70# Primary DNS hostname
71NS1_HOSTNAME=""
72
73# Secondary DNS hostname
74NS2_HOSTNAME=""
75
76# IP that have privilegied access to the DNS server. Separated by ';'.
77BIND_INTERNAL=""
78
79# Mail server hostname
80DEFAULT_MX=""
81
82# MySQL configuration
83MYSQL_HOST=""
84MYSQL_DATABASE=""
85MYSQL_USER=""
86MYSQL_PASS=""
87# quels clients mysql sont permis (%, localhost, etc)
88MYSQL_CLIENT=""
89
90# Folder holding data (used for quota management)
91ALTERNC_LOC=""
92
93# Networks that SMTP should relay, separated with spaces
94SMTP_RELAY_NETWORKS=""
95EOF
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_once("/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 [ ! -h /etc/apache-ssl/conf.d/alternc.conf ]; then
161        ln -sf /etc/alternc/apache-ssl.conf \
162            /etc/apache-ssl/conf.d/alternc.conf
163    fi
164
165    if [ ! -h /etc/apache/conf.d/alternc.conf ]; then
166        ln -sf /etc/alternc/apache.conf \
167            /etc/apache/conf.d/alternc.conf
168    fi
169
170    if [ ! -h /etc/apache/conf.d/override_php.conf ]; then
171        ln -sf /var/alternc/apacheconf/override_php.conf \
172            /etc/apache/conf.d/override_php.conf
173    fi
174
175    ;;
176
177    abort-upgrade|abort-remove|abort-deconfigure)
178
179    ;;
180
181    *)
182        echo "postinst called with unknown argument \`$1'" >&2
183        exit 1
184    ;;
185
186esac
187
188# dh_installdeb will replace this with shell code automatically
189# generated by other debhelper scripts.
190
191#DEBHELPER#
192
193exit 0
194
195# vim: et sw=4
Note: See TracBrowser for help on using the repository browser.