add parameter to force remove profile

This commit is contained in:
giotto 2020-07-11 21:38:11 +02:00 committed by GitHub
parent b2ab7fc862
commit c1dc825ace
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,11 +12,12 @@ source "${setupVars}"
helpFunc(){ helpFunc(){
echo "::: Remove a client conf profile" echo "::: Remove a client conf profile"
echo ":::" echo ":::"
echo "::: Usage: pivpn <-r|remove> [-h|--help] [<client-1>] ... [<client-n>] ..." echo "::: Usage: pivpn <-r|remove> [-f|--force] [-h|--help] [<client-1>] ... [<client-n>] ..."
echo ":::" echo ":::"
echo "::: Commands:" echo "::: Commands:"
echo "::: [none] Interactive mode" echo "::: [none] Interactive mode"
echo "::: <client> Client(s) to remove" echo "::: <client> Client(s) to remove"
echo "::: -f,--force Remove Client(s) without confirmation"
echo "::: -h,--help Show this help dialog" echo "::: -h,--help Show this help dialog"
} }
@ -29,6 +30,9 @@ do
helpFunc helpFunc
exit 0 exit 0
;; ;;
-f|--force)
FORCE=true
;;
*) *)
CLIENTS_TO_REMOVE+=("$1") CLIENTS_TO_REMOVE+=("$1")
;; ;;
@ -68,7 +72,11 @@ for CLIENT_NAME in "${CLIENTS_TO_REMOVE[@]}"; do
echo -e "::: \e[1m${CLIENT_NAME}\e[0m does not exist" echo -e "::: \e[1m${CLIENT_NAME}\e[0m does not exist"
else else
REQUESTED="$(sha256sum "configs/${CLIENT_NAME}.conf" | cut -c 1-64)" REQUESTED="$(sha256sum "configs/${CLIENT_NAME}.conf" | cut -c 1-64)"
read -r -p "Do you really want to delete $CLIENT_NAME? [Y/n] " if [ -n "$FORCE" ]; then
REPLY="y"
else
read -r -p "Do you really want to delete $CLIENT_NAME? [Y/n] "
fi
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then