-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreateuser
executable file
·122 lines (102 loc) · 3.55 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
#!/usr/bin/env bash
set -e
set -o nounset
export LC_ALL=C
cluster_name="${CLUSTER_NAME:-}"
SGE_ACL=""
slurm_account=""
# Make sure we have a userid to create
if [[ "$#" -ne "1" ]];
then
echo "Run \"createuser userid\"" 1>&2
exit 1
fi
username="$1"
# Check that the userid starts with a letter and is alphanumeric, 7 chars
if echo "$username" | grep -qE '^[[:lower:]][[:lower:][:digit:]]{6}$' ;
then
echo "Valid user string: ${username}" 1>&2
else
echo "Invalid user string: ${username}" 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
elif [[ -x /shared/ucl/sysops/libexec/clustname ]]; then
cluster_name="$(/shared/ucl/sysops/libexec/clustname)"
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
"kathleen")
SGE_ACL="Open"
slurm_account="allusers"
;;
"myriad")
SGE_ACL="Open"
slurm_account="allusers"
;;
dev-*)
slurm_account="allusers"
;;
"michael"|"young")
echo "Error: this is not the correct way to add users to the Young and Michael clusters." >&2
exit 1
;;
*)
echo "Error: unknown cluster: $cluster_name" >&2
exit 1
;;
esac
echo "creating account for ${username}"
if command -v qconf >/dev/null; then
if [[ -z "$SGE_ACL" ]]; then
echo "Error: detected SGE, but this cluster is not supposed to run SGE." >&2
exit 1
fi
qconf -au "${username}" "$SGE_ACL"
elif command -v sacctmgr >/dev/null; then
if [[ -z "${slurm_account}" ]]; then
echo "Error: detected Slurm, but this cluster is not supposed to run Slurm." >&2
exit 1
fi
sacctmgr --immediate --quiet add user name="${username}" defaultaccount="${slurm_account}"
else
echo "Error: no mechanism for adding users found." >&2
exit 1
fi
RECIPIENT="${username}@ucl.ac.uk"
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