Modification of package config script

This commit is contained in:
Steven Mondji-Lerider 2012-09-19 12:09:36 +00:00
parent 9d5794a83f
commit d1caf4a275
3 changed files with 152 additions and 29 deletions

140
debian/alternc.config vendored
View File

@ -1,6 +1,7 @@
#! /bin/sh
set -e
# Source debconf library.
. /usr/share/debconf/confmodule
db_title AlternC
@ -18,10 +19,6 @@ if [ "$RET" = "false" ]; then
exit 1
fi
db_input critical alternc/warningaclquota || true
# default values for local.sh
MYSQL_HOST=127.0.0.1
MYSQL_DATABASE=alternc
@ -45,6 +42,54 @@ if [ -r /etc/alternc/local.sh ]; then
# source the current config
. /etc/alternc/local.sh
fi
#We ask for the hosting name and the FQDN
db_set alternc/hostingname "$HOSTING"
db_set alternc/desktopname "$FQDN"
db_input high alternc/hostingname || true
db_input high alternc/desktopname || true
db_go || true
#we ask for the public and private ip
db_set alternc/public_ip "$PUBLIC_IP"
STATE=0
while [ $STATE -eq 0 ]; do
db_input high alternc/public_ip || true
db_go
db_get alternc/public_ip
ip=$RET
if [ $(echo $ip |egrep '(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1)$') ]; then
db_input high alternc/use_private_ip || true
db_go
db_get alternc/use_private_ip
if [ "$RET" = "true" ]; then
STATE=1
fi
else
STATE=1
fi
done
#private IP
db_set alternc/internal_ip "$INTERNAL_IP"
db_input high alternc/internal_ip || true
db_go
#We ask for the DNS server for the ip
#
db_set alternc/ns1 "$NS1_HOSTNAME"
db_input high alternc/ns1 || true
db_go
db_set alternc/ns1 "$NS2_HOSTNAME"
db_input high alternc/ns2 || true
db_go
#default mail server
db_set alternc/default_mx "$DEFAULT_MX"
db_input high alternc/default_mx || true
db_go
if [ -r /etc/alternc/my.cnf ]; then
# make mysql configuration available as shell variables
# to convert from .cnf to shell syntax, we:
@ -67,7 +112,64 @@ if [ -r /etc/alternc/my_mail.cnf ]; then
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
# mettre les valeurs de local.sh comme "default" pour debconf
#checking mysql connectivity and updating local.sh variables accordingly
check_mysql(){
STATE=0
while [ "$STATE" -eq 0 ]; do
db_input high alternc/mysql/host || true
db_go
db_get alternc/mysql/host || true
MYSQL_HOST="$RET"
db_input high alternc/mysql/user || true
db_go
db_get alternc/mysql/user || true
MYSQL_USER="$RET"
db_input high alternc/mysql/password || true
db_go
db_get alternc/mysql/password || true
MYSQL_PASSWORD="$RET"
db_input high alternc/mysql/client || true
db_go
db_get alternc/mysql/client || true
MYSQL_CLIENT="$RET"
if [ "`mysql -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" -h"$MYSQL_HOST" -Bse 'SELECT "OK";' 2>/dev/null`" = "OK" ]; then
STATE=`expr $STATE + 1`
else
db_input high alternc/remote_mysql_error || true
db_go
db_get alternc/remote_mysql_error || true
if [ "$RET" = "false" ]; then
exit 1
fi
fi
done
}
if [ "`mysql --defaults-file=/etc/mysql/debian.cnf -Bse 'SELECT "OK";' 2>/dev/null`" = "OK" ]; then
db_input critical alternc/use_local_mysql || true
db_go
db_get alternc/use_local_mysql || true
if [ "$RET" = "false" ]; then
#user want to use a remote server
check_mysql
fi
else
db_input critical alternc/use_remote_mysql || true
db_go
db_get alternc/use_remote_mysql || true
if [ "$RET" = "true" ]; then
#user want to use a remote server
check_mysql
fi
fi
# We need to check the alternc_location here because we have to test for quotas and acls
db_input low alternc/alternc_location || true
db_go
db_get alternc/alternc_location
if [ -z "$RET" ]
then
@ -75,14 +177,15 @@ db_set alternc/alternc_location "$ALTERNC_LOC"
fi
db_get alternc/alternc_location
#checking acl and quota activation, does't work with NFS yet. and with LXC too...
location=$RET
mount_point=`df -P $location | tail -1 | /usr/bin/awk '{print $NF}'`
quota_activation=`(quotaon -pa 2>/dev/null || true) |grep '^group.*on$' | /usr/bin/awk '$4 ~ /^\'$mount_point'$/ {print $4}'`
acl_activation=`/bin/mount | awk '$NF ~ /acl/ && $NF !~ /noacl/ && $3 ~ /^\'"$mount_point"'$/ {print $3}'`
LOCATION="$RET"
#checking acl and quota activation, does't work with NFS yet. should now work with lxc
MOUNT_POINT=$(df -P ${LOCATION%/*} | tail -n 1 | awk '{print $6}')
# Get the mount options for the path:$
MOUNT_OPTS=$(awk '$2=="'$MOUNT_POINT'" { print $4 }' /proc/mounts)
# Check to see if acl is one of the mount points:$
echo $MOUNT_OPTS | tr , \\\n | grep -q '^acl$'
if [ "$mount_point" != "$acl_activation" ]
then
if [ $(echo $MOUNT_OPTS | tr , \\\n | grep '^acl$' 2>/dev/null) != 'acl' ]; then
db_input critical alternc/acluninstalled || true
db_go
# db_reset alternc/acluninstalled || true
@ -90,8 +193,8 @@ then
# exit 1
fi
if [ "$mount_point" != "$quota_activation" ]
then
if [ $(quotaon -pa 2>/dev/null |grep '^group.*on$' | /usr/bin/awk '$4 ~ /^\'$MOUNT_POINT'$/ {print $4}') != "$MOUNT_POINT" ]; then
db_input critical alternc/quotauninstalled || true
db_go
db_reset alternc/quotauninstalled || true
@ -205,14 +308,7 @@ if [ -z "$RET" ]
then
db_set alternc/mysql/alternc_mail_password "$MYSQL_MAIL_PASS"
fi
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
db_input low alternc/alternc_location || true
db_input low alternc/default_mx2 || true
db_input low alternc/mysql/host || true
db_input low alternc/mysql/db || true

9
debian/changelog vendored
View File

@ -1,3 +1,12 @@
alternc (1.1+nmu5) stable; urgency=low
* Modification in alternc package config script.
* Order of questions changed
* Check the public IP address according to RFC 1918
* checking SQL connectivity ( different procedure for local and remote server )
-- squidly <squidly@nnx.com> Tue, 19 Sep 2012 13:47:47 +0200
alternc (1.1+nmu4) stable; urgency=low
* SQL Modification

28
debian/templates vendored
View File

@ -76,11 +76,8 @@ _Description: Name of the secondary domain name server:
Template: alternc/mysql/host
Type: string
_Description: Name of the mysql server:
Please enter the fully qualified name of your mysql server host. On small
systems, it IS "localhost" since you may have installed a local mysql
server. If you are a bigger hosting service, you may put your mysql
service on a remote synchronized ring or equivalent. In that case, please
enter the hostname of your mysql server. This server MUST be able to
Please enter the fully qualified name of your mysql server host.
This server MUST be able to
access the remote server at standard port (3306). It is recommended to use
"127.0.0.1" instead of "localhost" if your postfix installation is
configured in a chroot (which is the case, by default).
@ -231,3 +228,24 @@ _Description: Slave servers
the master server will attempt to reload apache on those remote
servers. The alternc-slave package correctly configures those machines
to allow login and reload.
Template: alternc/use_local_mysql
Type: boolean
_Description:
A local MySQL connexion was established on the server. Do you Want to Use it, or do you prefer to use a remote server ?
Template: alternc/use_remote_mysql
Type: boolean
_Description:
No local Mysql server was found. Do you want to use a remote Mysql Server or abort the installation.
Template: alternc/remote_mysql_error
Type: boolean
_Description:
Remote connection failed. Do you want to try again ?
Template: alternc/use_private_ip
Type: boolean
_Description:
The ip appears to be private, do you want to use it anyway ? The server might not be reachable from outside your network.