2006-04-26 12:28:53 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Source debconf library.
|
|
|
|
. /usr/share/debconf/confmodule
|
|
|
|
|
|
|
|
CONFIGFILE="/etc/alternc/local.sh"
|
|
|
|
|
|
|
|
update_var() {
|
2008-10-04 20:45:38 +00:00
|
|
|
local question
|
|
|
|
local var
|
|
|
|
question="$1"
|
|
|
|
var="$2"
|
2006-04-26 12:28:53 +00:00
|
|
|
db_get "$question"
|
|
|
|
if [ ! -z "$RET" ]; then
|
|
|
|
grep -Eq "^ *$var=" $CONFIGFILE || echo "$var=" >> $CONFIGFILE
|
|
|
|
SED_SCRIPT="$SED_SCRIPT;s\\^ *$var=.*\\$var=\"$RET\"\\"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# summary of how this script can be called:
|
|
|
|
# * <postinst> `configure' <most-recently-configured-version>
|
|
|
|
# * <old-postinst> `abort-upgrade' <new version>
|
|
|
|
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
|
|
|
|
# <new-version>
|
|
|
|
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
|
|
|
|
# <failed-install-package> <version> `removing'
|
|
|
|
# <conflicting-package> <version>
|
|
|
|
# for details, see http://www.debian.org/doc/debian-policy/ or
|
|
|
|
# the debian-policy package
|
|
|
|
#
|
|
|
|
# quoting from the policy:
|
|
|
|
# Any necessary prompting should almost always be confined to the
|
|
|
|
# post-installation script, and should be protected with a conditional
|
|
|
|
# so that unnecessary prompting doesn't happen if a package's
|
|
|
|
# installation fails and the `postinst' is called with `abort-upgrade',
|
|
|
|
# `abort-remove' or `abort-deconfigure'.
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
configure)
|
|
|
|
|
2007-01-17 20:58:16 +00:00
|
|
|
# ajoute l'user postfix au groupe sasl
|
|
|
|
adduser --quiet postfix sasl
|
|
|
|
|
2008-04-10 19:30:59 +00:00
|
|
|
# corriger les permissions du chroot
|
|
|
|
mkdir -p /var/spool/postfix/var/run/saslauthd || true
|
|
|
|
dpkg-statoverride --quiet --update --add root sasl 710 /var/spool/postfix/var/run/saslauthd || true
|
|
|
|
|
2006-04-26 12:28:53 +00:00
|
|
|
# build local.sh if it does not exist
|
|
|
|
if [ ! -f $CONFIGFILE ]; then
|
|
|
|
cat > $CONFIGFILE <<EOF
|
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# AlternC - Web Hosting System - Configuration
|
|
|
|
# This file will be modified on package configuration
|
|
|
|
# (e.g. upgrade or dpkg-reconfigure alternc)
|
|
|
|
|
|
|
|
# Hosting service name
|
|
|
|
HOSTING=""
|
|
|
|
|
|
|
|
# Primary hostname for this box (will be used to access the management panel)
|
|
|
|
FQDN=""
|
|
|
|
|
|
|
|
# Public IP
|
|
|
|
PUBLIC_IP=""
|
|
|
|
|
|
|
|
# Internal IP
|
|
|
|
# (most of the time, should be equal to PUBLIC_IP, unless you are behind
|
|
|
|
# firewall doing address translation)
|
|
|
|
INTERNAL_IP=""
|
|
|
|
|
|
|
|
# Monitoring IP or network (will be allowed to access Apache status)
|
|
|
|
MONITOR_IP=""
|
|
|
|
|
|
|
|
# Primary DNS hostname
|
|
|
|
NS1_HOSTNAME=""
|
|
|
|
|
|
|
|
# Secondary DNS hostname
|
|
|
|
NS2_HOSTNAME=""
|
|
|
|
|
|
|
|
# Mail server hostname
|
|
|
|
DEFAULT_MX=""
|
|
|
|
|
2008-04-13 04:35:19 +00:00
|
|
|
# Note: MySQL username/password configuration now stored in /etc/alternc/my.cnf
|
|
|
|
|
2006-04-26 12:28:53 +00:00
|
|
|
# quels clients mysql sont permis (%, localhost, etc)
|
|
|
|
MYSQL_CLIENT=""
|
|
|
|
|
|
|
|
# Folder holding data (used for quota management)
|
|
|
|
ALTERNC_LOC=""
|
|
|
|
|
2008-07-10 21:18:42 +00:00
|
|
|
# the type of backup created by the sql backup script
|
|
|
|
# valid options are "rotate" (newsyslog-style) or "date" (suffix is the date)
|
|
|
|
SQLBACKUP_TYPE=""
|
|
|
|
|
|
|
|
# overwrite existing files when backing up
|
|
|
|
SQLBACKUP_OVERWRITE=""
|
2009-07-27 21:21:26 +00:00
|
|
|
|
|
|
|
# known slave servers, empty for none, localhost is special (no ssh)
|
|
|
|
ALTERNC_SLAVES=""
|
2006-04-26 12:28:53 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
chown root:www-data $CONFIGFILE
|
|
|
|
chmod 640 $CONFIGFILE
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Update local.sh
|
|
|
|
# 1. use cp to keep permissions
|
|
|
|
# 2. add missing variable to local.sh
|
|
|
|
# 3. use sed to set variables with current values
|
|
|
|
echo "Updating $CONFIGFILE"
|
|
|
|
cp -a -f $CONFIGFILE $CONFIGFILE.tmp
|
|
|
|
# SED_SCRIPT will be modified by update_var
|
|
|
|
SED_SCRIPT=""
|
|
|
|
update_var alternc/hostingname HOSTING
|
|
|
|
update_var alternc/desktopname FQDN
|
|
|
|
update_var alternc/public_ip PUBLIC_IP
|
|
|
|
update_var alternc/internal_ip INTERNAL_IP
|
|
|
|
update_var alternc/monitor_ip MONITOR_IP
|
|
|
|
update_var alternc/ns1 NS1_HOSTNAME
|
|
|
|
update_var alternc/ns2 NS2_HOSTNAME
|
|
|
|
update_var alternc/default_mx DEFAULT_MX
|
|
|
|
update_var alternc/mysql/client MYSQL_CLIENT
|
2008-07-10 21:18:42 +00:00
|
|
|
update_var alternc/sql/backup_type SQLBACKUP_TYPE
|
|
|
|
update_var alternc/sql/backup_overwrite SQLBACKUP_OVERWRITE
|
2006-04-26 12:28:53 +00:00
|
|
|
update_var alternc/alternc_location ALTERNC_LOC
|
2009-07-27 21:21:26 +00:00
|
|
|
update_var alternc/slaves ALTERNC_SLAVES
|
2006-04-26 12:28:53 +00:00
|
|
|
sed -e "$SED_SCRIPT" < $CONFIGFILE > $CONFIGFILE.tmp
|
|
|
|
mv -f $CONFIGFILE.tmp $CONFIGFILE
|
|
|
|
|
2008-04-13 04:35:19 +00:00
|
|
|
# Setup grants
|
|
|
|
db_get "alternc/mysql/host"
|
|
|
|
MYSQL_HOST="$RET"
|
|
|
|
if [ "$MYSQL_HOST" != "localhost" -o -e /usr/sbin/mysqld ]; then
|
|
|
|
# compatibility shims with my.cnf
|
|
|
|
host="$RET"
|
|
|
|
db_get "alternc/mysql/db"
|
|
|
|
database="$RET"
|
|
|
|
db_get "alternc/mysql/user"
|
|
|
|
user="$RET"
|
|
|
|
db_get "alternc/mysql/password"
|
|
|
|
password="$RET"
|
|
|
|
|
|
|
|
# we source (instead of forking) mysql.sh so that it gets the local environment above
|
|
|
|
. /usr/share/alternc/install/mysql.sh
|
|
|
|
fi
|
|
|
|
|
2011-03-27 11:19:54 +00:00
|
|
|
# We don't force seen or reset the data : this will allow preseeding
|
|
|
|
# db_reset alternc/mysql/password || true
|
|
|
|
# db_fset alternc/mysql/password "seen" "false" || true
|
2006-04-26 12:28:53 +00:00
|
|
|
|
|
|
|
if [ -e $CONFIGFILE ]; then
|
|
|
|
# source local.sh variables
|
|
|
|
. $CONFIGFILE
|
|
|
|
fi
|
|
|
|
|
2009-07-27 21:21:26 +00:00
|
|
|
# multi-server configuration: we create an alternc account with
|
|
|
|
# authorized keys. since this is the master, we do not give him a
|
|
|
|
# valid shell, but we still need the user for proper perms
|
2009-08-04 19:29:01 +00:00
|
|
|
if [ ! -z "$ALTERNC_SLAVES" ] && [ "$ALTERNC_SLAVES" != "localhost" ] ; then
|
2009-07-27 21:21:26 +00:00
|
|
|
if ! grep -q alternc /etc/passwd ; then
|
|
|
|
echo "Creating alternc account"
|
|
|
|
adduser --quiet --system --uid 342 --home $ALTERNC_LOC --shell /bin/false --ingroup adm alternc
|
|
|
|
fi
|
2009-08-04 20:16:23 +00:00
|
|
|
chown alternc /var/alternc
|
2009-08-04 19:29:01 +00:00
|
|
|
if [ -r ~root/.ssh/id_dsa.pub ]; then
|
|
|
|
key=`cat ~root/.ssh/id_dsa.pub`
|
|
|
|
if ! grep -q "$key" $ALTERNC_LOC/.ssh/authorized_keys ; then
|
|
|
|
echo "Authorizing root ssh key to access the common alternc account"
|
|
|
|
mkdir -p $ALTERNC_LOC/.ssh
|
|
|
|
echo "$key" >> $ALTERNC_LOC/.ssh/authorized_keys
|
|
|
|
chown -R alternc:adm $ALTERNC_LOC/.ssh
|
|
|
|
chmod -R og-rwx $ALTERNC_LOC/.ssh
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "No SSH key in "~root/.ssh/id_dsa.pub
|
|
|
|
echo "create one and reconfigure alternc to propagate SSH keys"
|
2009-07-27 21:21:26 +00:00
|
|
|
fi
|
2009-08-04 19:29:01 +00:00
|
|
|
else
|
|
|
|
echo "AlternC slaves not configured ($ALTERNC_SLAVES)"
|
2009-07-27 21:21:26 +00:00
|
|
|
fi
|
|
|
|
|
2008-10-04 20:25:03 +00:00
|
|
|
# /var/alternc/dns/d/www.example.com
|
|
|
|
FQDN_LETTER="`echo $FQDN | sed -e 's/.*\.\([^\.]\)[^\.]*\.[^\.]*$/\1/'`"
|
|
|
|
if [ "$FQDN_LETTER" = "$FQDN" ]
|
|
|
|
then
|
|
|
|
FQDN_LETTER="_"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Erase all apacheconf file
|
|
|
|
# They will be regenerated without the bug by upgrade_check.sh below.
|
|
|
|
if dpkg --compare-versions "$2" le "0.9.3.9-globenet14"; then
|
|
|
|
rm -f /var/alternc/apacheconf/*/*
|
|
|
|
fi
|
|
|
|
|
2006-04-26 12:28:53 +00:00
|
|
|
echo "checking for upgrades"
|
|
|
|
/usr/share/alternc/install/upgrade_check.sh $2
|
|
|
|
|
|
|
|
echo "config phpmyadmin"
|
2009-04-06 15:03:17 +00:00
|
|
|
# Mise à jour sur une configuration existante
|
|
|
|
# recherche la chaine include_str (avec les / echappées) et supprime les <?php ?>
|
2011-02-28 16:43:03 +00:00
|
|
|
# ${include_str//\//\\/}"'\) c'est uniquement BASH, on est en SH/DASH
|
|
|
|
include_str='include("/etc/alternc/phpmyadmin.inc.php")'
|
|
|
|
pma_config='/etc/phpmyadmin/config.inc.php'
|
|
|
|
bash -c "include_str='include(\"/etc/alternc/phpmyadmin.inc.php\")';pma_config='/etc/phpmyadmin/config.inc.php';sed 's/<?php \('\"\${include_str//\//\\/}\"'\) ?>/\1;/g' \$pma_config > \$pma_config'_2' && mv \$pma_config'_2' \$pma_config"
|
2009-04-06 15:03:17 +00:00
|
|
|
|
|
|
|
# Sur une configuration vierge, inclure la configuration alternc
|
2006-04-26 12:28:53 +00:00
|
|
|
if ! grep -e "$include_str" $pma_config > /dev/null 2>&1; then
|
2009-04-06 15:03:17 +00:00
|
|
|
echo "$include_str;" >> $pma_config
|
2006-04-26 12:28:53 +00:00
|
|
|
fi
|
|
|
|
|
2009-04-07 12:23:09 +00:00
|
|
|
#clean old access to the management panel
|
2011-03-27 11:19:54 +00:00
|
|
|
# We don't use this anymore : (FIXME : shall we remove /var/alternc/dns while upgrading ?)
|
|
|
|
#find /var/alternc/dns/ -type l -lname /var/alternc/bureau -exec rm {} \;
|
2009-04-07 12:23:09 +00:00
|
|
|
|
2008-10-04 20:25:03 +00:00
|
|
|
# Bind stuff
|
|
|
|
touch /var/alternc/bind/automatic.conf /var/alternc/bind/slaveip.conf
|
|
|
|
chown root:bind /var/alternc/bind/automatic.conf /var/alternc/bind/slaveip.conf
|
|
|
|
chmod 640 /var/alternc/bind/automatic.conf /var/alternc/bind/slaveip.conf
|
|
|
|
touch /var/run/alternc/refresh_slave
|
|
|
|
/usr/lib/alternc/slave_dns
|
|
|
|
# Apache will not start without this file
|
2011-01-28 15:55:26 +00:00
|
|
|
touch /var/alternc/apache-vhost/vhosts_all.conf
|
2008-10-04 20:25:03 +00:00
|
|
|
|
|
|
|
# Update l18n files
|
|
|
|
/usr/share/alternc/install/dopo.sh
|
|
|
|
|
2006-04-26 12:28:53 +00:00
|
|
|
# important: postinst gele sans ca
|
|
|
|
db_stop
|
|
|
|
|
|
|
|
echo "running alternc.install"
|
|
|
|
alternc.install
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "postinst called with unknown argument \`$1'" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
# dh_installdeb will replace this with shell code automatically
|
|
|
|
# generated by other debhelper scripts.
|
|
|
|
|
|
|
|
#DEBHELPER#
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
# vim: et sw=4
|