Skip to content

Instantly share code, notes, and snippets.

@lasryaric
Created May 31, 2012 01:02
Show Gist options
  • Select an option

  • Save lasryaric/2840001 to your computer and use it in GitHub Desktop.

Select an option

Save lasryaric/2840001 to your computer and use it in GitHub Desktop.
Cross server configuration script
#!/bin/bash
# You can synchronize the configuration of multiple servers using git and this very small script.
# Just add your servers in a file called "serverlist.txt" (one per line) and
# configure git on the $REMOTE_DIRECTORY_CONFIG. Personnaly, I use the root of the server (/)
# You can also use git hook post-update to run a command after the update
# of the config files if you wish.
SERVERS_FILE="serverlist.txt"
REMOTE_DIRECTORY_CONFIG="/"
POST_UPDATE_COMMAND="echo update ok"
servers=( $( cat $SERVERS_FILE ) )
for server in ${servers[*]}
do
ssh $server "cd $REMOTE_DIRECTORY_CONFIG && git pull && $POST_UPDATE_COMMAND"
echo "Done with $server"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment