25 lines
497 B
Bash
Executable file
25 lines
497 B
Bash
Executable file
#!/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\" not in base
|
|
exit
|
|
fi
|
|
|
|
# Set default password
|
|
echo -n "Setting default password.."
|
|
password=$(pwgen -A -B -0 8 1)
|
|
echo "$user:$password" | chpasswd
|
|
echo "[OK]"
|
|
|
|
$SCRIPTPATH/sendmail_reset.sh $email $password
|