forked from team/makeuser
*Mostly* working
This commit is contained in:
parent
5f10b2f431
commit
1bc4d9715b
|
@ -1,4 +1,4 @@
|
||||||
Welcome newusername to thunix!
|
Welcome to thunix, newusername!
|
||||||
|
|
||||||
Your account has been provisioned, and should be available in a few
|
Your account has been provisioned, and should be available in a few
|
||||||
minutes for login. Your password is newpassword
|
minutes for login. Your password is newpassword
|
||||||
|
|
27
makeuser
27
makeuser
|
@ -19,7 +19,7 @@ ZNC_USER="/var/lib/znc/create-znc_account.sh"
|
||||||
|
|
||||||
# Set location to your repo for ansible here
|
# Set location to your repo for ansible here
|
||||||
# It is only needed for thunix
|
# It is only needed for thunix
|
||||||
REPO_LOCATION="~/repos/ansible"
|
REPO_LOCATION="/home/ubergeek/repos/ansible/"
|
||||||
|
|
||||||
error_exit() {
|
error_exit() {
|
||||||
echo -e "${PROGNAME}: ${1:-"Unknown Error"}" >&2
|
echo -e "${PROGNAME}: ${1:-"Unknown Error"}" >&2
|
||||||
|
@ -34,7 +34,7 @@ sub_to_list() {
|
||||||
echo "
|
echo "
|
||||||
From: $1
|
From: $1
|
||||||
Subject: subscribe
|
Subject: subscribe
|
||||||
" | sudo -u $1 sendmail $LIST_NAME
|
" | sudo -u $1 mail $LIST_NAME
|
||||||
}
|
}
|
||||||
|
|
||||||
[[ $(id -u) == 0 ]] && error_exit "Do not run this script as root."
|
[[ $(id -u) == 0 ]] && error_exit "Do not run this script as root."
|
||||||
|
@ -47,21 +47,26 @@ case $1 in
|
||||||
*)
|
*)
|
||||||
[[ $# -ne 3 ]] && error_exit "not enough args"
|
[[ $# -ne 3 ]] && error_exit "not enough args"
|
||||||
echo "adding new user $1"
|
echo "adding new user $1"
|
||||||
newpw=$(pwgen -1B 10)
|
newpw=`pwgen -1B 10`
|
||||||
pwcrypt=$(perl -e "print crypt('${newpw}', 'sa');")
|
pwcrypt=$(perl -e "print crypt('${newpw}', 'sa');")
|
||||||
sudo useradd -m -g 100 -p $pwcrypt -s /bin/bash $1 || exit 1
|
sudo useradd -m -g 1000 -p $pwcrypt -s /bin/bash $1 || exit 1
|
||||||
sed -e "s/newusername/$1/g" -e "s/newpassword/$newpw/" $EMAIL_TEMPLATE | sendmail $1 $2 $ADMIN_EMAIL
|
# 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" email.tmpl | sudo mail -s "Welcome to Thunix!" $2
|
||||||
sub_to_list $1
|
sub_to_list $1
|
||||||
|
|
||||||
# This line is for team
|
# This line is for team
|
||||||
# sudo -u znc $ZNC_USER $1
|
# sudo -u znc $ZNC_USER $1
|
||||||
# This one is for Thunix
|
# This one is for Thunix
|
||||||
sudo -u znc $ZNC_USER $1 $newpw
|
sudo -u znc $ZNC_USER $1 $pwcrypt
|
||||||
|
|
||||||
echo "$3" | tee /home/$1/.ssh/authorized_keys
|
# 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
|
# If root doesn't have a fediverse account, comment this out
|
||||||
sudo toot "welcome new user ~$1!"
|
# sudo toot "welcome new user ~$1!"
|
||||||
|
|
||||||
#Thunix specific section
|
#Thunix specific section
|
||||||
echo "---
|
echo "---
|
||||||
|
@ -78,14 +83,14 @@ case $1 in
|
||||||
- authorized_key:
|
- authorized_key:
|
||||||
user: $1
|
user: $1
|
||||||
state: present
|
state: present
|
||||||
key:'$3'" > $REPO_LOCATION/roles/shell/tasks/users/$YAML_FILE
|
key: \"$3\"" > $REPO_LOCATION/roles/shell/tasks/users/$YAML_FILE
|
||||||
|
|
||||||
echo -e "- include: users/$YAML_FILE\n" >> $REPO_LOCATION/roles/shell/tasks/users.yml
|
echo "- include: users/$YAML_FILE" >> $REPO_LOCATION/roles/shell/tasks/users.yml
|
||||||
place=`pwd`
|
place=`pwd`
|
||||||
cd $REPO_LOCATION
|
cd $REPO_LOCATION
|
||||||
git add $REPO_LOCATION/roles/shell/tasks/users.yml
|
git add $REPO_LOCATION/roles/shell/tasks/users.yml
|
||||||
git commit -am "Adding user $1"
|
git commit -am "Adding user $1"
|
||||||
git push
|
# git push
|
||||||
cd $place
|
cd $place
|
||||||
# End Thunix specific section
|
# End Thunix specific section
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in New Issue