+script to create an account

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-04-08 14:22:32 +02:00
parent 34c8e2f776
commit 2d9ced0b24
1 changed files with 99 additions and 0 deletions

99
eth/user/account_create Executable file
View File

@ -0,0 +1,99 @@
#!/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 <http://www.gnu.org/licenses/>.
#
#
# 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: <username> <ou> <class> <responsible account> <expiry-date> [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.
Example: NETHZ_USERNAME="nicosc" $0 asteven roscoe staff nicosc 31-DEC-2023
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"
to="nicosc@ethz.ch"
from="${NETHZ_USERNAME}@ethz.ch"
account="$1"; shift
ou="$1"; shift
class="$1"; shift
responsible="$1"; shift
expiry="$1"; shift
comment="$@"
cat << eof | $sendmail -f "$from" $to
To: systems-sysadmins@lists.inf.ethz.ch
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