forked from team/makeuser
move common code in both makeuser and makeuser_no_ansible to include/functions
This commit is contained in:
parent
de5d356d9c
commit
4574a848a1
|
@ -13,3 +13,24 @@ usage() {
|
||||||
sub_to_list() {
|
sub_to_list() {
|
||||||
echo "From: $1 Subject: subscribe" | sudo -u $1 mail $LIST_NAME
|
echo "From: $1 Subject: subscribe" | sudo -u $1 mail $LIST_NAME
|
||||||
}
|
}
|
||||||
|
|
||||||
|
makeuser_no_ansible()
|
||||||
|
{
|
||||||
|
echo "adding new user $1"
|
||||||
|
newpw=`pwgen -1B 10`
|
||||||
|
pwcrypt=$(perl -e "print crypt('${newpw}', 'sa');")
|
||||||
|
sudo useradd -m -g 1000 -p $pwcrypt -s /bin/bash $1 || exit 1
|
||||||
|
#This is the welcome for team.
|
||||||
|
#sed -e "s/newusername/$1/g" -e "s/newpassword/$newpw/" $EMAIL_TEMPLATE | sudo mail $1 $2 $ADMIN_EMAIL
|
||||||
|
|
||||||
|
#This is the welcome email for thunix
|
||||||
|
sed -e "s/newusername/$1/g" -e "s/newpassword/$newpw/g" include/email.tmpl | sudo mail -s "Welcome to Thunix!" $2
|
||||||
|
sed -e "s/newusername/$1/g" -e "s/newpassword/$newpw/g" include/email.tmpl | sudo mail -s "Welcome to Thunix!" $ADMIN_EMAIL
|
||||||
|
sub_to_list $1
|
||||||
|
|
||||||
|
#We don't need this for thunix, since ansible will do it
|
||||||
|
#echo "$3" | tee /home/$1/.ssh/authorized_keys
|
||||||
|
|
||||||
|
#If root doesn't have a fediverse account, comment this out
|
||||||
|
#sudo toot "welcome new user ~$1!"
|
||||||
|
}
|
||||||
|
|
19
makeuser
19
makeuser
|
@ -23,23 +23,8 @@ case $1 in
|
||||||
usage; error_exit "unknown option $1" ;;
|
usage; error_exit "unknown option $1" ;;
|
||||||
*)
|
*)
|
||||||
[[ $# -ne 3 ]] && error_exit "not enough args"
|
[[ $# -ne 3 ]] && error_exit "not enough args"
|
||||||
echo "adding new user $1"
|
|
||||||
newpw=`pwgen -1B 10`
|
makeuser_no_ansible #adding new user
|
||||||
pwcrypt=$(perl -e "print crypt('${newpw}', 'sa');")
|
|
||||||
sudo useradd -m -g 1000 -p $pwcrypt -s /bin/bash $1 || exit 1
|
|
||||||
# This is the welcome for team.
|
|
||||||
# sed -e "s/newusername/$1/g" -e "s/newpassword/$newpw/" $EMAIL_TEMPLATE | sudo mail $1 $2 $ADMIN_EMAIL
|
|
||||||
|
|
||||||
# This is the welcome email for thunix
|
|
||||||
sed -e "s/newusername/$1/g" -e "s/newpassword/$newpw/g" include/email.tmpl | sudo mail -s "Welcome to Thunix!" $2
|
|
||||||
sed -e "s/newusername/$1/g" -e "s/newpassword/$newpw/g" include/email.tmpl | sudo mail -s "Welcome to Thunix!" $ADMIN_EMAIL
|
|
||||||
sub_to_list $1
|
|
||||||
|
|
||||||
# We don't need this for thunix, since ansible will do it
|
|
||||||
# echo "$3" | tee /home/$1/.ssh/authorized_keys
|
|
||||||
|
|
||||||
# If root doesn't have a fediverse account, comment this out
|
|
||||||
# sudo toot "welcome new user ~$1!"
|
|
||||||
|
|
||||||
#Thunix specific section
|
#Thunix specific section
|
||||||
currdir=`pwd`
|
currdir=`pwd`
|
||||||
|
|
|
@ -22,23 +22,8 @@ case $1 in
|
||||||
usage; error_exit "unknown option $1" ;;
|
usage; error_exit "unknown option $1" ;;
|
||||||
*)
|
*)
|
||||||
[[ $# -ne 3 ]] && error_exit "not enough args"
|
[[ $# -ne 3 ]] && error_exit "not enough args"
|
||||||
echo "adding new user $1"
|
|
||||||
newpw=`pwgen -1B 10`
|
|
||||||
pwcrypt=$(perl -e "print crypt('${newpw}', 'sa');")
|
|
||||||
# sudo useradd -m -g 1000 -p $pwcrypt -s /bin/bash $1 || exit 1
|
|
||||||
# This is the welcome for team.
|
|
||||||
# sed -e "s/newusername/$1/g" -e "s/newpassword/$newpw/" $EMAIL_TEMPLATE | sudo mail $1 $2 $ADMIN_EMAIL
|
|
||||||
|
|
||||||
# This is the welcome email for thunix
|
makeuser_no_ansible #adding new user
|
||||||
sed -e "s/newusername/$1/g" -e "s/newpassword/$newpw/g" include/email.tmpl | sudo mail -s "Welcome to Thunix!" $2
|
|
||||||
sed -e "s/newusername/$1/g" -e "s/newpassword/$newpw/g" include/email.tmpl | sudo mail -s "Welcome to Thunix!" $ADMIN_EMAIL
|
|
||||||
sub_to_list $1
|
|
||||||
|
|
||||||
# We don't need this for thunix, since ansible will do it
|
|
||||||
# echo "$3" | tee /home/$1/.ssh/authorized_keys
|
|
||||||
|
|
||||||
# If root doesn't have a fediverse account, comment this out
|
|
||||||
# sudo toot "welcome new user ~$1!"
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue