2022-04-14 13:45:57 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
|
|
|
|
|
|
|
if [ $# -ne 2 ] ; then
|
|
|
|
echo -e "Params:\t<username> <contact@email>" >&2
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
user=$1
|
|
|
|
email=$2
|
|
|
|
|
|
|
|
# Check if already existing user
|
|
|
|
if grep -q -e ^$user: /etc/passwd ; then
|
|
|
|
echo User \"$user\" already in base
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Add user
|
|
|
|
echo -n "Creating POSIX account \"$user\"..."
|
|
|
|
useradd $user -m -s /bin/bash
|
|
|
|
echo "[OK]"
|
|
|
|
|
|
|
|
# Set default password
|
|
|
|
echo -n "Setting default password.."
|
2022-06-16 10:09:16 +02:00
|
|
|
password=$(pwgen -A -B -0 8 1)
|
|
|
|
echo "$user:$password" | chpasswd
|
2022-04-14 13:45:57 +02:00
|
|
|
echo "[OK]"
|
|
|
|
|
|
|
|
# Add account to members ML
|
|
|
|
echo -n "Adding mail to member list..."
|
|
|
|
echo " $user" >> /etc/postfix/virtual_members
|
|
|
|
postmap /etc/postfix/virtual_members
|
|
|
|
echo "[OK]"
|
|
|
|
|
|
|
|
echo -n "Reloading postfix..."
|
|
|
|
postfix reload > /dev/null 2>&1
|
|
|
|
echo "[OK]"
|
|
|
|
|
2022-06-16 10:09:16 +02:00
|
|
|
$SCRIPTPATH/sendmail_account.sh $user $email $password
|