This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Maintenance Mode for sites

By: loganbest on Jan 10th, 2013  |  syntax: Bash  |  size: 1.24 KB  |  views: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. if [ ! -n "$1" ]
  4. then
  5.     echo "Usage: to turn on maintenance mode:"
  6.     echo "`basename $0` on"
  7.     echo "Usage: to turn off maintenance mode:"
  8.     echo "`basename $0` off"
  9.     echo "Usage: to get the status of maintenance mode:"
  10.     echo "`basename $0` status"
  11.     exit $E_BADARGS
  12. fi
  13.  
  14. arg=$1
  15. case $arg in
  16.     on)
  17.         for D in $(find . -mindepth 1 -maxdepth 1 -type d -not -name 'hostnamedirectory') ; do
  18.             touch $D"/.maintenance_mode";
  19.             echo "Maintenance Mode turned on for "`basename $D`;
  20.         done
  21.         ;;
  22.     off)
  23.         for D in $(find . -mindepth 1 -maxdepth 1 -type d -not -name 'hostnamedirectory') ; do
  24.             rm $D"/.maintenance_mode";
  25.             echo "Maintenance Mode turned off for "`basename $D`;
  26.         done
  27.         ;;
  28.     status)
  29.         result=$(find . -mindepth 1 -maxdepth 1 -type d -not -name 'hostnamedirectory')
  30.         for i in $result
  31.             do
  32.             cd "$i"
  33.             if [ -e ".maintenance_mode" ]
  34.             then
  35.                 echo "Maintenance Mode is ON for "`basename $i`
  36.             else
  37.                 echo "Maintenance Mode is OFF for "`basename $i`
  38.             fi
  39.             cd - > /dev/null
  40.         done
  41.         ;;
  42. esac
clone this paste RAW Paste Data