#!/usr/local/bin/bash # --------------------------------------------------------------------------- # makeuser - tilde.institute new user creation # Usage: makeuser [-h|--help] "" # ben@gbmor.dev # --------------------------------------------------------------------------- PROGNAME=${0##*/} VERSION="0.1" error_exit() { echo -e "${PROGNAME}: ${1:-"Unknown Error"}" >&2 exit 1 } usage() { echo -e "usage: $PROGNAME [-h|--help] \"\"" } [[ $(id -u) != 0 ]] && error_exit "you must be the superuser to run this script." USERLIST=$( /etc/httpd/$1.conf # add the user's vhost config to # the main httpd config then gracefully # reload the httpd config echo "include \"/etc/httpd/$1.conf\"" >> /etc/httpd-vusers.conf httpdpid=`pgrep httpd | awk 'NR==1{print $1}'` kill -HUP $httpdpid # send welcome email sed -e "s/newusername/$1/g" /admin/misc/email.tmpl | doas -u admins mail -s "welcome to tilde.institute!" $2 # subscribe to mailing list echo " " | doas -u $1 mail -s "subscribe" institute-join@lists.tildeverse.org # announce the new user's creation on mastodon # then copy their ssh key to their home directory /admin/bin/toot.py "Welcome new user ~$1!" echo "$3" | tee /home/$1/.ssh/authorized_keys esac