A script that allows admins of thunix to make user accounts easily.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
makeuser/makedb

25 lines
681 B

#!/bin/bash
CONFIG=./setenv
. $CONFIG
. include/functions
USER=$1
PASSWORD=`pwgen -1B 24`
if [ $# -eq 2 ]
then
DATABASE=$2
else
DATABASE=$1
fi
if [ -z "$1" ]
then
echo -e "adding a new database for given username."
echo -e "usage: $(basename $0) <user name> [database name]"
else
database_create
sed -e "s/_username_/$USER/g" -e "s/_databasename_/$DATABASE/g" -e "s/_password_/$PASSWORD/g" include/dbemail.tmpl | sudo mail -s "Your database has been provisioned" $USER@thunix.net
sed -e "s/_username_/$USER/g" -e "s/_databasename_/$DATABASE/g" -e "s/_password_/$PASSWORD/g" include/dbemail.tmpl | sudo mail -s "Your database has been provisioned" $ADMIN_EMAIL
fi