Adding create user with email comment.

This commit is contained in:
jmjl 2023-08-01 14:32:15 +00:00
parent 663d53bdd6
commit 040483cbcc
3 changed files with 15 additions and 4 deletions

View file

@ -15,7 +15,7 @@ error_exit() {
}
usage() {
printf "usage: %s %s [-h|--help] <username> <email> \"<pubkey>\"\n" "$PROGNAME" "$VERSION"
printf "usage: %s %s [-h|--help] <username> <email> \"<pubkey>\" \"<comment>\"\n" "$PROGNAME" "$VERSION"
}
case $1 in
@ -24,10 +24,14 @@ case $1 in
-* | --*)
usage; error_exit "unknown option $1" ;;
*)
if [ $# -ne 3 ]; then
if [ $# -le 2 ]; then
error_exit "not enough args"
fi
if [ $# -ge 5 ]; then
error_exit "too many args"
fi
if id "$1" > /dev/null 2>&1; then
exit 0
fi
@ -46,9 +50,11 @@ case $1 in
echo "$2" | sudo tee /opt/mails/"$1" >/dev/null
printf "sending welcome mail\n"
[ "$4" != "" ] && comment="\n$4"
sed -e "s/newusername/$1/g" \
-e "s/newpassword/$newpw/" \
-e "s/newtoemail/$2/" \
-e "s/<comment>/$comment/" \
/opt/tools/res/welcome-mail.tmpl \
| sendmail "$1" "$2" root@tilde.green

View file

@ -32,9 +32,13 @@ while read -r i;do
n="${user} (${email})"
case "${c}" in
(i)echo "skipping!";continue;;
(a|c)
(A|a|c)
case "${c}" in
(a)
(A)
echo "accepting ${n}, please type your message and press Ctrl-D"
COMMENT="$(cat <&3)"
eval "${i} \"${COMMENT}\"";;
(a)
echo "accepting ${n}"
eval "${i}";;
(c)

View file

@ -13,6 +13,7 @@ which is set to only use ssh key authentication.
We look forward to seeing you around! welcome to the ~green!
~tilde.green admins
<comment>
--
Links: