Skip to content

Instantly share code, notes, and snippets.

@jiphex
Created October 3, 2011 10:19
Show Gist options
  • Save jiphex/1258830 to your computer and use it in GitHub Desktop.
Save jiphex/1258830 to your computer and use it in GitHub Desktop.
Propagate Things by Shell/rsync
#!/bin/sh
#
# SERVICES is a space-separated list of services to reload
# FILES is a list of configuration files to propagate from localhost to $HOSTS
# HOSTS is a list of servers to propagate things to.
#
# Assumes that some kind of passwordless SSH is already setup.
RELOADSERVICES=""
RESTARTSERVICES="varnish"
FILES="/etc/sysconfig/varnish /etc/varnish/default.vcl /tmp/test.txt /etc/sysctl.conf"
HOSTS="10.0.0.1 10.0.0.2 10.0.0.3"
for h in $HOSTS; do
for f in $FILES; do
rsync -vaPh $f root@$h:$f
done
for s in $RELOADSERVICES; do
ssh $h service $s reload
done
for s in $RESTARTSERVICES; do
ssh $h service $s restart
done
ssh $h sysctl -p
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment