| 1 |
#!/bin/sh |
|---|
| 2 |
|
|---|
| 3 |
set -e |
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 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 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
case "$1" in |
|---|
| 41 |
configure) |
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
adduser --quiet postfix sasl |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 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 |
|
|---|
| 51 |
if [ ! -f $CONFIGFILE ]; then |
|---|
| 52 |
cat > $CONFIGFILE <<EOF |
|---|
| 53 |
#!/bin/sh |
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
HOSTING="" |
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
FQDN="" |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
PUBLIC_IP="" |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
INTERNAL_IP="" |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
MONITOR_IP="" |
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
NS1_HOSTNAME="" |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
NS2_HOSTNAME="" |
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
DEFAULT_MX="" |
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
MYSQL_CLIENT="" |
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
ALTERNC_LOC="" |
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
SQLBACKUP_TYPE="" |
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
SQLBACKUP_OVERWRITE="" |
|---|
| 99 |
EOF |
|---|
| 100 |
|
|---|
| 101 |
chown root:www-data $CONFIGFILE |
|---|
| 102 |
chmod 640 $CONFIGFILE |
|---|
| 103 |
fi |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
echo "Updating $CONFIGFILE" |
|---|
| 110 |
cp -a -f $CONFIGFILE $CONFIGFILE.tmp |
|---|
| 111 |
|
|---|
| 112 |
SED_SCRIPT="" |
|---|
| 113 |
update_var alternc/hostingname HOSTING |
|---|
| 114 |
update_var alternc/desktopname FQDN |
|---|
| 115 |
update_var alternc/public_ip PUBLIC_IP |
|---|
| 116 |
update_var alternc/internal_ip INTERNAL_IP |
|---|
| 117 |
update_var alternc/monitor_ip MONITOR_IP |
|---|
| 118 |
update_var alternc/ns1 NS1_HOSTNAME |
|---|
| 119 |
update_var alternc/ns2 NS2_HOSTNAME |
|---|
| 120 |
update_var alternc/default_mx DEFAULT_MX |
|---|
| 121 |
update_var alternc/mysql/client MYSQL_CLIENT |
|---|
| 122 |
update_var alternc/sql/backup_type SQLBACKUP_TYPE |
|---|
| 123 |
update_var alternc/sql/backup_overwrite SQLBACKUP_OVERWRITE |
|---|
| 124 |
update_var alternc/alternc_location ALTERNC_LOC |
|---|
| 125 |
sed -e "$SED_SCRIPT" < $CONFIGFILE > $CONFIGFILE.tmp |
|---|
| 126 |
mv -f $CONFIGFILE.tmp $CONFIGFILE |
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
db_get "alternc/mysql/host" |
|---|
| 130 |
MYSQL_HOST="$RET" |
|---|
| 131 |
if [ "$MYSQL_HOST" != "localhost" -o -e /usr/sbin/mysqld ]; then |
|---|
| 132 |
|
|---|
| 133 |
host="$RET" |
|---|
| 134 |
db_get "alternc/mysql/db" |
|---|
| 135 |
database="$RET" |
|---|
| 136 |
db_get "alternc/mysql/user" |
|---|
| 137 |
user="$RET" |
|---|
| 138 |
db_get "alternc/mysql/password" |
|---|
| 139 |
password="$RET" |
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
. /usr/share/alternc/install/mysql.sh |
|---|
| 143 |
fi |
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
db_reset alternc/mysql/password || true |
|---|
| 147 |
db_fset alternc/mysql/password "seen" "false" || true |
|---|
| 148 |
|
|---|
| 149 |
if [ -e $CONFIGFILE ]; then |
|---|
| 150 |
|
|---|
| 151 |
. $CONFIGFILE |
|---|
| 152 |
fi |
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
FQDN_LETTER="`echo $FQDN | sed -e 's/.*\.\([^\.]\)[^\.]*\.[^\.]*$/\1/'`" |
|---|
| 156 |
if [ "$FQDN_LETTER" = "$FQDN" ] |
|---|
| 157 |
then |
|---|
| 158 |
FQDN_LETTER="_" |
|---|
| 159 |
fi |
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
if dpkg --compare-versions "$2" le "0.9.3.9-globenet14"; then |
|---|
| 164 |
rm -f /var/alternc/apacheconf/*/* |
|---|
| 165 |
rm -f /var/alternc/apacheconf/override_php.conf |
|---|
| 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 |
|
|---|
| 179 |
ln -nsf /var/alternc/bureau /var/alternc/dns/$FQDN_LETTER/$FQDN |
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
touch /var/alternc/bind/automatic.conf /var/alternc/bind/slaveip.conf |
|---|
| 183 |
chown root:bind /var/alternc/bind/automatic.conf /var/alternc/bind/slaveip.conf |
|---|
| 184 |
chmod 640 /var/alternc/bind/automatic.conf /var/alternc/bind/slaveip.conf |
|---|
| 185 |
touch /var/run/alternc/refresh_slave |
|---|
| 186 |
/usr/lib/alternc/slave_dns |
|---|
| 187 |
|
|---|
| 188 |
touch /var/alternc/apacheconf/override_php.conf |
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 |
/usr/share/alternc/install/dopo.sh |
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
db_stop |
|---|
| 195 |
|
|---|
| 196 |
echo "running alternc.install" |
|---|
| 197 |
alternc.install |
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 |
/usr/lib/alternc/basedir_prot.sh |
|---|
| 201 |
|
|---|
| 202 |
;; |
|---|
| 203 |
|
|---|
| 204 |
abort-upgrade|abort-remove|abort-deconfigure) |
|---|
| 205 |
|
|---|
| 206 |
;; |
|---|
| 207 |
|
|---|
| 208 |
*) |
|---|
| 209 |
echo "postinst called with unknown argument \`$1'" >&2 |
|---|
| 210 |
exit 1 |
|---|
| 211 |
;; |
|---|
| 212 |
|
|---|
| 213 |
esac |
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 |
|
|---|
| 217 |
|
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 |
exit 0 |
|---|
| 221 |
|
|---|
| 222 |
|
|---|
| 223 |
|
|---|