#1 Le 08/07/2019, à 14:39
- marcelopop
[RESOLU] utiliser une liste pour crées des virtualhost automatiquement
salut tout le monde je suis bloqué je ne sais pas comment faire je dois lire un fichier et créer des virtualhost automatiquement voila mon script. j’implore votre aide
list=$(cat litdom.txt)
for i in $list ; do
jfhdomaine=
ddomaine=
touch /home/test/$jfhdomaine.conf
echo "<VirtualHost *:80>
ServerAdmin mail@linux.com
ServerName $jfdomain
DocumentRoot $ddomaine
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin mail@linux.com
ServerName $jfhdomain
DocumentRoot $ddomain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>" > /home/test/$jfdomaine.conf
a2ensite $jfhdomaine.conf
done
mon fichier texte est structuré comme ceci:
nom de domaine
directory
ligne vide
nom de domaine
directory
ligne vide
klml.freeware.com/
/var/www/html/viaja
linux.freeware.com/
/var/www/html/nicho/
vida.freeware.com/
/var/www/html/free/
Merci d'avance pour vos pistes
Dernière modification par marcelopop (Le 08/07/2019, à 17:03)
Hors ligne
#2 Le 08/07/2019, à 16:51
- marcelopop
Re : [RESOLU] utiliser une liste pour crées des virtualhost automatiquement
cat NEW.txt | xargs -L 2 | while read line; do
jfhdomaine=`echo $line | awk '{ print $1 }'`
ddomaine=`echo $line | awk '{ print $2 }'`
Merci pour votre aide ^^
Hors ligne