Created
May 31, 2012 01:02
-
-
Save lasryaric/2840001 to your computer and use it in GitHub Desktop.
Cross server configuration script
This file contains hidden or 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 | |
| # 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