From 8e15676d0519613a84474dd0e6fba110015a60ec Mon Sep 17 00:00:00 2001 From: William Hirigoyen Date: Fri, 10 Nov 2023 11:11:52 +0100 Subject: [PATCH] Improve op_del improvement --- scripts/web-add.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/web-add.sh b/scripts/web-add.sh index 2230071..224b2b1 100755 --- a/scripts/web-add.sh +++ b/scripts/web-add.sh @@ -766,7 +766,9 @@ op_del() { # Deactivate web vhost (apache or nginx) if [ "$WEB_SERVER" == "apache" ]; then - a2dissite "${login}.conf" || true + if a2query -s test12 >/dev/null 2&>1; then + a2dissite "${login}.conf" + fi rm -f /etc/apache2/sites-available/"$login.conf" apache2ctl configtest @@ -809,18 +811,22 @@ op_del() { if [ "$WEB_SERVER" == "apache" ]; then if id www-"$login" &> /dev/null; then - userdel -f www-"$login" || true + userdel -f www-"$login" fi for php_version in "${PHP_VERSIONS[@]}"; do - if lxc-attach -n php"${php_version}" -- id www-"$login" &> /dev/null; then - lxc-attach -n php"${php_version}" -- userdel -f www-"$login" || true + if lxc-attach -n php"${php_version}" -- getent passwd www-"$login" &> /dev/null; then + lxc-attach -n php"${php_version}" -- userdel -f www-"$login" + fi + if lxc-attach -n php"${php_version}" -- getent passwd "$login" &> /dev/null; then + lxc-attach -n php"${php_version}" -- userdel -f "$login" fi - lxc-attach -n php"${php_version}" -- userdel -f "$login" || true done fi - userdel -f "$login" || true + if getent passwd "$login" &> /dev/null; then + userdel -f "$login" + fi sed -i.bak "/^$login:/d" /etc/aliases if [ "$WEB_SERVER" == "apache" ]; then