finished actions => handlers refacto, small bux fix in maestro => Test maestro1 OK
This commit is contained in:
Executable
+75
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
|
||||
GOD_FOLDERS="Maestro GPS Observer"
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# shellcheck source=lib/resolveConfigPath.sh
|
||||
. "$ROOT/lib/resolveConfigPath.sh"
|
||||
|
||||
CONFIG="config.json"
|
||||
|
||||
usage() {
|
||||
echo "Usage: $(basename "$0") [-c|--config PATH]" >&2
|
||||
echo " PATH is relative to $ROOT unless absolute." >&2
|
||||
}
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-c|--config)
|
||||
if [ -z "${2:-}" ]; then
|
||||
echo "Missing value for $1" >&2
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
CONFIG="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
CONFIG="$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
CONFIG="$(resolveConfigPath "$ROOT" "$CONFIG")"
|
||||
|
||||
if [ ! -f "$CONFIG" ]; then
|
||||
echo "Config file not found: $CONFIG" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
failed=0
|
||||
|
||||
for folder in $GOD_FOLDERS; do
|
||||
dir="$ROOT/$folder"
|
||||
if [ ! -d "$dir" ]; then
|
||||
echo "Missing daemon folder: $dir" >&2
|
||||
failed=1
|
||||
continue
|
||||
fi
|
||||
|
||||
shopt -s nullglob
|
||||
scripts=("$dir"/start*.sh)
|
||||
shopt -u nullglob
|
||||
|
||||
if [ ${#scripts[@]} -eq 0 ]; then
|
||||
echo "No start script in $dir" >&2
|
||||
failed=1
|
||||
continue
|
||||
fi
|
||||
if [ ${#scripts[@]} -gt 1 ]; then
|
||||
echo "Multiple start scripts in $dir, using ${scripts[0]}" >&2
|
||||
fi
|
||||
|
||||
echo "=== Starting $folder (config=$CONFIG) ==="
|
||||
(cd "$dir" && bash "${scripts[0]}" "$CONFIG") || {
|
||||
echo "Failed to start $folder" >&2
|
||||
failed=1
|
||||
}
|
||||
done
|
||||
|
||||
exit $failed
|
||||
Reference in New Issue
Block a user