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