|
@@ -44,6 +44,87 @@ ROUTER_IP_ADDRESS="192.168.1.254"
|
44
|
44
|
|
45
|
45
|
MESH_INSTALL_DIR=/var/lib
|
46
|
46
|
|
|
47
|
+# For Beaglebone Black network reboot daemon
|
|
48
|
+BBBRTC_REPO="https://code.freedombone.net/bashrc/bbbrtc"
|
|
49
|
+PHYREG_REPO="https://code.freedombone.net/bashrc/phyreg"
|
|
50
|
+
|
|
51
|
+function bbb_network_restart_daemon {
|
|
52
|
+ rdir="$1"
|
|
53
|
+
|
|
54
|
+ # This checks if there is an ethernet boot fault
|
|
55
|
+ # and if so it reboots and tries again
|
|
56
|
+ # https://github.com/bigjosh/bbbphyfix
|
|
57
|
+
|
|
58
|
+ if [ ! -d "$rdir$INSTALL_DIR" ]; then
|
|
59
|
+ mkdir -p "$rdir$INSTALL_DIR"
|
|
60
|
+ fi
|
|
61
|
+
|
|
62
|
+ #first install the bbbrtc command that we will need
|
|
63
|
+ cd "$rdir$INSTALL_DIR" || exit 357893563
|
|
64
|
+ git clone $BBBRTC_REPO "$rdir$INSTALL_DIR/bbbrtc"
|
|
65
|
+ cd "$rdir$INSTALL_DIR/bbbrtc" || exit 357893563
|
|
66
|
+ if ! make; then
|
|
67
|
+ exit 3568735
|
|
68
|
+ fi
|
|
69
|
+
|
|
70
|
+ #next install the bbbphyreg command that we will need
|
|
71
|
+ cd "$rdir$INSTALL_DIR" || exit 357893563
|
|
72
|
+ git clone $PHYREG_REPO "$rdir$INSTALL_DIR/phyreg"
|
|
73
|
+ cd "$rdir$INSTALL_DIR/phyreg" || exit 54789786
|
|
74
|
+ make clean
|
|
75
|
+ if ! make; then
|
|
76
|
+ exit 46879275
|
|
77
|
+ fi
|
|
78
|
+ make install
|
|
79
|
+
|
|
80
|
+ { echo '#!/bin/bash';
|
|
81
|
+ echo '';
|
|
82
|
+ echo 'sleep 30';
|
|
83
|
+ echo '';
|
|
84
|
+ echo "if [[ \$(phyreg test 18 13) == \"1\" ]]; then";
|
|
85
|
+ echo '';
|
|
86
|
+ echo ' sleep 1';
|
|
87
|
+ echo '';
|
|
88
|
+ echo " NOW=\$(bbbrtc now)";
|
|
89
|
+ echo " echo \"chkphy:Rebooting NOW=\$NOW\" >/dev/kmsg";
|
|
90
|
+ echo " echo \"Rebooting\" >>/var/tmp/chkphy.log";
|
|
91
|
+ echo ' # make sure that log message actually gets written before we pull the plug';
|
|
92
|
+ echo ' sync';
|
|
93
|
+ echo ' i2cset -f -y 0 0x24 0x0a 0x00';
|
|
94
|
+ echo ' bbbrtc now 130';
|
|
95
|
+ echo ' bbbrtc wake 110';
|
|
96
|
+ echo ' bbbrtc sleep 102';
|
|
97
|
+ echo ' bbbrtc now 100';
|
|
98
|
+ echo ' while true;';
|
|
99
|
+ echo ' do echo waiting to reboot';
|
|
100
|
+ echo ' sleep 10';
|
|
101
|
+ echo ' done';
|
|
102
|
+ echo ' fi';
|
|
103
|
+ echo '';
|
|
104
|
+ echo "echo \"chkphy:eth0 good\" >/dev/kmsg"; } > "${rdir}/usr/bin/chkphy"
|
|
105
|
+ chmod +x "${rdir}/usr/bin/chkphy"
|
|
106
|
+
|
|
107
|
+ { echo '[Unit]';
|
|
108
|
+ echo "Description=Beaglebone Black Network Restart Daemon";
|
|
109
|
+ echo 'After=syslog.target';
|
|
110
|
+ echo 'After=network.target';
|
|
111
|
+ echo '';
|
|
112
|
+ echo '[Service]';
|
|
113
|
+ echo 'Type=simple';
|
|
114
|
+ echo 'User=root';
|
|
115
|
+ echo 'Group=root';
|
|
116
|
+ echo 'WorkingDirectory=/root';
|
|
117
|
+ echo 'ExecStart=/usr/bin/chkphy';
|
|
118
|
+ echo '';
|
|
119
|
+ echo '[Install]';
|
|
120
|
+ echo 'WantedBy=multi-user.target'; } > "${rdir}/etc/systemd/system/bbbnetwork.service"
|
|
121
|
+ if [ ! "${rdir}" ]; then
|
|
122
|
+ systemctl enable bbbnetwork
|
|
123
|
+ else
|
|
124
|
+ chroot "$rdir" systemctl enable bbbnetwork
|
|
125
|
+ fi
|
|
126
|
+}
|
|
127
|
+
|
47
|
128
|
function get_app_icann_address {
|
48
|
129
|
app_name="$1"
|
49
|
130
|
if grep -q "${app_name} domain" "$COMPLETION_FILE"; then
|