#!/bin/sh
#
# 2011 Nico Schottelius (nico-nsbin at schottelius.org)
#
# This file is part of nsbin.
#
# nsbin is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# nsbin is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with nsbin. If not, see .
#
#
# Allow user to request an account
#
#
# Standard variables (stolen from cconf)
#
__pwd="$(pwd -P)"
__mydir="${0%/*}"; __abs_mydir="$(cd "$__mydir" && pwd -P)"
__myname=${0##*/}; __abs_myname="$__abs_mydir/$__myname"
if [ $# -lt 5 ]; then
cat << eof
$__myname: [comment]
username: The nethz username of the user to be created.
ou: organisational unit: One of alonso, donaldk, roscoe or tatbul
class: Either stud or staff
responsible account: The nethz username of the person responsible for the account
expiry-date: When the newly created account should expire.
The format is
{2-digit day of the month}-{JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC}-{4-digit year}
, e.g. 31-DEC-2005 (required by ISG).
comment: Optional, if you want to tell the sysadmins something special
Requires NETHZ_USERNAME to be set.
Examples:
NETHZ_USERNAME="nicosc" $0 asteven roscoe staff nicosc 31-DEC-2012
NETHZ_USERNAME="nicosc" $0 foobar donaldk stud nicosc 31-MAR-2014 And a funny day
eof
exit 1
fi
if [ -z "$NETHZ_USERNAME" ]; then
echo "Error: Set \$NETHZ_USERNAME to your username"
exit 1
fi
sendmail="/usr/sbin/sendmail"
to="systems-sysadmins@lists.inf.ethz.ch"
from="${NETHZ_USERNAME}@ethz.ch"
account="$1"; shift
ou="$1"; shift
class="$1"; shift
responsible="$1"; shift
expiry="$1"; shift
comment="$@"
# Also send to user
cat << eof | $sendmail -f "$from" $from $to
To: <$from>, <$to)
Subject: Create account $account in ou $ou
Sysadmin-Proxy: Check & forward this e-mail 1:1 to support@inf.ethz.ch.
Comment from user: $comment
Dear ISG, please execute
/usr/supp/accts/bin/user_tool \\
--create $account \\
--ou $ou \\
--class $class \\
--responsible $responsible \\
--expire $expiry
Cheers,
$USER
--
Send by ${__myname}
eof