epic-ts
[xhome.git] / xfhem / bin / xfhem
diff --git a/xfhem/bin/xfhem b/xfhem/bin/xfhem
new file mode 100755 (executable)
index 0000000..a1e6ad1
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+usage="xfhem [define|delete] watchdog [SERVER]"
+
+PATH="/opt/fhem:$PATH"
+
+function process_watchdog {
+       server=$1
+       case $operation in
+       define)
+               if [ -z "$server" ]
+               then
+                       echo "SERVER required for define operation"
+                       echo $usage
+                       exit 1
+               fi
+               fhem.pl 7072 "define watchdog at +*00:10:00 \"/usr/share/sysal/bin/triggerWatchdog_REST http://$server/sysal/rest rwd-$hostname $hostname\""
+               ;;
+       delete)
+               fhem.pl 7072 "delete watchdog"
+               ;;
+       *)
+               echo "invalid operation $operation"
+               echo $usage
+               exit 1
+               ;;
+       esac
+}
+               
+if [ $# -lt 2 ]
+then
+       echo $usage
+       exit 1
+fi
+
+operation=$1
+object=$2
+
+hostname=$(hostname)
+
+case $2 in
+watchdog)
+       process_watchdog $3
+       ;;
+*)
+       echo "invalid object $2"
+       echo $usage
+       exit 1
+       ;;
+esac
+