summaryrefslogtreecommitdiff
path: root/recipes-core/annex-client/annex-client/push_api_mdm_status
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-core/annex-client/annex-client/push_api_mdm_status')
-rwxr-xr-xrecipes-core/annex-client/annex-client/push_api_mdm_status30
1 files changed, 30 insertions, 0 deletions
diff --git a/recipes-core/annex-client/annex-client/push_api_mdm_status b/recipes-core/annex-client/annex-client/push_api_mdm_status
new file mode 100755
index 0000000..cf91eda
--- /dev/null
+++ b/recipes-core/annex-client/annex-client/push_api_mdm_status
@@ -0,0 +1,30 @@
+#!/bin/bash
+# This script pushes the current time to the API's remote management
+# to track last connected time
+
+STATUS_FILE="/var/config/devicehq/status.json"
+DHQ_DIR="/var/config/devicehq"
+
+STATUS="$1"
+
+if [ "$STATUS" == "" ]; then
+ STATUS="HEARTBEAT: $(date)"
+fi
+
+if [ ! -f $STATUS_FILE ]; then
+ mkdir -p $DHQ_DIR
+ echo "{
+ \"status\": \"unknown\",
+ \"lastConnected\": \"unknown\",
+ \"intervalSeconds\": \"10\"
+}" > $STATUS_FILE
+fi
+
+sed -i "s~\"status\"\s*:\s*\".*\"~\"status\": \"$STATUS\"~" $STATUS_FILE
+
+if [ $? != 0 ]; then
+ logger -t push_api_mdm_status "Failed to save status [$STATUS] to $STATUS_FILE"
+fi
+
+
+