From 82ce5d58ad1d279567d2d557b14203af8ff3e5d2 Mon Sep 17 00:00:00 2001 From: Ubergeek Date: Wed, 27 Mar 2019 18:28:49 +0000 Subject: [PATCH] Modfied for thunix --- email.tmpl | 48 ++++++++------------------------------ makeuser | 67 ++++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 66 insertions(+), 49 deletions(-) diff --git a/email.tmpl b/email.tmpl index 2c07303..f41601b 100644 --- a/email.tmpl +++ b/email.tmpl @@ -1,43 +1,13 @@ -Subject: welcome to tilde.team! +Welcome newusername to thunix! -hey ~newusername, +Your account has been provisioned, and should be available in a few +minutes for login. Your password is newpassword -welcome to tilde.team! +Any questions, concerns, comments, etc etc? Join us +in IRC at ircl.tilde.chat/6697, in #thunix, or via webchat: +https://web.tilde.chat/?join=thunix -your new account has been established. you can ssh into tilde.team with -the ssh key you supplied on registration. - -your password is "newpassword". please change it when you log in for -the first time. the password is used for imap/smtp auth, not shell login, -which is set to only use ssh key authentication. - -to get started, type `motd` at the command prompt to see a few ways to -get started. have fun! - -the greatest value of tilde.team is not the services provided by the -server, but rather the interesting and welcoming community built by its -users. this is possible because of people like you who choose to make -this a great place. the best way you can help tilde.team is by working -to support a great system culture. chat on irc; build cool programs and -share them with others; focus on learning, and help others learn; be a -good example for others; have fun! - -also, your ~/public_html directory is served at -https://tilde.team/~newusername/ -(you can also use https://newusername.tilde.team) - -check out our wiki at https://tilde.team/wiki/ for more information (and -maybe help us write a new wiki article:) - -our irc is tilde.chat, an irc network connecting several -tilde servers. the `chat` command on your ~team shell will open up -weechat with some nice default configs and plugins. -see our wiki article (https://tilde.team/wiki/?page=irc) -or https://tilde.chat site for information on how to connect from elsewhere. -we also have a webclient at https://irc.tilde.team that you can -register for by running the `webirc` command from a shell session. - -we look forward to seeing you around! welcome to the ~team! - -~tilde.team admins +Also, check out our git repos, that pretty much manage the whole of the +system at https://tildegit.org/thunix, and feel free to open issues and PRs. +Finally, welcome aboard! diff --git a/makeuser b/makeuser index 3470d22..36f0cc2 100755 --- a/makeuser +++ b/makeuser @@ -1,11 +1,25 @@ #!/bin/bash # --------------------------------------------------------------------------- -# makeuser - tilde.team new user creation +# makeuser - tilde new user creation # Usage: makeuser [-h|--help] "" # --------------------------------------------------------------------------- - +# +# Forked from tilde.team's make user script ( PROGNAME=${0##*/} -VERSION="0.1" +VERSION="0.4" +LIST_NAME="thunix-join@lists.tildeverse.org" +ADMIN_EMAIL="root@thunix.net" +EMAIL_TEMPLATE="email.tmpl" +YAML_FILE="$1.yml" +# This one for team +# ZNC_USER="/home/znc/add_znc_user.sh" + +# This one for Thunix +ZNC_USER="/var/lib/znc/create-znc_account.sh" + +# Set location to your repo for ansible here +# It is only needed for thunix +REPO_LOCATION="~/repos/ansible" error_exit() { echo -e "${PROGNAME}: ${1:-"Unknown Error"}" >&2 @@ -20,10 +34,10 @@ sub_to_list() { echo " From: $1 Subject: subscribe -" | sudo -u $1 sendmail tildeteam-join@lists.tildeverse.org +" | sudo -u $1 sendmail $LIST_NAME } -[[ $(id -u) != 0 ]] && error_exit "you must be the superuser to run this script." +[[ $(id -u) == 0 ]] && error_exit "Do not run this script as root." case $1 in -h | --help) @@ -35,13 +49,46 @@ case $1 in echo "adding new user $1" newpw=$(pwgen -1B 10) pwcrypt=$(perl -e "print crypt('${newpw}', 'sa');") - useradd -m -g 100 -p $pwcrypt -s /bin/bash $1 || exit 1 - - sed -e "s/newusername/$1/g" -e "s/newpassword/$newpw/" email.tmpl | sendmail $1 $2 sudoers@tilde.team + sudo useradd -m -g 100 -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 sub_to_list $1 - sudo -u znc /home/znc/add_znc_user.sh $1 + +# This line is for team +# sudo -u znc /home/znc/add_znc_user.sh $1 +# This one is for Thunix + sudo $ZNC_USER $1 $newpw echo "$3" | tee /home/$1/.ssh/authorized_keys - toot "welcome new user ~$1!" ;; + +# If root doesn't have a fediverse account, comment this out + sudo toot "welcome new user ~$1!" + +#Thunix specific section + echo "--- +- name: Setting up $1 + user: + name: $1 + groups: tilde + state: present + skeleton: /etc/skel + shell: /bin/bash + system: no + createhome: yes + home: /home/$1 +- authorized_key: + user: $1 + state: present + key:'$3'" > $REPO_LOCATION/roles/shell/tasks/users/$YAML_FILE + + echo -e "- include: users/$YAML_FILE\n" >> $REPO_LOCATION/roles/shell/tasks/users.yml + place=`pwd` + cd $REPO_LOCATION + git add $REPO_LOCATION/roles/shell/tasks/users.yml + git commit -am "Adding user $1" + git push + cd $place +# End Thunix specific section + ;; + esac