#!/bin/bash #push global config from one cell to all cells set -e #exit on error, like python DEBUG=1 main() { ME=`getme` debug "I am $ME" update_known_host $ME transfer $ME } getme() { cd /etc/allcells for i in *; do if [ -L "$i" ] && ls -l --color=no "$i" |grep -- '->.*/etc/cell' &>/dev/null ; then ME="$i" fi done echo "$ME" } transfer() { cd /etc/allcells for cell in *; do [ $cell = $1 ] && continue echo "transferring to $cell" scp -o "UserKnownHostsFile /admin/package/transfer/known_hosts" -o "GlobalKnownHostsFile /etc/allcells/$cell/known_host" \ -i /home/transfer/.ssh/id_rsa -r /etc/allcells/$1 transfer@"$cell":/etc/allcells/ done } update_known_host() { echo -n "$1 " > /etc/cell/known_host cat /etc/ssh/ssh_host_key.pub >> /etc/cell/known_host debug "updated /etc/cell/known_host" } debug() { [ "$DEBUG" = 1 ] && echo "$@" } main