-
Notifications
You must be signed in to change notification settings - Fork 1
/
check-garden-device.sh
99 lines (82 loc) · 2.24 KB
/
check-garden-device.sh
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
DEVICE_NAME=$1
if [ ! $DEVICE_NAME ]; then
echo "Please provide a device name as an argument."
exit 1
fi
CURRENT_HOST=$(cat /etc/hostname)
DEVICE_GROUP=$(cat "devices/$DEVICE_NAME/group.txt")
DEVICE_HOST=$(cat "devices/$DEVICE_NAME/host.txt")
DEVICE_BOARD=$(cat "devices/$DEVICE_NAME/board.txt")
if [ "$DEVICE_BOARD" != "esp" ]; then
if [ "$DEVICE_GROUP" = "ui" ]; then
if [ "$DEVICE_HOST" = "$CURRENT_HOST" ]; then
OUTPUT=$(sh view-ui-controller-1602-status.sh $DEVICE_NAME)
RESULT="NotSet"
SUB_RESULT=""
case "$OUTPUT" in
*inactive*)
RESULT="Inactive"
;;
*active*)
RESULT="Active"
;;
*failed*)
RESULT="Failed"
;;
esac
# TODO: Reimplement if possible
#case "$OUTPUT" in
# *MqttConnectionException*)
# SUB_RESULT="Failed to connect to broker"
# ;;
# *"An error occurred while retrieving package metadata"*)
# SUB_RESULT="Nuget connection error"
# ;;
# *"No such file or directory"*)
# SUB_RESULT="USB device not found"
# ;;
#esac
#echo $OUTPUT
echo " UI Controller Service: $RESULT"
if [ "$SUB_RESULT" ]; then
echo " $SUB_RESULT"
fi
fi
else
if [ "$DEVICE_HOST" = "$CURRENT_HOST" ]; then
OUTPUT=$(sh view-mqtt-bridge-status.sh $DEVICE_NAME)
RESULT="NotSet"
SUB_RESULT=""
case "$OUTPUT" in
*inactive*)
RESULT="Inactive"
;;
*active*)
RESULT="Active"
;;
*failed*)
RESULT="Failed"
;;
esac
case "$OUTPUT" in
*MqttConnectionException*)
SUB_RESULT="Failed to connect to broker"
;;
*"An error occurred while retrieving package metadata"*)
SUB_RESULT="Nuget connection error"
;;
*"No such file or directory"*)
SUB_RESULT="USB device not found"
;;
esac
#echo $OUTPUT
echo " MQTT Bridge Service: $RESULT"
if [ "$SUB_RESULT" ]; then
echo " $SUB_RESULT"
fi
fi
sh check-garden-device-mqtt.sh $DEVICE_NAME
fi
else
sh check-garden-device-mqtt.sh $DEVICE_NAME
fi