2022-03-02 00:41:53 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# FICHIER SOUS CONTROLE D'ANSIBLE, NE PAS MODIFIER DIRECTEMENT
|
|
|
|
|
|
|
|
VHOSTS_DIR=/etc/apache2/vhosts.d/
|
|
|
|
MAINTENANCE_DIR=/var/www/html/rp_maintenance/
|
|
|
|
|
|
|
|
TMP=$(mktemp)
|
|
|
|
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
LISTE_VHOSTS=""
|
|
|
|
|
|
|
|
for i in $(ls $VHOSTS_DIR); do
|
|
|
|
LISTE_VHOSTS="$LISTE_VHOSTS $i"
|
2022-03-13 13:56:03 +01:00
|
|
|
if [ -f "$MAINTENANCE_DIR/$i.html" ]; then
|
2022-03-02 00:41:53 +01:00
|
|
|
LISTE_VHOSTS="$LISTE_VHOSTS (maintenance)"
|
|
|
|
else
|
|
|
|
LISTE_VHOSTS="$LISTE_VHOSTS (normal)"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo $LISTE_VHOSTS | xargs dialog --title "Gestion page de maintenance" --menu "Modifier le statut de maintenance du virtualhost :" 0 0 0 2> $TMP
|
|
|
|
ERR=$?
|
|
|
|
VHOST=$(cat $TMP)
|
|
|
|
rm $TMP
|
|
|
|
|
|
|
|
if [ "$ERR" == "0" ]; then
|
2022-03-13 13:56:03 +01:00
|
|
|
if [ -f "$MAINTENANCE_DIR/$VHOST.html" ]; then
|
|
|
|
rm $MAINTENANCE_DIR/$VHOST.html
|
2022-03-02 00:41:53 +01:00
|
|
|
else
|
2022-03-13 13:56:03 +01:00
|
|
|
ln -s $MAINTENANCE_DIR/maintenance-generique.html $MAINTENANCE_DIR/$VHOST.html
|
2022-03-02 00:41:53 +01:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
done
|