From 794defa907820e2bac768a2d2b16b3ddc6a3ab6e Mon Sep 17 00:00:00 2001 From: Nicolas Roman Date: Thu, 21 Mar 2019 10:01:58 +0100 Subject: [PATCH] retrieve first ServerName and change it with the new one in all the conf file --- scripts/web-add.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/web-add.sh b/scripts/web-add.sh index 6a817e7..57ef87a 100755 --- a/scripts/web-add.sh +++ b/scripts/web-add.sh @@ -814,9 +814,9 @@ op_servernameupdate() { if [ $# -eq 2 ]; then vhost="${1}.conf" servername=$2 - old_servername=$(grep ServerName $VHOST_PATH/"$vhost" | awk '{print $2;}') - - [ -f $VHOST_PATH/"$vhost" ] && sed -i "s/ServerName .*/ServerName $servername/" $VHOST_PATH/"$vhost" --follow-symlinks \ + old_servername=$(grep ServerName $VHOST_PATH/"$vhost" | awk '{print $2;}' | head -n1) + # Remplacement de toutes les directives ServerName, on assume qu'il s'agit du même pour chaque vhost du fichier + [ -f $VHOST_PATH/"$vhost" ] && sed -i "s/ServerName .*/ServerName $servername/g" $VHOST_PATH/"$vhost" --follow-symlinks \ && sed -i "/^ *RewriteCond/ s/$old_servername/$servername/g" $VHOST_PATH/"$vhost" --follow-symlinks apache2ctl configtest 2>/dev/null