Test if user www-login exists before deleting (else, the deletion fails)

This commit is contained in:
William Hirigoyen (Evolix) 2021-12-02 10:16:12 +01:00
parent 0709747a1e
commit 5cd6a6f046

View file

@ -730,11 +730,15 @@ op_del() {
set -x
if [ "$WEB_SERVER" == "apache" ]; then
userdel -f www-"$login"
if id www-"$login" &> /dev/null; then
userdel -f www-"$login"
fi
fi
userdel -f "$login"
for php_version in "${PHP_VERSIONS[@]}"; do
lxc-attach -n php"${php_version}" -- userdel -f www-"$login"
if lxc-attach -n php"${php_version}" -- id www-"$login" &> /dev/null; then
lxc-attach -n php"${php_version}" -- userdel -f www-"$login"
fi
lxc-attach -n php"${php_version}" -- userdel -f "$login"
done
sed -i.bak "/^$login:/d" /etc/aliases