Commit 47541e3f authored by Haarst, Jan van's avatar Haarst, Jan van
Browse files

Add users to database when added to group

parent c5cb011b
#!/bin/bash
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
set -o nounset
set -o errexit
......@@ -23,6 +25,7 @@ DN_ARRAY["VIR"]="CN=USR_BIOINF_VIR,OU=BioInformatics,OU=NoPolicy,OU=Servers,DC=w
DN_ARRAY["BIF"]="CN=USR_BIOINF_BIF,OU=BioInformatics,OU=NoPolicy,OU=Servers,DC=wurnet,DC=nl"
DN_ARRAY["AB"]="CN=USR_BIOINF_AB,OU=BioInformatics,OU=NoPolicy,OU=Servers,DC=wurnet,DC=nl"
DB="${SCRIPTPATH}"/users.sqlite3.db
# Functions
......@@ -104,8 +107,13 @@ do
chown --verbose ${NEW_USER}:'domain users' $dir
fi
done
# TODO Add user to database/Google Docs sheet.
# Add user to database.
if [ -e "$DB" ]
then
echo "Adding $NEW_USER to database $DB"
# ACCOUNT|DEPARTMENT|SUPERVISOR|ADDED_BY|ENTRY_DATE|END_DATE
sqlite3 -batch "$DB" "insert into users (ACCOUNT,DEPARTMENT,ADDED_BY,SUPERVISOR,END_DATE) values ('"${NEW_USER}"','"${DN_AVAIL}"','"${SUDO_USER}"','','');"
fi
# TODO mail this automatically, using the right return adress
echo "Use this as mail template to mail $MAIL :"
echo
......
CREATE TABLE IF NOT EXISTS users
(
ID INTEGER PRIMARY KEY,
ACCOUNT TEXT NOT NULL,
DEPARTMENT TEXT NOT NULL,
SUPERVISOR TEXT,
ADDED_BY TEXT,
ENTRY_DATE DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
END_DATE DATETIME
);
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment