openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs | README

watch-all.sh (1067B)


      1 #!/bin/bash
      2 
      3 cd "$(dirname "$0")"
      4 
      5 # Calling the update script for all types.
      6 #
      7 # Need for:
      8 # - inotify-tools
      9 # - curl
     10 # - getopt
     11 #
     12 # On Ubuntu/Debian install them with 'apt-get install inotify-tools curl'.
     13 #
     14 
     15 
     16 usage() {
     17   echo "Usage: $0 [-u <host/path>]" 1>&2;
     18   exit 1;
     19 }
     20 
     21 url="http://localhost/"
     22 type=
     23 
     24 while getopts "hu:" o; do
     25     case "${o}" in
     26         h)
     27             usage; exit 1;
     28             ;;
     29         u)
     30             url=${OPTARG}
     31             ;;
     32         *)
     33             usage
     34             ;;
     35     esac
     36 done
     37 shift $((OPTIND-1))
     38 
     39 # Kill child processes on CTRL+C
     40 trap 'echo "Terminating child processes... ";pkill -P $$' SIGINT SIGTERM
     41 
     42 for type in "tpl" "xsd" "css" "js" "lang"; do
     43     ./update.sh -u $url -x $type -w 2>&1 &
     44     echo "Started watcher for $type in background with PID $!"
     45 done
     46 
     47 echo "."
     48 echo "All Watches are started."
     49 
     50 echo "Waiting for child processes - Press CTRL + C to exit."
     51 
     52 wait # wait for child processes (forever, so the script must be canceled with SIGINT (ctrl+c) or SIGTERM)
     53 
     54 echo "All child processes are terminated. Exiting ..."