-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreateuser
executable file
·140 lines (118 loc) · 4.22 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env bash
set -e
export LC_ALL=C
cluster_name="${CLUSTER_NAME:-}"
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
if [[ -n "$cluster_name" ]]; then
# Allow overriding cluster_name for testing/whatever
echo "Warning: cluster name overridden as \"$cluster_name\"" >&2
cluster_name="$cluster_name"
elif [[ -r /opt/sge/default/common/cluster_name ]]; then
cluster_name="$(cat /opt/sge/default/common/cluster_name)"
elif command -v sacctmgr >/dev/null; then
cluster_name="$(sacctmgr -pn list cluster | cut -f 1 -d '|')"
elif [[ -r /shared/ucl/etc/cluster_name ]]; then
cluster_name="$(cat /shared/ucl/etc/cluster_name)"
else
echo "Error: could not find a way to determine cluster name." >&2
exit 1
fi
case "$cluster_name" 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: $cluster_name" >&2
exit 1
;;
esac
if [[ "$cluster_name" == "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 [[ "$cluster_name" == "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"
if command -v qconf >/dev/null; then
qconf -au "$1" "$ACL"
elif command -v sacctmgr >/dev/null; then
echo "Slurm user adding is not yet implemented since the details of cluster implementation have not yet been finalised."
echo "You'll need the sacctmgr command, probably something like this:"
echo ""
echo " sacctmgr add user name=\"\$username\""
echo ""
echo "You'll also need at least Operator privileges on Slurm. (Or sudo access to get them.)"
exit 1
else
echo "Error: no mechanism for adding users found." >&2
exit 1
fi
echo "Emailing user ${RECIPIENT}"
/usr/sbin/sendmail -t<<EOF
From: [email protected]
To: ${RECIPIENT}
Subject: ${cluster_name^} account
We are happy to confirm that your account to use the Research Computing ${cluster_name^}
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 ${cluster_name^} 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
${cluster_name}[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