2011-01-28 15:55:26 +00:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
# functions.sh next-gen by Fufroma
|
2007-09-09 18:18:19 +00:00
|
|
|
|
|
2011-01-28 15:55:26 +00:00
|
|
|
|
# Init some vars
|
|
|
|
|
. /etc/alternc/local.sh
|
|
|
|
|
|
|
|
|
|
# Init some other vars
|
2011-01-29 15:12:26 +00:00
|
|
|
|
MYSQL_DO="/usr/bin/mysql --defaults-file=/etc/alternc/my.cnf -Bs -e "
|
2011-02-01 22:44:18 +00:00
|
|
|
|
mysql_query() { /usr/bin/mysql --defaults-file=/etc/alternc/my.cnf -Bs -e "$@" ; }
|
2011-01-28 15:55:26 +00:00
|
|
|
|
DOMAIN_LOG_FILE="/var/log/alternc/update_domains.log"
|
2011-01-29 15:46:33 +00:00
|
|
|
|
VHOST_FILE="$VHOST_DIR/vhosts_all.conf"
|
2011-01-28 15:55:26 +00:00
|
|
|
|
|
|
|
|
|
# Some usefull miscellaneous shell functions
|
2007-09-09 18:21:57 +00:00
|
|
|
|
print_domain_letter() {
|
|
|
|
|
local domain="$1"
|
|
|
|
|
|
|
|
|
|
local letter=`echo "$domain" | awk '{z=split($NF, a, ".") ; print substr(a[z-1], 1, 1)}'`
|
|
|
|
|
if [ -z "$letter" ]; then
|
|
|
|
|
letter="_"
|
|
|
|
|
fi
|
|
|
|
|
echo $letter
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print_user_letter() {
|
|
|
|
|
local user="$1"
|
|
|
|
|
echo "$user" | awk '{print substr($1, 1, 1)}'
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-09 18:18:19 +00:00
|
|
|
|
# imprime le nom d'usager associé au domaine
|
|
|
|
|
get_account_by_domain() {
|
2011-01-28 15:55:26 +00:00
|
|
|
|
# les admintools ne sont peut-être pas là
|
2011-01-29 15:12:26 +00:00
|
|
|
|
# if [ -x "/usr/bin/get_account_by_domain" ]
|
|
|
|
|
# then
|
|
|
|
|
# # only first field, only first line
|
|
|
|
|
# /usr/bin/get_account_by_domain "$1"|head -1|awk '{ print $1;}'
|
|
|
|
|
# else
|
2011-01-28 15:55:26 +00:00
|
|
|
|
# implantons localement ce que nous avons besoin, puisque admintools
|
|
|
|
|
# n'est pas là
|
2011-02-01 22:44:18 +00:00
|
|
|
|
mysql_query 'SELECT a.login FROM membres a, sub_domaines b WHERE a.uid = b.compte AND \
|
2011-01-28 15:55:26 +00:00
|
|
|
|
CONCAT(IF(sub="", "", CONCAT(sub, ".")), domaine) = "'"$1"'" LIMIT 1;'
|
2011-01-29 15:12:26 +00:00
|
|
|
|
# fi
|
2007-09-09 18:18:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-28 15:55:26 +00:00
|
|
|
|
log_error() {
|
|
|
|
|
local error=$1
|
|
|
|
|
echo "`date` $0 : $1" | tee -a "$DOMAIN_LOG_FILE" >&2
|
|
|
|
|
exit 1
|
2007-09-09 18:18:19 +00:00
|
|
|
|
}
|
|
|
|
|
|