We might need some commands which can be run together across all servers in the cluster.
function otherpis {
grep "pi" /etc/hosts | awk '{print $2}' | grep -v $(hostname)
}
clustercmd() {
for pi in $(otherpis)
do
echo "ssh $pi $@"
ssh $pi "$@"
done
echo "$@"
eval $@
}
clustercmd date
clustercmd 'sudo apt install htpdate -y > /dev/null 2>&1'
clustercmd sudo htpdate -a -l time.nist.gov
function clusterreboot {
clustercmd sudo shutdown -r now
}
function clustershutdown {
clustercmd sudo shutdown now
}
clusterscp() {
for pi in $(otherpis); do
cat $1 | ssh $pi "sudo tee $1" > /dev/null 2>&1
done
}