-
Notifications
You must be signed in to change notification settings - Fork 1
/
createuser
executable file
·113 lines (92 loc) · 3.15 KB
/
createuser
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env bash
set -e
export LC_ALL=C
PLATFORM=""
ACL=""
# Make sure we have a userid to create
if [ "$#" -ne "1" ];
then
echo "Run \"createuser userid\"" 1>&2
exit 1
fi
# Check that the userid starts with a letter and is alphanumeric, 7 chars
if echo $1 | grep -qE '^[[:lower:]][[:lower:][:digit:]]{6}$' ;
then
echo "Valid user string: $1" 1>&2
else
echo "Invalid user string: $1" 1>&2
echo "Run \"createuser userid\"" 1>&2
exit 1
fi
# Work out where we are
</opt/sge/default/common/cluster_name read -r PLATFORM || (echo "Error: could not determine cluster." >&2; exit 1)
case "$PLATFORM" in
"grace")
ACL="Open"
;;
"legion")
ACL="Open"
;;
"kathleen")
ACL="Open"
;;
"myriad")
ACL="Open"
;;
"thomas"|"michael"|"young")
echo "Error: this is not the correct way to add users to the Thomas and Michael clusters." >&2
exit 1
;;
*)
echo "Error: unknown cluster: $PLATFORM" >&2
exit 1
;;
esac
if [[ "$PLATFORM" == "legion" ]]; then
echo "Reminder: new accounts unassociated with existing paid projects
are no longer to be created on Legion (as of 2019-01-01). "
read -r -p "Are you sure you want to create this account? Please type 'yes' if so: " response
if [[ "$response" != "yes" ]]; then
echo "Okay, stopping."
exit
fi
fi
if [[ "$PLATFORM" == "grace" ]]; then
echo "Reminder: new accounts are no longer to be created on Grace."
read -r -p "Are you sure you want to create this account? Please type 'yes' if so: " response
if [[ "$response" != "yes" ]]; then
echo "Okay, stopping."
exit
fi
fi
echo "creating account for $1"
qconf -au "$1" "$ACL"
echo "Emailing user ${RECIPIENT}"
/usr/sbin/sendmail -t<<EOF
From: [email protected]
To: ${RECIPIENT}
Subject: ${PLATFORM^} account
We are happy to confirm that your account to use the Research Computing ${PLATFORM^}
HPC cluster is now active. You should be able to log in within 5 minutes of
receiving this email.
Please find below some information to help get you get started in your use of
the system.
GETTING HELP
Information to help you get started in using ${PLATFORM^} is available at
https://www.rc.ucl.ac.uk/docs/
including a user guide covering all of our systems.
ANNOUNCEMENTS
Emails relating to planned outages, service changes etc will be sent to the
${PLATFORM}[email protected] email list. You have been subscribed to this
list using the email address associated with your main UCL userid - please
make sure that you read all notices sent to this address promptly and
observe the requests/guidelines they contain.
If you use a different email address for most of your correspondence, it is
a condition of your account that you configure your UCL email account to
have email redirected to an address of your choosing.
Please see https://www.ucl.ac.uk/isd/how-to/set-forwarding-using-outlook-web-access-owa
for further information on email forwarding.
If you have any queries relating to this information please email the
support address [email protected].
EOF