-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.sh
107 lines (91 loc) · 2.48 KB
/
install.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
100
101
102
103
104
105
106
107
#!/bin/bash
UTILS_HOST=codeload.github.com
UTILS_URL=/divanikus/zesp32-installer/zip/master
UTILS_DIR=/opt/utils
PKG_URL=http://82.146.46.112/fw/mihub.tar.gz
PKG_UPD_URL=http://82.146.46.112/fw/update.tar.gz
PKG=/tmp/m.tgz
w_get() {
echo -e "GET $2 HTTP/1.0\nHost: $1\n" | openssl s_client -quiet -connect $1:443 -servername $1 2>/dev/null | sed '1,/^\r$/d' > $3
}
echo =================================================================
echo ZESP32 automatic installer
echo =================================================================
if [ ! -d "/lumi" ]; then
echo
echo This script is intended to run only on stock firmware.
exit -1
fi
echo
echo Updating time...
ntpdate pool.ntp.org
echo
echo Downloading ZESP32...
if ! wget -O $PKG $PKG_URL; then
echo Download failed.
exit -1
fi
echo
echo Unpacking...
if ! tar -xzvf $PKG -C /; then
echo Unpacking failed, please check available space and try again.
exit -1
fi
rm $PKG
ln -fs /opt/node/bin/npm /usr/bin/npm
ln -fs /opt/node/bin/node /usr/bin/node
echo
echo Downloading update...
if ! wget -O $PKG $PKG_UPD_URL; then
echo Download failed.
exit -1
fi
echo
echo Unpacking update...
if ! tar -xzvf $PKG -C /; then
echo Unpacking failed, please check available space and try again.
exit -1
fi
rm $PKG
echo
echo Detecting Wifi module...
MODULE=unknown
if lsmod | grep 8723bs >/dev/null; then
MODULE=8723bs
elif lsmod | grep 8189es >/dev/null; then
MODULE=8189es
else
echo Unknown Wifi module
exit -1
fi
echo Found $MODULE
echo
echo Downloading utils...
WORKDIR=$(mktemp -d)
mkdir -p $UTILS_DIR
w_get $UTILS_HOST $UTILS_URL $WORKDIR/master.zip
if ! unzip $WORKDIR/master.zip -d $WORKDIR; then
echo Download failed. Please try again.
exit -1
fi
mv $WORKDIR/zesp32-installer-master/scripts/*.sh $UTILS_DIR
chmod +x $UTILS_DIR/*.sh
# Enabling automatic Zigbee flashing on boot
touch /opt/app/util/need_update_coordinator.tag
echo
echo Installing modified rc.local...
TS=$(date +%s)
cp /etc/rc.local /etc/rc.local.bak-$TS
echo Previous version is in /etc/rc.local.bak-$TS
mv $WORKDIR/zesp32-installer-master/rc.$MODULE.local /etc/rc.local
chmod +x /etc/rc.local
echo
echo Current WiFi settings:
cat /lumi/conf/wifi.conf
echo
echo =================================================================
echo ZESP32 installation completed. Device will restart in 15 seconds.
echo Press Ctrl+C to cancel automatic restart.
echo =================================================================
sleep 15
reboot