From 4633ee9dd3a8c86c83fad3619d63d4827c12bf6a Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Fri, 28 Jun 2019 11:18:20 -0400 Subject: [PATCH] tidy up and add makefile --- Makefile | 16 ++++++++++++++++ makeuser | 19 ++++++++++++++----- email.tmpl => welcome-email.tmpl | 24 ++++++++++++------------ 3 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 Makefile rename email.tmpl => welcome-email.tmpl (59%) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6f89396 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +PREFIX ?= /usr/local +BINDIR ?= $(PREFIX)/bin + +install: + @echo Installing the executable to $(BINDIR) + @mkdir -p $(BINDIR) + @install -m 755 makeuser $(BINDIR) + @install -m 644 welcome-email.tmpl $(BINDIR) + +uninstall: + @echo Removing the executable from $(BINDIR) + @rm -f $(BINDIR)/makeuser + @rm -f $(BINDIR)/welcome-email.tmpl + +.PHONY: install uninstall + diff --git a/makeuser b/makeuser index 3470d22..769ce93 100755 --- a/makeuser +++ b/makeuser @@ -23,8 +23,6 @@ Subject: subscribe " | sudo -u $1 sendmail tildeteam-join@lists.tildeverse.org } -[[ $(id -u) != 0 ]] && error_exit "you must be the superuser to run this script." - case $1 in -h | --help) usage; exit ;; @@ -32,16 +30,27 @@ case $1 in usage; error_exit "unknown option $1" ;; *) [[ $# -ne 3 ]] && error_exit "not enough args" + 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 + sudo useradd -m -g 100 -p "$pwcrypt" -s /bin/bash $1 \ + || error_exit "couldn't add user" - sed -e "s/newusername/$1/g" -e "s/newpassword/$newpw/" email.tmpl | sendmail $1 $2 sudoers@tilde.team + echo "sending welcome mail" + sed -e "s/newusername/$1/g" -e "s/newpassword/$newpw/" welcome-email.tmpl \ + | sendmail $1 $2 sudoers@tilde.team + + echo "subscribing to mailing list" sub_to_list $1 + + echo "creating znc account" sudo -u znc /home/znc/add_znc_user.sh $1 - echo "$3" | tee /home/$1/.ssh/authorized_keys + echo "adding ssh pubkey" + echo "$3" | sudo tee /home/$1/.ssh/authorized_keys + + echo "announcing new user on mastodon" toot "welcome new user ~$1!" ;; esac diff --git a/email.tmpl b/welcome-email.tmpl similarity index 59% rename from email.tmpl rename to welcome-email.tmpl index 2c07303..b335ea4 100644 --- a/email.tmpl +++ b/welcome-email.tmpl @@ -11,9 +11,6 @@ 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 @@ -22,20 +19,23 @@ 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) +your ~/public_html directory is served at https://tilde.team/~newusername/ +(you can also use https://newusername.tilde.team). see https://tilde.wiki/?page=tildepages +for more info. -check out our wiki at https://tilde.team/wiki/ for more information (and +check out our wiki at https://tilde.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) +tilde servers. 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. + +note that when you first log in, you'll enter a byobu session, which is a terminal +multiplexer (see https://superuser.com/a/423397/866501 for info) with weechat and +mutt already open for you. if you're familiar with tmux, you can use it as usual, +replacing ctrl-b with ctrl-a. otherwise, you can disable the autolaunch with the +byobu-disable command. feel free to holler on the mailing list or on irc if you +have any questions or need help! we look forward to seeing you around! welcome to the ~team!