added force-confirm option for del script

This commit is contained in:
Nicolas Roman 2019-04-05 10:49:23 +02:00
parent 7a0d307f23
commit ad3c31fb96

View file

@ -100,12 +100,18 @@ add [ [OPTIONS] LOGIN WWWDOMAIN ]
Example : web-add.sh add -m testdb -r 56 testlogin testdomain.com Example : web-add.sh add -m testdb -r 56 testlogin testdomain.com
del LOGIN [DBNAME] del [ [OPTIONS] LOGIN [DBNAME] ]
Delete account and all files related (Apache, Awstats, etc) Delete account and all files related (Apache, Awstats, etc)
Archive home directory. Archive home directory.
Remove MySQL database only if DBNAME is specified. Remove MySQL database only if DBNAME is specified.
-y
Don't ask for confirmation
Example : web-add.sh del -y testlogin testdatabase
list-vhost LOGIN list-vhost LOGIN
List Apache vhost for user LOGIN List Apache vhost for user LOGIN
@ -642,7 +648,50 @@ op_del() {
fi fi
fi fi
echo -n "Continuer la suppression du compte $login ? [y/N] : " #
# Mode non interactif
#
else
while getopts hy opt; do
case "$opt" in
y)
force_confirm=1
;;
h)
usage
exit 1
;;
?)
usage
exit 1
;;
esac
done
shift $((OPTIND - 1))
if [ $# -gt 0 ] && [ $# -le 2 ]; then
login=$1
if [ $# -eq 2 ]; then
dbname=$2
fi
else
usage
exit 1
fi
fi
echo
echo "----------------------------------------------"
echo "Nom du compte : $login"
if [ "$dbname" ]; then
echo "Base de données MySQL : $dbname"
fi
echo "----------------------------------------------"
echo
if [ -z "$force_confirm" ]; then
echo -n "Confirmer la suppression ? [y/N] : "
read -r tmp read -r tmp
echo echo
if [ "$tmp" != "y" ] && [ "$tmp" != "Y" ]; then if [ "$tmp" != "y" ] && [ "$tmp" != "Y" ]; then
@ -650,19 +699,6 @@ op_del() {
echo echo
exit 1 exit 1
fi fi
#
# Mode non interactif
#
elif [ $# -gt 0 ] && [ $# -le 2 ]; then
login=$1
if [ $# -eq 2 ]; then
dbname=$2
fi
else
usage
exit 1
fi fi
set -x set -x