Optimisation de la concatenation des fichiers de conf apache (merci Dom)
Reecriture de la fonction print_domain_letter pour eviter de systematiquement lancer un process awk
This commit is contained in:
parent
f402a5fcc0
commit
4f88df0342
|
@ -12,13 +12,23 @@ VHOST_FILE="$VHOST_DIR/vhosts_all.conf"
|
|||
|
||||
# Some usefull miscellaneous shell functions
|
||||
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
|
||||
# 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
|
||||
local domain=$1
|
||||
domain=${domain/.${domain/*./}/}
|
||||
domain=${domain/*./}
|
||||
domain=${domain:0:1}
|
||||
# Bash match un é quand on lui donne [a-z]. Etrange
|
||||
if [[ "$domain" =~ [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0-9]{1} ]]; then
|
||||
echo $domain
|
||||
else
|
||||
echo '_'
|
||||
fi
|
||||
}
|
||||
|
||||
print_user_letter() {
|
||||
|
|
|
@ -123,7 +123,7 @@ if [ ! -z "$(cat "$RELOAD_WEB")" ] ; then
|
|||
|
||||
# Concat the apaches files
|
||||
tempo=$(mktemp "$VHOST_FILE.XXXXX")
|
||||
find "$VHOST_DIR" -mindepth 2 -type f -iname "*.conf" -exec cat '{}' > "$tempo" \;
|
||||
find "$VHOST_DIR" -mindepth 2 -type f -iname "*.conf" -print0 | xargs -0 cat > "$tempo"
|
||||
if [ $? -ne 0 ] ; then
|
||||
log_error " web file concatenation failed"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue