Last active
March 30, 2021 12:24
-
-
Save hey-jude/23388f707cbf226543420187fae93b77 to your computer and use it in GitHub Desktop.
sync worker nodes (config passwordless ssh before exec.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $# -ne 1 ]]; then | |
echo "Usage: syncDir.sh <path>" >&2 | |
exit 1 | |
fi | |
ABS_PATH_COMMAND="readlink -f" | |
if [[ $(uname -s) = "Darwin" ]] | |
then | |
ABS_PATH_COMMAND="realpath" | |
fi | |
WORKERS=$(cat $HOME/bin/workers | grep -v '^#') | |
DIR=$(${ABS_PATH_COMMAND} $1) | |
DIR=$(echo ${DIR}|sed 's@/$@@') | |
DEST=$(dirname ${DIR}) | |
SSH_OPTS="-o StrictHostKeyChecking=no -o ConnectTimeout=5" | |
echo "RSYNC'ing ${DIR} to workers..." | |
for worker in ${WORKERS}; do | |
echo ${worker} | |
rsync -e "ssh ${SSH_OPTS}" -az ${DIR} ${worker}:${DEST} & sleep 0.05 | |
done | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment