#! /bin/bash # Script to add an user in the cluster. # Launch this script as su in the frontend to add an user across all nodes in the cluster. # All nodes in the cluster are assumed to have been connected and active # Prompt for adding an user ID read -p "User ID to add " user if [[ -d /share/home/$user ]]; then echo "/share/home/$user exists. Will not creat any."; else useradd -d /share/home/$user $user; usermod -g users; passwd $use; fi #if [[ -d /share/home/$user ]]; then echo "/share/home/$user exists. Will not creat any."; else echo /share/home/$user $user; usermod -g users; echo groups $user; fi HOSTNAME=$(cat /etc/hostname) hosts=$(cat /etc/hosts | grep 192 | awk {'print $1}') for rn in $hosts do ### remotely creat a user in the remote node echo 'Be careful: Please provide the right password when prompted.' echo 'Be careful: Please provide the root password to enter' $rn ssh root@$rn "if [[ -f /share/home/$user ]]; then echo "/share/home/$user exists. Will not creat any."; else useradd -d /share/home/$user $user ; usermod -g users; echo 'Please key in the new password for user '$user ; passwd $user ; fi" done