#! /bin/bash # to sync the password of all users (except for root) across all nodes in the cluster (except in the frontend) coc-sshreachable #hosts=$(cat /share/tmp/ssh-reachable.dat) declare -a hosts=($(cat /share/tmp/ssh-reachable.dat | awk '{if ($1 != "192.168.1.10") print $1}')) #declare -a hosts=c26 #($(cat /share/tmp/ssh-reachable.dat)) #($(cat /etc/hosts | awk 'NF==4 {print $4}' | uniq | sort)) alh=${#hosts[@]} declare -a username=($(cat /etc/passwd | awk -F":" '{print $1, $3}' | awk '{if($2>=1000 && $2<4000) {print $1}}')) declare -a uid=($(cat /etc/passwd | awk -F":" '{print $1, $3}' | awk '{if($2>=1000 && $2<4000) {print $2}}')) alength=${#username[@]} for (( i=1; i<${alength}+1; i++ )); do ####################################### ### to abstract the password of ${username[$i-1]} from /share/apps/configrepo/users_data/userpass.xx.dat number=$(ls /share/apps/configrepo/users_data/userpass.* | awk -F "." '{print $2}' | sort | awk 'END {print}') taf=/share/apps/configrepo/users_data/userpass.$number.dat #echo $taf passwd=$(cat $taf | grep "${username[$i-1]}" | awk '{print $4}') # echo ${username[$i-1]} $passwd ####################################### echo 0000 ${username[$i-1]} ${uid[$i-1]} $passwd > /share/apps/configrepo/users_data/newuser.dat for (( j=1; j<${alh}+1; j++ )); do ################## # echo $i ${username[$i-1]} ${uid[$i-1]} $passwd ${hosts[$j-1]} ssh -oStrictHostKeyChecking=no ${hosts[$j-1]} "coc-sync-passwd-local" echo ' ' ################## done done