openrat-cms

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

commit 40a92e1a0733a855b672362e23ab706f7fe59b2a
parent ed3d7482d44914267369e826a7dc5cf7dc4924d0
Author: Jan Dankert <develop@jandankert.de>
Date:   Sat, 17 Oct 2020 01:10:24 +0200

New: A helper script for setting up all watches for frontend development.

Diffstat:
Mdev-helper/update.sh | 9+++++++--
Adev-helper/watch-all.sh | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/dev-helper/update.sh b/dev-helper/update.sh @@ -82,6 +82,9 @@ function make_writable { esac } +# Kill child processes on CTRL+C +trap 'echo "Terminating child processes"; pkill -P $$; exit' SIGINT SIGTERM + while true; do # Calling compiler first make_writable $type $theme @@ -92,7 +95,7 @@ while true; do exit 0; # Exit, because watching is not enabled fi; - echo "waiting for changes ..." + echo "Enabling the watcher ..." case $type in lang ) watchfiles="../modules/language/language.yml";; xsd ) watchfiles="../modules/template_engine/components/html";; @@ -101,7 +104,9 @@ while true; do tpl ) watchfiles="../modules/cms/ui/themes/$theme/html/views/";; * ) echo "unknown type";exit;; esac - inotifywait --event modify -r $watchfiles + inotifywait --event modify -r $watchfiles & + echo "Waiting for watcher ..." + wait echo "a file was changed. updating ..." done diff --git a/dev-helper/watch-all.sh b/dev-helper/watch-all.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +cd "$(dirname "$0")" + +# Calling the update script for all types. +# +# Need for: +# - inotify-tools +# - curl +# - getopt +# +# On Ubuntu/Debian install them with 'apt-get install inotify-tools curl'. +# + + +usage() { + echo "Usage: $0 [-u <host/path>]" 1>&2; + exit 1; +} + +url="http://localhost/" +type= + +while getopts "hu:" o; do + case "${o}" in + h) + usage; exit 1; + ;; + u) + url=${OPTARG} + ;; + *) + usage + ;; + esac +done +shift $((OPTIND-1)) + +# Kill child processes on CTRL+C +trap 'echo "Terminating child processes... ";pkill -P $$' SIGINT SIGTERM + +for type in "tpl" "xsd" "css" "js" "lang"; do + ./update.sh -u $url -x $type -w 2>&1 & + echo "Started watcher for $type in background with PID $!" +done + +echo "." +echo "All Watches are started." + +echo "Waiting for child processes - Press CTRL + C to exit." + +wait # wait for child processes (forever, so the script must be canceled with SIGINT (ctrl+c) or SIGTERM) + +echo "All child processes are terminated. Exiting ..."