56 lines
1.3 KiB
Bash
56 lines
1.3 KiB
Bash
# vim: syn=sh ts=4 sts=4 sw=4 smartindent expandtab
|
|
|
|
gitea-add-user() {
|
|
if [ $# -ne 4 ]; then
|
|
echo $#
|
|
echo "gitea-add-user <HOST> <EMAIL> <USERNAME> <PASSWORD>"
|
|
return 2
|
|
fi
|
|
local host=$1
|
|
local email=$2
|
|
local username=$3
|
|
local password=$4
|
|
|
|
curl --request POST --url https://${host}/user/sign_up \
|
|
--header 'content-type: application/x-www-form-urlencoded'\
|
|
--data user_name=$username \
|
|
--data email=$email \
|
|
--data password=$password \
|
|
--data retype=$password
|
|
local retcode=$?
|
|
if [ $retcode -ne 0 ]; then
|
|
echo "unable to add user $username!"
|
|
return 4
|
|
fi
|
|
|
|
local mail="$(cat <<EOF
|
|
Subject: Neuer GIT-Account erstellt
|
|
From: $EMAIL_SENDER
|
|
To: $email
|
|
Ihr GIT Account wurde auf "$host" erstellt mit den Nutzernamen "$username" erstellt.
|
|
Sie können sich dort anmelden.
|
|
|
|
Anmedleinformationen:
|
|
Addresse: https://$host
|
|
Nutzername: $username
|
|
Passwort: $password
|
|
|
|
Wir freuen uns auf Dich!
|
|
Dein GIT-Team auf $host
|
|
EOF
|
|
)"
|
|
if [ -n $(which mutt 2>/dev/null) ]; then
|
|
mutt -H - $email <<<"$mail"
|
|
#elif [ -n $(which send-email 2>/dev/null) ]; then
|
|
fi
|
|
|
|
retcode=$?
|
|
if [ $retcode -ne 0 ]; then
|
|
Email not sended!
|
|
return 5
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
|