#!/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