Changement du chemin de stockage de la conf apache.

Au lieu de stocker dans /var/alternc/apache-vhost/a/admin/www.machin.conf
On stock dans /var/alternc/apache-vhost/2/2000/www.machin.conf

Permet de résoudre le probleme de non suppression de conf apache à la 
suppression d'un membre

TODO : le backporter en 1.0.4 une fois validé.
This commit is contained in:
Alan Garcia 2012-10-15 14:20:38 +00:00
parent f2585792c6
commit cedce69efe
6 changed files with 67 additions and 10 deletions

2
.gitattributes vendored
View File

@ -513,6 +513,7 @@ install/upgrades/0.9.7.sql -text
install/upgrades/0.9.9.sql -text install/upgrades/0.9.9.sql -text
install/upgrades/1.0.1.php -text install/upgrades/1.0.1.php -text
install/upgrades/1.0.3.sql -text install/upgrades/1.0.3.sql -text
install/upgrades/1.0.4.sh -text
install/upgrades/1.0.sql -text install/upgrades/1.0.sql -text
install/upgrades/1.1.php -text install/upgrades/1.1.php -text
install/upgrades/1.1.sh -text install/upgrades/1.1.sh -text
@ -578,6 +579,7 @@ src/quota_delete -text
src/quota_edit -text src/quota_edit -text
src/quota_get -text src/quota_get -text
src/quota_init -text src/quota_init -text
src/rebuild_all_webconf.sh -text
src/sendmail -text src/sendmail -text
src/slave_dns -text src/slave_dns -text
src/spoolsize.php -text src/spoolsize.php -text

4
install/upgrades/1.0.4.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
# Rebuild all web configuration
/usr/lib/alternc/rebuild_all_webconf.sh --force

View File

@ -20,7 +20,7 @@
# Purpose of file: Makefile des binaires de /usr/lib/alternc # Purpose of file: Makefile des binaires de /usr/lib/alternc
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
SETUID=quota_edit quota_get mem_add mem_del du.pl SETUID=quota_edit quota_get mem_add mem_del du.pl
SCRIPTS=sqlbackup.sh quota_init quota_delete update_domains.sh slave_dns sendmail spoolsize.php fixperms.sh alternc-dboptimize export_account.php cron_users_doit.sh cron_users.sh compress_logs.sh delete_logs.sh quota-warning.sh update_mails.sh alternc_add_policy_dovecot SCRIPTS=sqlbackup.sh quota_init quota_delete update_domains.sh slave_dns sendmail spoolsize.php fixperms.sh alternc-dboptimize export_account.php cron_users_doit.sh cron_users.sh compress_logs.sh delete_logs.sh quota-warning.sh update_mails.sh alternc_add_policy_dovecot rebuild_all_webconf.sh
LIBS=functions.sh functions_hosting.sh functions_dns.sh LIBS=functions.sh functions_hosting.sh functions_dns.sh
BIN=$(DESTDIR)/usr/lib/alternc/ BIN=$(DESTDIR)/usr/lib/alternc/

View File

@ -31,6 +31,7 @@ MYSQL_DO="/usr/bin/mysql --defaults-file=/etc/alternc/my.cnf -Bs -e "
mysql_query() { /usr/bin/mysql --defaults-file=/etc/alternc/my.cnf -Bs -e "$@" ; } mysql_query() { /usr/bin/mysql --defaults-file=/etc/alternc/my.cnf -Bs -e "$@" ; }
DOMAIN_LOG_FILE="/var/log/alternc/update_domains.log" DOMAIN_LOG_FILE="/var/log/alternc/update_domains.log"
VHOST_FILE="$VHOST_DIR/vhosts_all.conf" VHOST_FILE="$VHOST_DIR/vhosts_all.conf"
VHOST_MANUALCONF="$VHOST_DIR/manual/"
# Some useful miscellaneous shell functions # Some useful miscellaneous shell functions
@ -67,6 +68,10 @@ get_account_by_domain() {
CONCAT(IF(sub="", "", CONCAT(sub, ".")), domaine) = "'"$1"'" LIMIT 1;' CONCAT(IF(sub="", "", CONCAT(sub, ".")), domaine) = "'"$1"'" LIMIT 1;'
} }
get_uid_by_domain() {
mysql_query 'SELECT b.compte as uid FROM sub_domaines b WHERE \
CONCAT(IF(sub="", "", CONCAT(sub, ".")), domaine) = "'"$1"'" LIMIT 1;'
}
# Log (echoes+log) an error and exit the current script with an error. # Log (echoes+log) an error and exit the current script with an error.
log_error() { log_error() {

View File

@ -29,6 +29,15 @@ launch_hooks() {
return 0 return 0
} }
host_conffile() {
# Return the absolute path of a conf file for a FQDN
local FQDN="$1"
local U_ID=$(get_uid_by_domain "$FQDN")
local CONFFILE="$VHOST_DIR/${U_ID:0:1}/$U_ID/$FQDN.conf"
echo $CONFFILE
return 0
}
host_create() { host_create() {
# Function to create a vhost for a website # Function to create a vhost for a website
# First, it look if there is a special file for # First, it look if there is a special file for
@ -56,13 +65,13 @@ host_create() {
local MAIL_ACCOUNT=$3 local MAIL_ACCOUNT=$3
local REDIRECT=$4 # Yes, TARGET_DIR and REDIRECT are the same local REDIRECT=$4 # Yes, TARGET_DIR and REDIRECT are the same
local TARGET_DIR=$4 # It's used by different template local TARGET_DIR=$4 # It's used by different template
local U_ID=$(get_uid_by_domain "$FQDN")
local G_ID="$U_ID"
local USER=$(get_account_by_domain $FQDN) local USER=$(get_account_by_domain $FQDN)
local U_ID=$(get_uid_by_name "$USER")
local G_ID=$(get_uid_by_name "$USER")
local user_letter=`print_user_letter "$USER"` local user_letter=`print_user_letter "$USER"`
local DOCUMENT_ROOT="${HTML_HOME}/${user_letter}/${USER}$TARGET_DIR" local DOCUMENT_ROOT="${HTML_HOME}/${user_letter}/${USER}$TARGET_DIR"
local ACCOUNT_ROOT="${HTML_HOME}/${user_letter}/${USER}/" local ACCOUNT_ROOT="${HTML_HOME}/${user_letter}/${USER}/"
local FILE_TARGET="$VHOST_DIR/${user_letter}/$USER/$FQDN.conf" local FILE_TARGET=$(host_conffile "$FQDN")
# In case VTYPE don't have the same name as the template file, # In case VTYPE don't have the same name as the template file,
# here we can define it # here we can define it
@ -150,9 +159,7 @@ host_change_enable() {
local TYPE=$2 # no use here, but one day, maybe... So here he is local TYPE=$2 # no use here, but one day, maybe... So here he is
local FQDN=$3 local FQDN=$3
local USER=$(get_account_by_domain $FQDN) local FENABLED=$(host_conffile "$FQDN")
local user_letter=`print_user_letter "$USER"`
local FENABLED="$VHOST_DIR/${user_letter}/$USER/$FQDN.conf"
local FDISABLED="$FENABLED-disabled" local FDISABLED="$FENABLED-disabled"
case $STATE in case $STATE in
@ -189,9 +196,7 @@ host_delete() {
return $? return $?
fi fi
local USER=`get_account_by_domain $FQDN` local FENABLED=$(host_conffile "$FQDN")
local user_letter=`print_user_letter "$USER"`
local FENABLED="$VHOST_DIR/${user_letter}/$USER/$FQDN.conf"
local FDISABLED="$FENABLED-disabled" local FDISABLED="$FENABLED-disabled"
[ -w "$FENABLED" ] && rm -f "$FENABLED" [ -w "$FENABLED" ] && rm -f "$FENABLED"

41
src/rebuild_all_webconf.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash
# Get some vars
. /usr/lib/alternc/functions_hosting.sh
if [ -z "$VHOST_DIR" ] ; then
echo "Problem: No VHOST_DIR var"
exit 2
fi
echo "This script empty the $VHOST_DIR directory"
echo "and rebuild all web configuration."
echo ""
echo "Only files in $VHOST_MANUALCONF will be preserved."
echo "Use --force to skip confirmation"
echo ""
if [ ! "$1" == "--force" ] ; then
read -n1 -p "Continue (y/n)? "
[[ $REPLY = [yY] ]] || exit 1
fi
echo ""
echo "++ Start rebuilding ++"
echo "Delete old configuration"
# [a-z_] for old storage schema (1.0)
for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z _ ; do
test -d "$VHOST_DIR/$i" && rm -rf "$VHOST_DIR/$i/"
done
test -f "$VHOST_FILE" && rm -f "$VHOST_FILE"
echo "Deleting complete"
echo "Set flag to rebuild"
mysql_query "update sub_domaines set web_action = 'UPDATE';"
echo "Launch update_domains to rebuild."
/usr/lib/alternc/update_domains.sh
echo "Finish."