Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #This program is free software; you can redistribute it and/or modify
  4. #it under the terms of the GNU General Public License as published by
  5. #the Free Software Foundation; either version 2 of the License, or
  6. #(at your option) any later version.#
  7. #This program is distributed in the hope that it will be useful,#but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the#GNU General Public License for more details.
  9. #
  10. #You should have received a copy of the GNU General Public License
  11. #along with this program; if not, write to the Free Software#Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  12.  
  13.  
  14. if [ $(whoami) = "root" ]
  15. then
  16. echo "This script must be run as admin" exit 0
  17. fi
  18.  
  19. servers=(
  20. 0.0.0.0
  21. );
  22.  
  23.  
  24. #use sort's -X (sort by extension) flag and the fact that "gif", and "jpg" come before "php" alphabetically
  25. #to push out images before php files so we don't end up with pages missing images
  26. # the -r in xargs tells it to not run 'ls' if there are no results
  27. #changeLog=`find /home/httpd/vhosts/*.com/httpdocs/ -type f ! -group pushed | xargs -r ls -X `
  28.  
  29. begin=`date`
  30. while :
  31. do
  32. start="`date`"
  33. counter=0
  34. #To start a process with nice, run nice -n nicevalue command arguments where nicevalue is a number
  35. #between 1 and 19, and command and arguments are the command you want to run and its arguments. The
  36. #larger the number given to nice, the lower the priority command is given. Note that only the root
  37. #user can increase priority with nice.
  38. echo "Generating file list ..."
  39. #changeLog=`nice find /home/httpd/vhosts/*.com/httpdocs/ -type f ! -group pushed`
  40. changeLog=`find /home/httpd/vhosts/*.com/httpdocs/ -type f ! -group pushed`
  41. for f in ${changeLog[@]}
  42. do
  43. if [ -e $f ] ; then
  44. for server in ${servers[@]}
  45. do
  46. echo "$f --> $server"
  47. # The -R in rsync preserves the file paths and creates dirs if they're not on the target
  48. rsync -R -e ssh "$f" admin@$server:/
  49. done
  50. sudo chgrp pushed "$f"
  51. let "counter+=1"
  52. else
  53. echo "Bad file name setting to ignore: $f"
  54. sudo chgrp pushed $f*
  55. fi
  56. done
  57. echo "---------------------"
  58. echo " running since: $begin"
  59. echo " start: $start"
  60. echo " end: `date`"
  61. echo " files pushed: $counter"
  62. echo " Remember to exit screen nicely so this keeps running with Ctrl+a d"
  63. echo " See ctrl+a ? for help on screen"
  64. echo "---------------------"
  65.  
  66. sleep 1
  67. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement