2015-08-25 16:54:13 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#
|
2017-08-23 14:19:48 +02:00
|
|
|
# Gestion des comptes web et des hôtes virtuels pour Apache et Nginx
|
2015-08-25 16:54:13 +02:00
|
|
|
#
|
2017-08-23 14:19:48 +02:00
|
|
|
# Copyright (c) 2009-2017 Evolix - Tous droits reserves
|
2015-08-25 16:54:13 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
# TODO
|
|
|
|
# - Gestion des quota
|
|
|
|
# - Possibilité de créer un compte FTP-only
|
|
|
|
# - Pouvoir spécifier le CONTACT_MAIL dans un fichier de conf
|
|
|
|
# - Traduire usage() en francais, ou l'inverse ??
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
HOME="/root"
|
2015-08-31 15:17:10 +02:00
|
|
|
CONTACT_MAIL="jdoe@example.org"
|
|
|
|
WWWBOUNCE_MAIL="jdoe@example.org"
|
2015-11-28 22:59:36 +01:00
|
|
|
SCRIPTS_PATH="/usr/share/scripts/evoadmin"
|
|
|
|
LOCAL_SCRIPT="$SCRIPTS_PATH/web-add.local.sh"
|
|
|
|
PRE_LOCAL_SCRIPT="$SCRIPTS_PATH/web-add.pre-local.sh"
|
|
|
|
TPL_AWSTATS="$SCRIPTS_PATH/awstats.XXX.conf"
|
2018-04-20 11:20:06 +02:00
|
|
|
SSH_GROUP="evolinux-ssh"
|
2017-08-23 14:19:48 +02:00
|
|
|
|
|
|
|
# Set to nginx if you use nginx and not apache
|
|
|
|
WEB_SERVER="apache"
|
|
|
|
if [ "$WEB_SERVER" == "apache" ]; then
|
2018-11-22 16:28:24 +01:00
|
|
|
VHOST_PATH="/etc/apache2/sites-available"
|
2017-08-23 14:19:48 +02:00
|
|
|
TPL_VHOST="$SCRIPTS_PATH/vhost"
|
|
|
|
TPL_MAIL="$SCRIPTS_PATH/web-mail.tpl"
|
|
|
|
|
|
|
|
elif [ "$WEB_SERVER" == "nginx" ]; then
|
|
|
|
VHOST_PATH="/etc/nginx/sites-available"
|
|
|
|
TPL_VHOST="$SCRIPTS_PATH/vhost-nginx.tpl"
|
|
|
|
TPL_MAIL="$SCRIPTS_PATH/web-mail-nginx.tpl"
|
|
|
|
else
|
|
|
|
echo "$WEB_SERVER is not apache nor nginx, exiting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# FPM
|
|
|
|
FPM_PATH="/etc/php/7.0/fpm/pool.d"
|
|
|
|
FPM_SERVICE_NAME="php7.0-fpm"
|
|
|
|
TPL_FPM="$SCRIPTS_PATH/fpm.conf.tpl"
|
|
|
|
|
2015-08-25 16:54:13 +02:00
|
|
|
MAX_LOGIN_CHAR=16
|
|
|
|
HOME_DIR="/home"
|
|
|
|
MYSQL_CREATE_DB_OPTS=""
|
2017-08-22 23:19:51 +02:00
|
|
|
MYSQL_OPTS=""
|
|
|
|
PHP_VERSIONS=()
|
2015-08-25 16:54:13 +02:00
|
|
|
|
|
|
|
# Utiliser ce fichier pour redefinir la valeur des variables ci-dessus
|
2015-12-23 15:39:50 +01:00
|
|
|
config_file="/etc/evolinux/web-add.conf"
|
2018-10-16 20:10:02 +02:00
|
|
|
# shellcheck source=/etc/evolinux/web-add.conf
|
2015-08-25 16:54:13 +02:00
|
|
|
[ -r $config_file ] && . $config_file
|
|
|
|
|
|
|
|
usage() {
|
2017-08-20 04:31:00 +02:00
|
|
|
cat <<EOT >&2
|
2015-08-25 16:54:13 +02:00
|
|
|
|
|
|
|
Usage: $0 COMMAND [ARG]
|
|
|
|
|
|
|
|
add [ [OPTIONS] LOGIN WWWDOMAIN ]
|
|
|
|
|
|
|
|
Create web account LOGIN.
|
|
|
|
No arguments starts interactive mode.
|
|
|
|
|
|
|
|
-p PASSWD
|
|
|
|
FTP and SFTP password (default : random)
|
|
|
|
|
|
|
|
-m DBNAME
|
|
|
|
Name of MySQL database (default : same as account)
|
|
|
|
|
|
|
|
-P DBPASSWD
|
|
|
|
MySQL password (default : random)
|
|
|
|
|
|
|
|
-l MAIL
|
|
|
|
Send summary email to MAIL
|
|
|
|
|
|
|
|
-k SSHKEY
|
|
|
|
Use this SSH key
|
|
|
|
|
|
|
|
-u UID
|
|
|
|
Force account UID (only in command line)
|
|
|
|
|
|
|
|
-g GID
|
|
|
|
Force account GID (only in command line)
|
|
|
|
|
|
|
|
-U UID
|
|
|
|
Force www-account UID (only in command line)
|
|
|
|
|
|
|
|
-y
|
|
|
|
Don't ask for confirmation
|
|
|
|
|
2017-08-22 23:19:51 +02:00
|
|
|
-r
|
|
|
|
PHP version (without dot)
|
|
|
|
|
|
|
|
-q
|
|
|
|
Filesystem quota in GiB, in the form <quota soft>:<quota hard>
|
|
|
|
|
|
|
|
Example : web-add.sh add -m testdb -r 56 testlogin testdomain.com
|
2015-08-25 16:54:13 +02:00
|
|
|
|
2019-04-05 10:49:23 +02:00
|
|
|
del [ [OPTIONS] LOGIN [DBNAME] ]
|
2015-08-25 16:54:13 +02:00
|
|
|
|
|
|
|
Delete account and all files related (Apache, Awstats, etc)
|
|
|
|
Archive home directory.
|
|
|
|
Remove MySQL database only if DBNAME is specified.
|
|
|
|
|
2019-04-05 10:49:23 +02:00
|
|
|
-y
|
|
|
|
Don't ask for confirmation
|
|
|
|
|
|
|
|
Example : web-add.sh del -y testlogin testdatabase
|
|
|
|
|
|
|
|
|
2015-08-25 16:54:13 +02:00
|
|
|
list-vhost LOGIN
|
|
|
|
|
|
|
|
List Apache vhost for user LOGIN
|
2019-03-19 11:46:41 +01:00
|
|
|
|
2018-12-04 17:25:45 +01:00
|
|
|
check-vhosts -f
|
2019-03-22 15:00:44 +01:00
|
|
|
|
2018-12-04 17:25:45 +01:00
|
|
|
List suggested changes to vhosts, apply fixes with -f
|
2015-08-25 16:54:13 +02:00
|
|
|
|
|
|
|
add-alias VHOST ALIAS
|
|
|
|
|
|
|
|
Add a ServerAlias to an Apache vhost
|
|
|
|
|
|
|
|
del-alias VHOST ALIAS
|
|
|
|
|
|
|
|
Del a ServerAlias from an Apache vhost
|
|
|
|
|
2019-03-22 15:00:44 +01:00
|
|
|
update-servername VHOST SERVERNAME OLD_SERVERNAME
|
2019-03-19 11:46:41 +01:00
|
|
|
|
2019-03-22 15:00:44 +01:00
|
|
|
Replace the OLD_SERVERNAME with the SERVERNAME for an Apache vhost
|
2019-05-16 14:40:30 +02:00
|
|
|
Also apply to rewrite rules
|
2019-03-19 11:46:41 +01:00
|
|
|
|
2019-03-25 11:34:03 +01:00
|
|
|
check-occurence NAME
|
|
|
|
|
|
|
|
List all occurences of NAME in vhosts
|
|
|
|
|
2019-05-16 14:40:30 +02:00
|
|
|
list-user-itk LOGIN
|
2019-03-25 18:05:37 +01:00
|
|
|
|
2019-05-16 14:40:30 +02:00
|
|
|
List the assigned ITK user for the LOGIN specified
|
2019-03-25 18:05:37 +01:00
|
|
|
|
2019-05-16 14:40:30 +02:00
|
|
|
enable-user-itk LOGIN
|
2019-03-25 18:05:37 +01:00
|
|
|
|
2019-05-16 14:40:30 +02:00
|
|
|
Enable the assigned ITK user for the LOGIN specified
|
2019-03-25 18:05:37 +01:00
|
|
|
|
2019-05-16 14:40:30 +02:00
|
|
|
disable-user-itk LOGIN
|
2019-03-25 18:05:37 +01:00
|
|
|
|
2019-05-16 14:40:30 +02:00
|
|
|
Disable the assigned ITK user for the LOGIN specified
|
2019-03-25 18:05:37 +01:00
|
|
|
|
2017-08-22 23:19:51 +02:00
|
|
|
setphpversion LOGIN VERSION
|
|
|
|
|
|
|
|
Change PHP version for LOGIN
|
|
|
|
|
|
|
|
setquota LOGIN QUOTA_SOFT:QUOTA_HARD
|
|
|
|
|
|
|
|
Change quotas for LOGIN
|
2019-06-07 14:10:07 +02:00
|
|
|
|
|
|
|
manage-http-challenge-file [CREATE | DELETE]
|
|
|
|
|
|
|
|
Create or delete a dummy file for the Let's Encrypt HTTP challenge
|
|
|
|
The default directory is /var/lib/letsencrypt/.well-known/
|
2019-07-10 16:56:50 +02:00
|
|
|
|
|
|
|
generate-csr LOGIN DOMAINS
|
|
|
|
|
|
|
|
Generate the request for the Let's Encrypt certificate
|
|
|
|
|
|
|
|
generate-ssl-certificate LOGIN [TRUE | FALSE]
|
|
|
|
|
|
|
|
Generate the Let's Encrypt certificate
|
|
|
|
Run in TEST mode if TRUE
|
|
|
|
|
2015-08-25 16:54:13 +02:00
|
|
|
EOT
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Affiche un message d'erreur de validation
|
|
|
|
#
|
|
|
|
in_error() {
|
2017-08-20 04:31:00 +02:00
|
|
|
msg=$1
|
|
|
|
cat >&2 <<EOT
|
2015-08-25 16:54:13 +02:00
|
|
|
***
|
|
|
|
Erreur : $msg
|
|
|
|
***
|
|
|
|
EOT
|
|
|
|
}
|
|
|
|
|
|
|
|
gen_random_passwd() {
|
2021-02-22 16:22:31 +01:00
|
|
|
apg -c /dev/urandom -MNCL -n1 -m18 -E oOlL10
|
2015-08-25 16:54:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
validate_login() {
|
2017-08-20 04:31:00 +02:00
|
|
|
login=$1
|
2018-04-19 22:41:58 +02:00
|
|
|
|
2017-08-20 04:31:00 +02:00
|
|
|
length=${#login}
|
2018-04-19 22:41:58 +02:00
|
|
|
|
2018-10-16 20:25:23 +02:00
|
|
|
if [ "$length" -lt 3 ]; then
|
2017-08-20 04:31:00 +02:00
|
|
|
in_error "Le login doit contenir plus de 2 caracteres"
|
|
|
|
return 1
|
|
|
|
fi
|
2018-04-19 22:41:58 +02:00
|
|
|
|
2018-10-16 20:25:23 +02:00
|
|
|
if [ "$length" -gt $MAX_LOGIN_CHAR ]; then
|
2017-08-20 04:31:00 +02:00
|
|
|
in_error "Le login ne doit pas contenir plus de $MAX_LOGIN_CHAR caracteres"
|
|
|
|
return 1
|
|
|
|
fi
|
2015-08-25 16:54:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
validate_passwd() {
|
2017-08-20 04:31:00 +02:00
|
|
|
passwd=$1
|
|
|
|
length=${#passwd}
|
2015-08-25 16:54:13 +02:00
|
|
|
|
2018-10-16 20:25:23 +02:00
|
|
|
if [ "$length" -lt 6 ] && [ "$length" -gt 0 ]; then
|
2017-08-20 04:31:00 +02:00
|
|
|
in_error "Le mot de passe doit avoir au moins 6 caracteres"
|
|
|
|
return 1
|
|
|
|
fi
|
2015-08-25 16:54:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
validate_dbname() {
|
2017-08-20 04:31:00 +02:00
|
|
|
dbname=$1
|
2017-08-22 23:19:51 +02:00
|
|
|
if mysql $MYSQL_OPTS -ss -e "show databases" | grep "^$dbname$" >/dev/null; then
|
2017-08-20 04:31:00 +02:00
|
|
|
in_error "Base de données déjà existante"
|
|
|
|
return 1
|
|
|
|
fi
|
2015-08-25 16:54:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
validate_wwwdomain() {
|
2017-08-20 04:31:00 +02:00
|
|
|
wwwdomain=$1
|
|
|
|
if [ -z "$wwwdomain" ]; then
|
|
|
|
in_error "Le nom de domaine est obligatoire"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
return 0
|
2015-08-25 16:54:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
validate_mail() {
|
2017-08-20 04:31:00 +02:00
|
|
|
return 0
|
2015-08-25 16:54:13 +02:00
|
|
|
}
|
|
|
|
|
2017-08-22 23:19:51 +02:00
|
|
|
validate_phpversion() {
|
|
|
|
php_version="$1"
|
2018-10-16 20:32:47 +02:00
|
|
|
if [[ ! " ${PHP_VERSIONS[*]} " =~ ${php_version} ]]; then
|
2017-08-22 23:19:51 +02:00
|
|
|
in_error "Version de PHP incorrecte."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
validate_quota() {
|
2018-10-16 20:25:23 +02:00
|
|
|
quota_soft=$(echo "$1" |cut -f 1 -d:)
|
|
|
|
quota_hard=$(echo "$1" |cut -f 2 -d:)
|
2017-08-22 23:19:51 +02:00
|
|
|
if [ -z "$quota_soft" ] || [ -z "$quota_hard" ]; then
|
|
|
|
in_error "Le quota soft et le quota hard doivent être spécifiés sous la forme <quota soft>:<quota hard>."
|
|
|
|
return 1
|
2018-10-16 20:25:23 +02:00
|
|
|
elif [ "$quota_soft" -gt "$quota_hard" ]; then
|
2017-08-22 23:19:51 +02:00
|
|
|
in_error "Le quota hard doit être plus grand que le quota soft."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-08-25 16:54:13 +02:00
|
|
|
step_ok() {
|
2017-08-20 04:31:00 +02:00
|
|
|
msg=$1
|
|
|
|
echo "[OK] $msg"
|
2015-08-25 16:54:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
create_www_account() {
|
|
|
|
|
2017-08-20 04:31:00 +02:00
|
|
|
# Vérifications
|
|
|
|
for filetocheck in $TPL_VHOST $TPL_AWSTATS $TPL_MAIL; do
|
|
|
|
if [ ! -f $filetocheck ]; then
|
|
|
|
in_error "Fichier inexistant : $filetocheck"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
############################################################################
|
|
|
|
|
|
|
|
if [ -f $PRE_LOCAL_SCRIPT ]; then
|
2018-10-16 20:10:02 +02:00
|
|
|
# shellcheck source=/usr/share/scripts/evoadmin/web-add.pre-local.sh
|
2017-08-20 04:31:00 +02:00
|
|
|
source $PRE_LOCAL_SCRIPT
|
|
|
|
fi
|
|
|
|
|
|
|
|
step_ok "Exécution du pre-script spécifique"
|
|
|
|
|
|
|
|
############################################################################
|
|
|
|
|
|
|
|
if [ -z "$HOME_DIR_USER" ]; then
|
|
|
|
HOME_DIR_USER="$HOME_DIR/$in_login"
|
|
|
|
fi
|
|
|
|
|
|
|
|
############################################################################
|
|
|
|
|
|
|
|
if [ -d "$HOME_DIR_USER" ]; then
|
|
|
|
in_error "Ce compte existe deja (ou il a mal été effacé)"
|
|
|
|
return 1
|
|
|
|
fi
|
2018-04-19 22:41:58 +02:00
|
|
|
|
2018-10-17 21:03:15 +02:00
|
|
|
# Create user and force UID / GID if specified
|
2018-10-17 21:03:15 +02:00
|
|
|
/usr/sbin/adduser \
|
|
|
|
--gecos "User $in_login" \
|
|
|
|
--disabled-password \
|
|
|
|
"$in_login" \
|
|
|
|
--shell /bin/bash \
|
|
|
|
${in_uid:+'--uid' "$in_uid"} \
|
|
|
|
${in_gid:+'--gid' "$in_gid"} \
|
|
|
|
--force-badname \
|
|
|
|
--home "$HOME_DIR_USER" >/dev/null
|
2019-03-19 11:46:41 +01:00
|
|
|
|
2018-10-17 21:03:15 +02:00
|
|
|
[ -z "$in_sshkey" ] \
|
2019-02-28 16:19:54 +01:00
|
|
|
&& echo "$in_login:$in_passwd" | chpasswd
|
|
|
|
|
2018-10-17 21:03:15 +02:00
|
|
|
[ -z "$in_sshkey" ] \
|
|
|
|
|| [ -n "$HOME_DIR_USER" ] \
|
|
|
|
&& mkdir "$HOME_DIR_USER/.ssh" \
|
|
|
|
&& echo "$in_sshkey" > "$HOME_DIR_USER/.ssh/authorized_keys" \
|
|
|
|
&& chmod -R u=rwX,g=,o= "$HOME_DIR_USER/.ssh/authorized_keys" \
|
|
|
|
&& chown -R "$in_login":"$in_login" "$HOME_DIR_USER/.ssh"
|
2017-08-20 04:31:00 +02:00
|
|
|
|
2019-03-19 11:46:41 +01:00
|
|
|
if [ "$WEB_SERVER" == "apache" ]; then
|
2018-10-17 21:03:15 +02:00
|
|
|
# Create www user and force UID if specified
|
2018-10-17 21:03:15 +02:00
|
|
|
/usr/sbin/adduser \
|
|
|
|
--gecos "WWW $in_login" \
|
|
|
|
--disabled-password \
|
|
|
|
www-"$in_login" \
|
|
|
|
--shell /bin/false \
|
|
|
|
${in_wwwuid:+'--uid' "$in_wwwuid"} \
|
|
|
|
--ingroup "$in_login" \
|
|
|
|
--force-badname \
|
|
|
|
--home "$HOME_DIR_USER"/www \
|
|
|
|
--no-create-home > /dev/null
|
2017-08-23 14:19:48 +02:00
|
|
|
elif [ "$WEB_SERVER" == "nginx" ]; then
|
|
|
|
# Adding user www-data to group $in_login.
|
|
|
|
# And primary group www-data for $in_login.
|
2018-10-16 20:25:23 +02:00
|
|
|
adduser www-data "$in_login"
|
|
|
|
usermod -g www-data "$in_login"
|
2017-08-23 14:19:48 +02:00
|
|
|
fi
|
2017-08-20 04:31:00 +02:00
|
|
|
|
2017-08-25 22:56:30 +02:00
|
|
|
# Get uid/gid for newly created accounts
|
2018-10-16 20:25:23 +02:00
|
|
|
uid=$(id -u "$in_login")
|
|
|
|
gid=$(id -g "$in_login")
|
|
|
|
www_uid=$(id -u www-"$in_login")
|
2017-08-25 22:56:30 +02:00
|
|
|
|
2017-08-22 23:19:51 +02:00
|
|
|
# Create users inside all containers
|
2018-10-16 20:25:23 +02:00
|
|
|
for php_version in "${PHP_VERSIONS[@]}"; do
|
|
|
|
lxc-attach -n php"${php_version}" -- /usr/sbin/addgroup "$in_login" --gid "$gid" --force-badname >/dev/null
|
|
|
|
lxc-attach -n php"${php_version}" -- /usr/sbin/adduser --gecos "User $in_login" --disabled-password "$in_login" --shell /bin/bash --uid "$uid" --gid "$gid" --force-badname --home "$HOME_DIR_USER" >/dev/null
|
2019-02-28 16:19:54 +01:00
|
|
|
lxc-attach -n php"${php_version}" -- [ -z "$in_sshkey" ] && echo "$in_login:$in_passwd" | chpasswd
|
2018-10-16 20:25:23 +02:00
|
|
|
lxc-attach -n php"${php_version}" -- /usr/sbin/adduser --disabled-password --home "$HOME_DIR_USER"/www --no-create-home --shell /bin/false --gecos "WWW $in_login" www-"$in_login" --uid "$www_uid" --ingroup "$in_login" --force-badname >/dev/null
|
2017-08-22 23:19:51 +02:00
|
|
|
done
|
|
|
|
|
2018-04-19 22:41:42 +02:00
|
|
|
if grep -qE '^AllowGroups' /etc/ssh/sshd_config; then
|
2018-10-16 20:39:23 +02:00
|
|
|
if ! grep -qE "^AllowGroups(\\s+\\S+)*(\\s+$SSH_GROUP)" /etc/ssh/sshd_config; then
|
2018-04-20 11:20:06 +02:00
|
|
|
sed -i "s/^AllowGroups .*/& $SSH_GROUP/" /etc/ssh/sshd_config
|
|
|
|
groupadd --force $SSH_GROUP
|
2018-04-19 22:41:42 +02:00
|
|
|
fi
|
2018-04-20 11:20:06 +02:00
|
|
|
usermod -a -G $SSH_GROUP "$in_login"
|
|
|
|
elif grep -qE '^AllowUsers' /etc/ssh/sshd_config; then
|
|
|
|
sed -i "s/^AllowUsers .*/& $in_login/" /etc/ssh/sshd_config
|
2018-04-19 22:41:42 +02:00
|
|
|
fi
|
2017-08-20 04:31:00 +02:00
|
|
|
/etc/init.d/ssh reload
|
|
|
|
|
|
|
|
step_ok "Création des utilisateurs"
|
|
|
|
|
|
|
|
############################################################################
|
|
|
|
|
2017-08-23 14:19:48 +02:00
|
|
|
if [ "$WEB_SERVER" == "apache" ]; then
|
|
|
|
echo "www-$login: $login" >> /etc/aliases
|
|
|
|
echo "$login: $WWWBOUNCE_MAIL" >> /etc/aliases
|
|
|
|
elif [ "$WEB_SERVER" == "nginx" ]; then
|
|
|
|
echo "$login: $WWWBOUNCE_MAIL" >> /etc/aliases
|
|
|
|
fi
|
2017-08-20 04:31:00 +02:00
|
|
|
newaliases
|
|
|
|
|
|
|
|
step_ok "Alias mail"
|
|
|
|
|
|
|
|
############################################################################
|
|
|
|
|
2018-10-16 20:25:23 +02:00
|
|
|
chmod 750 "$HOME_DIR_USER"/
|
2018-04-19 22:41:58 +02:00
|
|
|
|
2017-08-20 04:31:00 +02:00
|
|
|
# Répertoires par défaut
|
2018-10-16 20:25:23 +02:00
|
|
|
mkdir -p "$HOME_DIR_USER"/{log,www,awstats}
|
|
|
|
chown "$in_login":"$in_login" "$HOME_DIR_USER"/www
|
|
|
|
chgrp "$in_login" "$HOME_DIR_USER"/{log,awstats}
|
|
|
|
chmod 750 "$HOME_DIR_USER"/{log,www,awstats}
|
2018-04-19 22:41:58 +02:00
|
|
|
|
2017-08-20 04:31:00 +02:00
|
|
|
# Ajout des logs par defaut
|
2018-10-16 20:25:23 +02:00
|
|
|
touch "$HOME_DIR_USER"/log/access.log
|
|
|
|
touch "$HOME_DIR_USER"/log/error.log
|
|
|
|
touch "$HOME_DIR_USER"/log/php.log
|
|
|
|
chgrp "$in_login" "$HOME_DIR_USER"/log/access.log
|
|
|
|
chgrp "$in_login" "$HOME_DIR_USER"/log/error.log
|
2017-08-23 14:19:48 +02:00
|
|
|
if [ "$WEB_SERVER" == "apache" ]; then
|
2018-10-16 20:25:23 +02:00
|
|
|
chown www-"$in_login":"$in_login" "$HOME_DIR_USER"/log/php.log
|
2017-08-23 14:19:48 +02:00
|
|
|
fi
|
|
|
|
# There is no php.log for nginx ATM, it will go in error.log.
|
2018-10-16 20:25:23 +02:00
|
|
|
chmod 640 "$HOME_DIR_USER"/log/access.log
|
|
|
|
chmod 640 "$HOME_DIR_USER"/log/error.log
|
|
|
|
chmod 640 "$HOME_DIR_USER"/log/php.log
|
2017-08-20 04:31:00 +02:00
|
|
|
|
|
|
|
step_ok "Création du répertoire personnel"
|
|
|
|
|
2017-08-22 23:19:51 +02:00
|
|
|
############################################################################
|
|
|
|
|
|
|
|
if [ -n "$in_quota" ]; then
|
2018-10-16 20:25:23 +02:00
|
|
|
quota_soft=$(($(echo "$in_quota" |cut -f 1 -d:) * 1024 * 1024))
|
|
|
|
quota_hard=$(($(echo "$in_quota" |cut -f 2 -d:) * 1024 * 1024))
|
|
|
|
setquota --remote --user "$in_login" $quota_soft $quota_hard 0 0 /home
|
2017-08-22 23:19:51 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
############################################################################
|
|
|
|
|
|
|
|
# Create FPM pool on all containers.
|
2018-10-16 20:25:23 +02:00
|
|
|
for php_version in "${PHP_VERSIONS[@]}"; do
|
2017-08-22 23:19:51 +02:00
|
|
|
if [ "$php_version" = "70" ]; then
|
|
|
|
pool_path="/etc/php/7.0/fpm/pool.d/"
|
2019-03-15 16:44:42 +01:00
|
|
|
elif [ "$php_version" = "73" ]; then
|
|
|
|
pool_path="/etc/php/7.3/fpm/pool.d/"
|
2021-04-15 11:11:55 +02:00
|
|
|
elif [ "$php_version" = "74" ]; then
|
|
|
|
pool_path="/etc/php/7.4/fpm/pool.d/"
|
2021-10-05 10:13:12 +02:00
|
|
|
elif [ "$php_version" = "80" ]; then
|
|
|
|
pool_path="/etc/php/8.0/fpm/pool.d/"
|
2022-02-22 15:16:22 +01:00
|
|
|
elif [ "$php_version" = "81" ]; then
|
|
|
|
pool_path="/etc/php/8.1/fpm/pool.d/"
|
2017-08-22 23:19:51 +02:00
|
|
|
else
|
|
|
|
pool_path="/etc/php5/fpm/pool.d/"
|
|
|
|
fi
|
2017-08-25 22:57:38 +02:00
|
|
|
phpfpm_socket_path="/home/${in_login}/php-fpm${php_version}.sock"
|
2018-10-16 20:25:23 +02:00
|
|
|
cat <<EOT >/var/lib/lxc/php"${php_version}"/rootfs/${pool_path}/"${in_login}".conf
|
2017-08-22 23:19:51 +02:00
|
|
|
[${in_login}]
|
2019-04-02 15:15:51 +02:00
|
|
|
user = www-${in_login}
|
2017-08-22 23:19:51 +02:00
|
|
|
group = ${in_login}
|
|
|
|
|
2017-08-25 22:57:38 +02:00
|
|
|
listen = ${phpfpm_socket_path}
|
|
|
|
listen.owner = ${in_login}
|
|
|
|
listen.group = ${in_login}
|
2021-02-22 16:12:21 +01:00
|
|
|
|
2017-08-22 23:19:51 +02:00
|
|
|
pm = ondemand
|
2021-02-23 11:07:29 +01:00
|
|
|
pm.status_path = /evolinux_fpm_status-$(apg -Mncl -n1 -m32)
|
2017-08-22 23:19:51 +02:00
|
|
|
pm.max_children = 10
|
|
|
|
pm.process_idle_timeout = 10s
|
2021-02-23 11:07:29 +01:00
|
|
|
|
2017-08-22 23:19:51 +02:00
|
|
|
php_admin_value[error_log] = /home/${in_login}/log/php.log
|
|
|
|
EOT
|
2017-08-25 22:57:38 +02:00
|
|
|
step_ok "Création du pool FPM ${php_version}"
|
2017-08-22 23:19:51 +02:00
|
|
|
done
|
|
|
|
|
2017-08-20 04:31:00 +02:00
|
|
|
############################################################################
|
2018-04-19 22:41:58 +02:00
|
|
|
|
2017-08-20 04:31:00 +02:00
|
|
|
random=$RANDOM
|
2017-08-23 14:19:48 +02:00
|
|
|
if [ "$WEB_SERVER" == "apache" ]; then
|
2019-08-21 12:05:37 +02:00
|
|
|
# On s'assure que /etc/apache2/ssl pour le IncludeOptional de la conf
|
|
|
|
mkdir -p /etc/apache2/ssl
|
|
|
|
|
2017-08-23 14:19:48 +02:00
|
|
|
vhostfile="/etc/apache2/sites-available/${in_login}.conf"
|
2018-10-16 20:43:26 +02:00
|
|
|
sed -e "s/XXX/$in_login/g ; s/SERVERNAME/$in_wwwdomain/ ; s/RANDOM/$random/ ; s#HOME_DIR#$HOME_DIR#" < $TPL_VHOST > "$vhostfile"
|
2017-08-23 14:19:48 +02:00
|
|
|
|
|
|
|
if [ ${#PHP_VERSIONS[@]} -gt 0 ]; then
|
2017-08-25 22:57:38 +02:00
|
|
|
phpfpm_socket_path="/home/${in_login}/php-fpm${in_phpversion}.sock"
|
2018-10-16 20:25:23 +02:00
|
|
|
cat <<EOT >>"$vhostfile"
|
2017-08-25 22:57:38 +02:00
|
|
|
<Proxy "unix:${phpfpm_socket_path}|fcgi://localhost/" timeout=300>
|
2017-08-22 23:19:51 +02:00
|
|
|
</Proxy>
|
2018-10-16 20:39:23 +02:00
|
|
|
<FilesMatch "\\.php$">
|
2017-08-25 22:57:38 +02:00
|
|
|
SetHandler proxy:unix:${phpfpm_socket_path}|fcgi://localhost/
|
2017-08-22 23:19:51 +02:00
|
|
|
</FilesMatch>
|
|
|
|
</VirtualHost>
|
|
|
|
EOT
|
2017-08-23 14:19:48 +02:00
|
|
|
else
|
2018-10-16 20:25:23 +02:00
|
|
|
cat <<EOT >>"$vhostfile"
|
2017-08-22 23:19:51 +02:00
|
|
|
</VirtualHost>
|
|
|
|
EOT
|
2017-08-23 14:19:48 +02:00
|
|
|
fi
|
2018-04-19 22:41:58 +02:00
|
|
|
|
2017-08-23 14:19:48 +02:00
|
|
|
# On active aussi example.com si domaine commence par "www." comme www.example
|
2018-10-16 20:39:23 +02:00
|
|
|
if echo "$in_wwwdomain" | grep '^www.' > /dev/null; then
|
|
|
|
subweb="${in_wwwdomain#www.}"
|
|
|
|
sed -i -e "s/^\\(.*\\)#\\(ServerAlias\\).*$/\\1\\2 $subweb/" "$vhostfile"
|
2017-08-23 14:19:48 +02:00
|
|
|
fi
|
2018-04-19 22:41:58 +02:00
|
|
|
|
2021-02-10 15:21:04 +01:00
|
|
|
a2ensite "${in_login}.conf" >/dev/null
|
2018-04-19 22:41:58 +02:00
|
|
|
|
2017-08-23 14:19:48 +02:00
|
|
|
step_ok "Configuration d'Apache"
|
|
|
|
|
|
|
|
elif [ "$WEB_SERVER" == "nginx" ]; then
|
2018-10-16 20:43:26 +02:00
|
|
|
sed -e \
|
|
|
|
"s/DOMAIN/${in_wwwdomain}/g; s/LOGIN/${in_login}/g;" \
|
|
|
|
< "$TPL_VHOST" \
|
|
|
|
> ${VHOST_PATH}/"$in_login"
|
|
|
|
ln -s /etc/nginx/sites-available/"$in_login" \
|
|
|
|
/etc/nginx/sites-enabled/"$in_login"
|
2017-08-23 14:19:48 +02:00
|
|
|
|
|
|
|
/etc/init.d/nginx restart
|
|
|
|
|
|
|
|
step_ok "Configuration de Nginx + restart"
|
|
|
|
|
|
|
|
############################################################################
|
|
|
|
|
2018-10-16 20:43:26 +02:00
|
|
|
sed -e "s/SED_LOGIN/${in_login}/g;" \
|
|
|
|
< $TPL_FPM > ${FPM_PATH}/"${in_login}".conf
|
2017-08-23 14:19:48 +02:00
|
|
|
step_ok "Creation du pool PHP-FPM"
|
2017-08-20 04:31:00 +02:00
|
|
|
|
2017-08-25 14:47:42 +02:00
|
|
|
############################################################################
|
|
|
|
fi
|
2017-08-20 04:31:00 +02:00
|
|
|
|
2018-10-16 20:43:26 +02:00
|
|
|
sed -e "s/XXX/$in_login/ ; s/SERVERNAME/$in_wwwdomain/ ; s#HOME_DIR#$HOME_DIR#" \
|
|
|
|
< $TPL_AWSTATS > /etc/awstats/awstats."$in_login".conf
|
|
|
|
chmod 644 /etc/awstats/awstats."$in_login".conf
|
2017-08-23 14:19:48 +02:00
|
|
|
|
2018-10-16 20:25:23 +02:00
|
|
|
VAR=$(grep -v "^#" /etc/cron.d/awstats |tail -1 | cut -d " " -f1)
|
|
|
|
if [ "$VAR" = "" ] || [ "$VAR" -ge 59 ]; then
|
2017-08-20 04:31:00 +02:00
|
|
|
VAR=1
|
|
|
|
else
|
2018-10-16 20:46:16 +02:00
|
|
|
VAR=$((VAR +1))
|
2017-08-20 04:31:00 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$VAR * * * * root umask 033; [ -x /usr/lib/cgi-bin/awstats.pl -a -f /etc/awstats/awstats.$in_login.conf -a -r $HOME_DIR_USER/log/access.log ] && /usr/lib/cgi-bin/awstats.pl -config=$in_login -update >/dev/null" >> /etc/cron.d/awstats
|
|
|
|
|
|
|
|
step_ok "Activation d'Awstats"
|
|
|
|
|
|
|
|
############################################################################
|
2018-04-19 22:41:58 +02:00
|
|
|
|
2017-08-20 04:31:00 +02:00
|
|
|
if [ "$in_dbname" ]; then
|
2017-08-22 23:19:51 +02:00
|
|
|
echo "CREATE DATABASE \`$in_dbname\` $MYSQL_CREATE_DB_OPTS;" | mysql $MYSQL_OPTS
|
|
|
|
echo "GRANT ALL PRIVILEGES ON \`$in_dbname\`.* TO \`$in_login\`@localhost IDENTIFIED BY '$in_dbpasswd';" | mysql $MYSQL_OPTS
|
|
|
|
echo "FLUSH PRIVILEGES;" | mysql $MYSQL_OPTS
|
2017-08-20 04:31:00 +02:00
|
|
|
|
|
|
|
my_cnf_file="$HOME_DIR_USER/.my.cnf"
|
2018-10-16 20:25:23 +02:00
|
|
|
cat > "$my_cnf_file" <<-EOT
|
2017-10-17 10:44:58 +02:00
|
|
|
[client]
|
|
|
|
user = $in_login
|
|
|
|
password = "$in_dbpasswd"
|
|
|
|
|
|
|
|
[mysql]
|
|
|
|
database = $in_dbname
|
2017-08-23 14:19:48 +02:00
|
|
|
EOT
|
2018-10-16 20:25:23 +02:00
|
|
|
chown "$in_login" "$my_cnf_file"
|
|
|
|
chmod 600 "$my_cnf_file"
|
2017-08-20 04:31:00 +02:00
|
|
|
|
|
|
|
step_ok "Création base de données et compte MySQL"
|
|
|
|
fi
|
|
|
|
|
|
|
|
############################################################################
|
2018-04-19 22:41:58 +02:00
|
|
|
|
2017-08-22 23:19:51 +02:00
|
|
|
if [ "$in_dbname" ]; then
|
2018-10-16 20:43:26 +02:00
|
|
|
sed -e "
|
2019-03-19 11:46:41 +01:00
|
|
|
s/LOGIN/$in_login/g ;
|
|
|
|
s/SERVERNAME/$in_wwwdomain/ ;
|
|
|
|
s/PASSE1/$in_passwd/ ;
|
|
|
|
s/PASSE2/$in_dbpasswd/ ;
|
|
|
|
s/RANDOM/$random/ ;
|
|
|
|
s/QUOTA/$quota/ ;
|
|
|
|
s/RCPTTO/$in_mail/ ;
|
|
|
|
s/DBNAME/$in_dbname/ ;
|
2018-10-16 20:43:26 +02:00
|
|
|
s#HOME_DIR#$HOME_DIR#" \
|
|
|
|
< $TPL_MAIL | /usr/lib/sendmail -oi -t -f "$CONTACT_MAIL"
|
2017-08-22 23:19:51 +02:00
|
|
|
else
|
2018-10-16 20:43:26 +02:00
|
|
|
sed -e "
|
2019-03-19 11:46:41 +01:00
|
|
|
s/LOGIN/$in_login/g ;
|
|
|
|
s/SERVERNAME/$in_wwwdomain/ ;
|
|
|
|
s/PASSE1/$in_passwd/ ;
|
|
|
|
s/RANDOM/$random/ ;
|
|
|
|
s/QUOTA/$quota/ ;
|
|
|
|
s/RCPTTO/$in_mail/ ;
|
|
|
|
s#HOME_DIR#$HOME_DIR# ;
|
2018-10-16 20:43:26 +02:00
|
|
|
39,58d" \
|
|
|
|
< $TPL_MAIL | /usr/lib/sendmail -oi -t -f "$CONTACT_MAIL"
|
2017-08-22 23:19:51 +02:00
|
|
|
fi
|
2017-08-20 04:31:00 +02:00
|
|
|
|
|
|
|
step_ok "Envoi du mail récapitulatif"
|
|
|
|
|
|
|
|
############################################################################
|
|
|
|
|
|
|
|
if [ -f $LOCAL_SCRIPT ]; then
|
2018-10-16 20:10:02 +02:00
|
|
|
# shellcheck source=/usr/share/scripts/evoadmin/web-add.local.sh
|
2017-08-20 04:31:00 +02:00
|
|
|
source $LOCAL_SCRIPT
|
|
|
|
fi
|
|
|
|
|
|
|
|
step_ok "Exécution du script spécifique"
|
|
|
|
|
|
|
|
############################################################################
|
2018-04-19 22:41:58 +02:00
|
|
|
|
2017-08-23 14:19:48 +02:00
|
|
|
if [ "$WEB_SERVER" == "apache" ]; then
|
|
|
|
apache2ctl configtest 2>/dev/null
|
|
|
|
/etc/init.d/apache2 force-reload >/dev/null
|
2018-10-16 20:25:23 +02:00
|
|
|
for php_version in "${PHP_VERSIONS[@]}"; do
|
2017-08-23 14:19:48 +02:00
|
|
|
if [ "$php_version" = "70" ]; then
|
|
|
|
initscript_path="/etc/init.d/php7.0-fpm"
|
|
|
|
binary="php-fpm7.0"
|
2019-03-15 16:44:42 +01:00
|
|
|
elif [ "$php_version" = "73" ]; then
|
|
|
|
initscript_path="/etc/init.d/php7.3-fpm"
|
|
|
|
binary="php-fpm7.3"
|
2021-04-15 11:11:55 +02:00
|
|
|
elif [ "$php_version" = "74" ]; then
|
|
|
|
initscript_path="/etc/init.d/php7.4-fpm"
|
|
|
|
binary="php-fpm7.4"
|
2021-10-05 10:13:12 +02:00
|
|
|
elif [ "$php_version" = "80" ]; then
|
|
|
|
initscript_path="/etc/init.d/php8.0-fpm"
|
|
|
|
binary="php-fpm8.0"
|
2022-02-22 15:16:22 +01:00
|
|
|
elif [ "$php_version" = "81" ]; then
|
|
|
|
initscript_path="/etc/init.d/php8.1-fpm"
|
|
|
|
binary="php-fpm8.1"
|
2017-08-23 14:19:48 +02:00
|
|
|
else
|
|
|
|
initscript_path="/etc/init.d/php5-fpm"
|
|
|
|
binary="php5-fpm"
|
|
|
|
fi
|
2018-10-16 20:25:23 +02:00
|
|
|
lxc-attach -n php"${php_version}" -- $binary --test >/dev/null
|
|
|
|
lxc-attach -n php"${php_version}" -- $initscript_path restart >/dev/null
|
2017-08-25 22:57:38 +02:00
|
|
|
step_ok "Rechargement de php-fpm dans php${php_version}"
|
2017-08-23 14:19:48 +02:00
|
|
|
done
|
|
|
|
|
2017-08-25 22:57:38 +02:00
|
|
|
step_ok "Rechargement d'Apache"
|
2017-08-23 14:19:48 +02:00
|
|
|
fi
|
2017-08-20 04:31:00 +02:00
|
|
|
|
2017-08-23 14:19:48 +02:00
|
|
|
############################################################################
|
2017-08-20 04:31:00 +02:00
|
|
|
|
2017-08-23 14:19:48 +02:00
|
|
|
if [ "$WEB_SERVER" == "nginx" ]; then
|
2018-10-16 20:25:23 +02:00
|
|
|
fpm_status=$(echo -n "$in_login" | md5sum | cut -d' ' -f1)
|
|
|
|
cat <<EOT> /etc/munin/plugin-conf.d/phpfpm_"${in_login}"_
|
2017-08-23 14:19:48 +02:00
|
|
|
|
|
|
|
[phpfpm_${in_login}_*]
|
|
|
|
env.url http://munin:%d/fpm_status_$fpm_status
|
|
|
|
env.ports 80
|
|
|
|
env.phpbin php-fpm
|
|
|
|
env.phppool $in_login
|
|
|
|
EOT
|
|
|
|
for name in average connections memory processes status; do
|
|
|
|
ln -s /usr/local/share/munin/plugins/phpfpm_${name} \
|
2018-10-16 20:25:23 +02:00
|
|
|
/etc/munin/plugins/phpfpm_"${in_login}"_${name}
|
2017-08-23 14:19:48 +02:00
|
|
|
done
|
|
|
|
cat <<EOT>> /etc/nginx/evolinux.d/munin-plugins.conf
|
|
|
|
|
|
|
|
# $in_login FPM Status page. Secret part is md5 of pool name.
|
|
|
|
location ~ ^/fpm_status_${fpm_status}$ {
|
|
|
|
include fastcgi_params;
|
|
|
|
fastcgi_pass unix:/var/run/php-fpm-${in_login}.sock;
|
|
|
|
fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name;
|
|
|
|
allow 127.0.0.1;
|
|
|
|
deny all;
|
|
|
|
}
|
|
|
|
EOT
|
|
|
|
sed -i "s#SED_STATUS#/fpm_status_${fpm_status}#" \
|
2018-10-16 20:25:23 +02:00
|
|
|
${FPM_PATH}/"${in_login}".conf
|
2017-08-23 14:19:48 +02:00
|
|
|
/etc/init.d/nginx reload
|
|
|
|
/etc/init.d/${FPM_SERVICE_NAME} reload
|
|
|
|
/etc/init.d/munin-node restart
|
|
|
|
|
|
|
|
step_ok "Configuration plugin php-fpm pour munin"
|
|
|
|
fi
|
2017-08-20 04:31:00 +02:00
|
|
|
############################################################################
|
2018-04-19 22:41:58 +02:00
|
|
|
|
2017-08-20 04:31:00 +02:00
|
|
|
DATE=$(date +"%Y-%m-%d")
|
|
|
|
echo "$DATE [web-add.sh] Ajout $in_login" >> /var/log/evolix.log
|
2015-08-25 16:54:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
op_del() {
|
2019-04-04 11:52:18 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Mode interactif
|
|
|
|
#
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
echo
|
|
|
|
echo "Suppression d'un compte WEB"
|
|
|
|
echo
|
|
|
|
|
|
|
|
until [ "$login" ]; do
|
|
|
|
echo -n "Entrez le login du compte à supprimer : "
|
|
|
|
read -r tmp
|
|
|
|
login="$tmp"
|
|
|
|
done
|
|
|
|
|
|
|
|
echo -n "Voulez-vous aussi supprimer un compte/base MySQL ? [y|N]"
|
|
|
|
read -r confirm
|
|
|
|
|
|
|
|
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
|
|
|
|
echo -n "Entrez le nom de la base de donnees ($login par defaut) : "
|
|
|
|
read -r tmp
|
|
|
|
|
|
|
|
if [ -z "$tmp" ]; then
|
|
|
|
dbname=$login
|
|
|
|
else
|
|
|
|
dbname="$tmp"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-04-05 10:49:23 +02:00
|
|
|
#
|
|
|
|
# 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] : "
|
2019-04-04 11:52:18 +02:00
|
|
|
read -r tmp
|
|
|
|
echo
|
|
|
|
if [ "$tmp" != "y" ] && [ "$tmp" != "Y" ]; then
|
|
|
|
echo "Annulation..."
|
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-08-20 04:31:00 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
set -x
|
2022-02-17 11:12:55 +01:00
|
|
|
# Crontab dump needs to be done **before** user deletion
|
2022-05-11 14:39:00 +02:00
|
|
|
if crontab -l -u "$login"; then
|
|
|
|
crontab -l -u "$login" &> /home/$login/crontab-$(date '+%Y%m%d-%H%M%S').bak
|
|
|
|
crontab -r -u "$login"
|
|
|
|
fi
|
2022-02-17 11:12:55 +01:00
|
|
|
|
2017-08-23 14:19:48 +02:00
|
|
|
if [ "$WEB_SERVER" == "apache" ]; then
|
2021-12-02 10:16:12 +01:00
|
|
|
if id www-"$login" &> /dev/null; then
|
|
|
|
userdel -f www-"$login"
|
|
|
|
fi
|
2017-08-23 14:19:48 +02:00
|
|
|
fi
|
2021-09-22 10:31:49 +02:00
|
|
|
userdel -f "$login"
|
2018-10-16 20:25:23 +02:00
|
|
|
for php_version in "${PHP_VERSIONS[@]}"; do
|
2021-12-02 10:16:12 +01:00
|
|
|
if lxc-attach -n php"${php_version}" -- id www-"$login" &> /dev/null; then
|
|
|
|
lxc-attach -n php"${php_version}" -- userdel -f www-"$login"
|
|
|
|
fi
|
|