2006-04-26 12:28:53 +00:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
# Source debconf library.
|
|
|
|
. /usr/share/debconf/confmodule
|
|
|
|
db_title AlternC
|
|
|
|
|
|
|
|
db_input critical alternc/welcomeconfirm || true
|
|
|
|
|
|
|
|
db_go
|
|
|
|
# Check the answer.
|
|
|
|
db_get alternc/welcomeconfirm || true
|
|
|
|
|
|
|
|
if [ "$RET" = "false" ]; then
|
2007-01-12 20:20:35 +00:00
|
|
|
# reset the welcomeconfirm flag if user refuses so it gets asked again next time
|
|
|
|
db_reset alternc/welcomeconfirm || true
|
|
|
|
db_fset alternc/welcomeconfirm "seen" "false" || true
|
2006-04-26 12:28:53 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-05-22 19:18:43 +00:00
|
|
|
db_input critical alternc/warningaclquota || true
|
|
|
|
|
2012-08-06 09:54:09 +00:00
|
|
|
|
|
|
|
|
2006-04-26 12:28:53 +00:00
|
|
|
# default values for local.sh
|
|
|
|
MYSQL_HOST=127.0.0.1
|
|
|
|
MYSQL_DATABASE=alternc
|
|
|
|
MYSQL_USER=sysusr
|
|
|
|
MYSQL_PASS="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)' `"
|
2012-04-24 15:51:47 +00:00
|
|
|
MYSQL_MAIL_USER=alternc_user
|
2012-04-16 14:21:10 +00:00
|
|
|
MYSQL_MAIL_PASS="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)' `"
|
2006-04-26 12:28:53 +00:00
|
|
|
MYSQL_CLIENT=localhost
|
|
|
|
FQDN="`cat /etc/mailname 2>/dev/null || hostname -f`"
|
2010-01-15 00:08:25 +00:00
|
|
|
INTERNAL_IP="`env LANG=C /sbin/ifconfig|grep inet | grep -v 127.0.0.1| head -1 | cut -d: -f2 | sed -e 's/\([0-9\.]*\).*$/\1/' 2>/dev/null || hostname -f`"
|
2006-04-26 12:28:53 +00:00
|
|
|
PUBLIC_IP="$INTERNAL_IP"
|
|
|
|
DEFAULT_MX="`cat /etc/mailname 2>/dev/null || hostname -f`"
|
|
|
|
ALTERNC_LOC=/var/alternc
|
|
|
|
NS1_HOSTNAME="$FQDN"
|
|
|
|
NS2_HOSTNAME="$FQDN"
|
|
|
|
HOSTING="AlternC"
|
2008-07-10 21:18:42 +00:00
|
|
|
SQLBACKUP_TYPE="rotate"
|
|
|
|
SQLBACKUP_OVERWRITE="no"
|
2006-04-26 12:28:53 +00:00
|
|
|
|
|
|
|
if [ -r /etc/alternc/local.sh ]; then
|
|
|
|
# source the current config
|
|
|
|
. /etc/alternc/local.sh
|
|
|
|
fi
|
2008-04-13 04:35:19 +00:00
|
|
|
if [ -r /etc/alternc/my.cnf ]; then
|
|
|
|
# make mysql configuration available as shell variables
|
|
|
|
# to convert from .cnf to shell syntax, we:
|
|
|
|
# * match only lines with "equal" in them (/=/)
|
|
|
|
# * remove whitespace around the = and add a left quote operator ' (;s)
|
|
|
|
# * add a right quote operator at the end of line (;s)
|
|
|
|
# * convert mysql variables into our MYSQL_ naming convention (;s)
|
|
|
|
# * print the result (;p)
|
2008-04-17 23:08:10 +00:00
|
|
|
eval `sed -n -e "/=/{s/ *= *\"\?/='/;s/\"\?\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_USER/;s/password/MYSQL_PASS/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/my.cnf`
|
2008-04-13 04:35:19 +00:00
|
|
|
fi
|
2006-04-26 12:28:53 +00:00
|
|
|
|
2012-04-16 14:21:10 +00:00
|
|
|
if [ -r /etc/alternc/my_mail.cnf ]; then
|
|
|
|
# make mysql configuration available as shell variables
|
|
|
|
# to convert from .cnf to shell syntax, we:
|
|
|
|
# * match only lines with "equal" in them (/=/)
|
|
|
|
# * remove whitespace around the = and add a left quote operator ' (;s)
|
|
|
|
# * add a right quote operator at the end of line (;s)
|
|
|
|
# * convert mysql variables into our MYSQL_ naming convention (;s)
|
|
|
|
# * print the result (;p)
|
|
|
|
eval `sed -n -e "/=/{s/ *= *\"\?/='/;s/\"\?\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_MAIL_USER/;s/password/MYSQL_MAIL_PASS/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/my_mail.cnf`
|
|
|
|
fi
|
2011-05-22 19:18:43 +00:00
|
|
|
|
2006-04-26 12:28:53 +00:00
|
|
|
# mettre les valeurs de local.sh comme "default" pour debconf
|
2012-08-06 09:54:09 +00:00
|
|
|
db_get alternc/alternc_location
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/alternc_location "$ALTERNC_LOC"
|
|
|
|
fi
|
|
|
|
|
|
|
|
db_get alternc/alternc_location
|
2012-08-20 20:29:57 +00:00
|
|
|
#checking acl and quota activation, does't work with NFS yet. and with LXC too...
|
2012-08-06 09:54:09 +00:00
|
|
|
location=$RET
|
|
|
|
mount_point=`df -P $location | tail -1 | /usr/bin/awk '{print $NF}'`
|
2012-08-20 20:29:57 +00:00
|
|
|
quota_activation=`(quotaon -pa 2>/dev/null || true) |grep '^group.*on$' | /usr/bin/awk '$4 ~ /^\'$mount_point'$/ {print $4}'`
|
2012-08-06 09:54:09 +00:00
|
|
|
acl_activation=`/bin/mount | awk '$NF ~ /acl/ && $NF !~ /noacl/ && $3 ~ /^\'"$mount_point"'$/ {print $3}'`
|
|
|
|
|
|
|
|
if [ "$mount_point" != "$acl_activation" ]
|
|
|
|
then
|
|
|
|
db_input critical alternc/acluninstalled || true
|
|
|
|
db_go
|
2012-08-20 20:29:57 +00:00
|
|
|
# db_reset alternc/acluninstalled || true
|
|
|
|
# db_fset alternc/acluninstalled "seen" "false" || true
|
|
|
|
# exit 1
|
2012-08-06 09:54:09 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$mount_point" != "$quota_activation" ]
|
|
|
|
then
|
|
|
|
db_input critical alternc/quotauninstalled || true
|
|
|
|
db_go
|
2012-08-14 09:44:43 +00:00
|
|
|
db_reset alternc/quotauninstalled || true
|
2012-08-06 09:54:09 +00:00
|
|
|
db_fset alternc/quotauninstalled "seen" "false" || true
|
|
|
|
fi
|
|
|
|
|
2006-04-26 12:28:53 +00:00
|
|
|
db_get alternc/hostingname
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/hostingname "$HOSTING"
|
|
|
|
fi
|
|
|
|
|
|
|
|
db_get alternc/desktopname
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/desktopname "$FQDN"
|
|
|
|
fi
|
|
|
|
|
|
|
|
db_get alternc/public_ip
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/public_ip "$PUBLIC_IP"
|
|
|
|
fi
|
|
|
|
|
|
|
|
db_get alternc/internal_ip
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/internal_ip "$INTERNAL_IP"
|
|
|
|
fi
|
|
|
|
|
|
|
|
db_get alternc/monitor_ip
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/monitor_ip "$MONITOR_IP"
|
|
|
|
fi
|
|
|
|
|
|
|
|
db_get alternc/ns1
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/ns1 "$NS1_HOSTNAME"
|
|
|
|
fi
|
|
|
|
|
|
|
|
db_get alternc/ns2
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/ns2 "$NS2_HOSTNAME"
|
|
|
|
fi
|
|
|
|
|
|
|
|
db_get alternc/default_mx
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/default_mx "$DEFAULT_MX"
|
|
|
|
fi
|
|
|
|
|
2011-06-04 08:59:12 +00:00
|
|
|
db_get alternc/default_mx2
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/default_mx2 "$DEFAULT_SECONDARY_MX"
|
|
|
|
fi
|
|
|
|
|
2006-04-26 12:28:53 +00:00
|
|
|
db_get alternc/mysql/host
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/mysql/host "$MYSQL_HOST"
|
|
|
|
fi
|
|
|
|
|
|
|
|
db_get alternc/mysql/db
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/mysql/db "$MYSQL_DATABASE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
db_get alternc/mysql/user
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/mysql/user "$MYSQL_USER"
|
|
|
|
fi
|
|
|
|
|
|
|
|
db_get alternc/mysql/password
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/mysql/password "$MYSQL_PASS"
|
|
|
|
fi
|
|
|
|
|
|
|
|
db_get alternc/mysql/client
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/mysql/client "$MYSQL_CLIENT"
|
|
|
|
fi
|
|
|
|
|
2008-07-10 21:18:42 +00:00
|
|
|
db_get alternc/sql/backup_type
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/sql/backup_type "$SQLBACKUP_TYPE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
db_get alternc/sql/backup_overwrite
|
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/sql/backup_overwrite "$SQLBACKUP_OVERWRITE"
|
|
|
|
fi
|
|
|
|
|
2012-04-24 15:51:47 +00:00
|
|
|
db_get alternc/mysql/alternc_mail_user
|
2012-04-16 14:21:10 +00:00
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/mysql/alternc_mail_user "$MYSQL_MAIL_USER"
|
|
|
|
fi
|
|
|
|
|
2012-04-24 15:51:47 +00:00
|
|
|
db_get alternc/mysql/alternc_mail_password
|
2012-04-16 14:21:10 +00:00
|
|
|
if [ -z "$RET" ]
|
|
|
|
then
|
|
|
|
db_set alternc/mysql/alternc_mail_password "$MYSQL_MAIL_PASS"
|
|
|
|
fi
|
2006-04-26 12:28:53 +00:00
|
|
|
db_input medium alternc/desktopname || true
|
|
|
|
db_input medium alternc/hostingname || true
|
|
|
|
db_input medium alternc/internal_ip || true
|
|
|
|
db_input medium alternc/public_ip || true
|
|
|
|
db_input medium alternc/default_mx || true
|
|
|
|
db_input medium alternc/ns1 || true
|
|
|
|
db_input medium alternc/ns2 || true
|
2006-09-15 17:16:42 +00:00
|
|
|
db_input low alternc/alternc_location || true
|
2011-06-04 08:59:12 +00:00
|
|
|
db_input low alternc/default_mx2 || true
|
2006-04-26 12:28:53 +00:00
|
|
|
db_input low alternc/mysql/host || true
|
|
|
|
db_input low alternc/mysql/db || true
|
|
|
|
db_input low alternc/mysql/user || true
|
|
|
|
db_input low alternc/mysql/password || true
|
2012-04-16 14:21:10 +00:00
|
|
|
db_input low alternc/mysql/alternc_mail_password || true
|
|
|
|
db_input low alternc/mysql/alternc_mail_user || true
|
2007-11-15 02:53:04 +00:00
|
|
|
db_input low alternc/mysql/client || true
|
2008-07-10 22:02:38 +00:00
|
|
|
db_input low alternc/sql/backup_type || true
|
|
|
|
db_input low alternc/sql/overwrite || true
|
2006-04-26 12:28:53 +00:00
|
|
|
db_input low alternc/monitor_ip || true
|
2009-08-04 18:02:11 +00:00
|
|
|
db_input low alternc/slaves || true
|
2006-04-26 12:28:53 +00:00
|
|
|
db_go
|
|
|
|
|
|
|
|
# vim: et sw=4
|