Last active
August 29, 2015 14:10
-
-
Save tuxfight3r/2767954b71b8e774e086 to your computer and use it in GitHub Desktop.
sync apache configs/ via git and www folders between nodes
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
########### apache-sync.sh | |
#!/bin/bash | |
#Purpose:To update apache configs via git to the rest of the apache servers | |
#Note: This script should only be run from node01 to keep things consistent | |
#Date: 11/09/2014 | |
#Author: Mohan | |
#HOST IPS are read from hosts file in the current dir | |
. hosts | |
echo "Pushing configs to git repo" | |
git push origin master | |
[ $? -eq 0 ] && echo "Push Completed" || { echo "ERROR: Uploading Configs check gitrepo/nework" && exit 2; } | |
echo "\n\n" | |
for host in $MOD_HOSTS; | |
do echo -e "Updating Host ${host}:\n" | |
ssh -q -l root ${host} "{ cd /etc/httpd; git status; git pull; apachectl -t; \ | |
[ \$? -eq 0 ] && service httpd reload || \ | |
echo -e "\n Error updating configs in host $host. Please check Manually and reload apache"; };" | |
done | |
######HOSTS | |
[root@node01 httpd (master)]# cat hosts | |
#SSH Keys based auth should be in place for it to work. | |
MOD_HOSTS="10.8.0.2 10.8.0.3" | |
###########www-sync.sh | |
#!/bin/bash | |
#Purpose:To keep /var/www folders between machines in sync via rsync | |
#Note: This script should only be run from node01 to keep things consistent | |
#Date: 15/09/2014 | |
#Author: Mohan | |
#HOST IPS are read from hosts file | |
. hosts | |
for host in $MOD_HOSTS; | |
do | |
echo -e "\nUpdating /var/www in Host ${host}:\n" | |
cd /var/www; | |
rsync -avzr --progress * -e "ssh -q" root@${host}:/var/www/ | |
echo -e "done\n" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment