@ -145,4 +145,94 @@ Al termine della configurazione avviare il servizio:
```bash
sudo systemctl start slurmctld
sudo systemctl start slurmd
```
```
### Creazione utenti
Affinché un programma possa essere lanciato su tutti i nodi è necessario che l'**utente** sia disponibile su ciascuno di essi, il seguente script si occupa di replicare l'utente ovunque sia necessario:
```bash
#!/bin/bash
#
# Add a SLURM user to the Steffè cluster
# A good place for this script is in:
# /usr/local/bin/cluster-users
set -e
cluster_hosts="steffe0 steffe1 steffe2 steffe3 steffe4 steffe5 steffe6 steffe7 steffe8 steffe9 steffe10 steffe11 steffe12 steffe13 steffe14 steffe15 steffe16 steffe17 steffe18 steffe19"
function help {
echo "Usage: $0 COMMAND username"
echo ""
echo "Examples: "
echo " -) $0 --add utente"
echo " -) $0 --delete utente"
}
function add_user {
if [ "$1" == "" ]; then
echo "Specify a valid username for the new user"
exit 1
fi
if [ "$2" != "" ]; then
echo "Unsupported option specified"
exit 1
fi
adduser $1
# We obtain the UID of the new user, as the last line at the end
# of passwd
userid=$(grep $1 /etc/passwd | tail -n1 | cut -d ':' -f3)
for h in ${cluster_hosts}; do
echo -n "Creating the user $1 on $h ... "
ssh ${h} useradd -u ${userid} $1
echo "done"
done
}
function del_user {
if [ "$1" == "" ]; then
echo "Specify a valid username to delete"
exit 1
fi
if [ "$2" != "" ]; then
echo "Unsupported option specified"
exit 1
fi
echo -n "This command will remove the user $1, proceed? [yn]: "
read ans
if [ "$ans" != "y" ]; then
echo "Exiting"
exit 0
fi
userdel -f $1
for h in ${cluster_hosts}; do
echo -n "Creating the user $1 on $h ... "
ssh ${h} userdel -f $1
echo "done"
done
echo "Note: the home directory /home/$1 has been preserved,"
echo " you may wish to delete that as well."
}
if [ "$1" == "--add" ]; then
add_user $2
exit 0
fi
if [ "$1" == "--delete" ]; then
del_user $2
exit 0
fi
help
```