| 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 |
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 |
|
|---|
| 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 |
|
|---|
| 65 |
if [ ! -f $CONFIGFILE ]; then |
|---|
| 66 |
cat > $CONFIGFILE <<EOF |
|---|
| 67 |
#!/bin/sh |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
HOSTING="" |
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
FQDN="" |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
PUBLIC_IP="" |
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
INTERNAL_IP="" |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
MONITOR_IP="" |
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
NS1_HOSTNAME="" |
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
NS2_HOSTNAME="" |
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
DEFAULT_MX="" |
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
MYSQL_CLIENT="" |
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
ALTERNC_LOC="" |
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
SQLBACKUP_TYPE="" |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
SQLBACKUP_OVERWRITE="" |
|---|
| 113 |
EOF |
|---|
| 114 |
|
|---|
| 115 |
chown root:www-data $CONFIGFILE |
|---|
| 116 |
chmod 640 $CONFIGFILE |
|---|
| 117 |
fi |
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
echo "Updating $CONFIGFILE" |
|---|
| 124 |
cp -a -f $CONFIGFILE $CONFIGFILE.tmp |
|---|
| 125 |
|
|---|
| 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 |
|
|---|
| 143 |
db_get "alternc-slave/mysql/host" |
|---|
| 144 |
MYSQL_HOST="$RET" |
|---|
| 145 |
if [ "$MYSQL_HOST" != "localhost" -o -e /usr/sbin/mysqld ]; then |
|---|
| 146 |
|
|---|
| 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 |
|
|---|
| 156 |
. /usr/share/alternc/install/mysql.sh |
|---|
| 157 |
fi |
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 |
|
|---|
| 201 |
exit 0 |
|---|
| 202 |
|
|---|
| 203 |
|
|---|
| 204 |
|
|---|