ansible-role-reverse_proxy/files/maintenance.sh
2022-03-13 13:56:03 +01:00

37 lines
874 B
Bash
Executable file

#!/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"
if [ -f "$MAINTENANCE_DIR/$i.html" ]; then
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
if [ -f "$MAINTENANCE_DIR/$VHOST.html" ]; then
rm $MAINTENANCE_DIR/$VHOST.html
else
ln -s $MAINTENANCE_DIR/maintenance-generique.html $MAINTENANCE_DIR/$VHOST.html
fi
else
exit
fi
done