blob: cf91edad7edc288537b63f1cd07658187f85a2be (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
|