#! /bin/bash # This script will scan all users in /etc/passwd of the frontend, compare them with the coressponding /etc/fstab entries in the local nodes. If no entry is found in the local version of /etc/fstab for a particular user, a line to mount the home directory of this user to the nfs will be added in /etc/fstab of the local node. declare -a name name=$(cat /etc/passwd | awk -F":" '$3>=1000 && $3<=9999 {print}' | awk -F":" '{print $1}') #echo ${name[@]} coc-sshreachable hosts=$(cat /share/tmp/ssh-reachable.dat | awk '{print}' | sed -e "s/anicca//g" | awk '$1!= "" ') echo $hosts for j in $hosts do for i in $name do state="i=\$(cat /etc/passwd | grep "$i" | awk -F":" '{print \$1}'); \ var=\$(cat /etc/fstab | grep \$i); \ if [ -z \"\$var\" ]; then st2='192.168.1.10:/home/$i /home/$i nfs nosuid,rw,sync,hard,intr 0 0' ; \ echo To add \$st2 into /etc/fstab of $j; cp /etc/fstab /etc/fstab.orig; echo \$st2 >> /etc/fstab ; fi \ " # echo 'before enter ssh' $state ssh $j $state done done ### hosts #cp /etc/fstab /etc/fstab.orig; echo \$st2 >> /etc/fstab ; fi \