Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #This program is free software; you can redistribute it and/or modify
- #it under the terms of the GNU General Public License as published by
- #the Free Software Foundation; either version 2 of the License, or
- #(at your option) any later version.#
- #This program is distributed in the hope that it will be useful,#but WITHOUT ANY WARRANTY; without even the implied warranty of
- #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the#GNU General Public License for more details.
- #
- #You should have received a copy of the GNU General Public License
- #along with this program; if not, write to the Free Software#Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- if [ $(whoami) = "root" ]
- then
- echo "This script must be run as admin" exit 0
- fi
- servers=(
- 0.0.0.0
- );
- #use sort's -X (sort by extension) flag and the fact that "gif", and "jpg" come before "php" alphabetically
- #to push out images before php files so we don't end up with pages missing images
- # the -r in xargs tells it to not run 'ls' if there are no results
- #changeLog=`find /home/httpd/vhosts/*.com/httpdocs/ -type f ! -group pushed | xargs -r ls -X `
- begin=`date`
- while :
- do
- start="`date`"
- counter=0
- #To start a process with nice, run nice -n nicevalue command arguments where nicevalue is a number
- #between 1 and 19, and command and arguments are the command you want to run and its arguments. The
- #larger the number given to nice, the lower the priority command is given. Note that only the root
- #user can increase priority with nice.
- echo "Generating file list ..."
- #changeLog=`nice find /home/httpd/vhosts/*.com/httpdocs/ -type f ! -group pushed`
- changeLog=`find /home/httpd/vhosts/*.com/httpdocs/ -type f ! -group pushed`
- for f in ${changeLog[@]}
- do
- if [ -e $f ] ; then
- for server in ${servers[@]}
- do
- echo "$f --> $server"
- # The -R in rsync preserves the file paths and creates dirs if they're not on the target
- rsync -R -e ssh "$f" admin@$server:/
- done
- sudo chgrp pushed "$f"
- let "counter+=1"
- else
- echo "Bad file name setting to ignore: $f"
- sudo chgrp pushed $f*
- fi
- done
- echo "---------------------"
- echo " running since: $begin"
- echo " start: $start"
- echo " end: `date`"
- echo " files pushed: $counter"
- echo " Remember to exit screen nicely so this keeps running with Ctrl+a d"
- echo " See ctrl+a ? for help on screen"
- echo "---------------------"
- sleep 1
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement