/
.boot.sh
66 lines (56 loc) · 1.8 KB
/
.boot.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
#!/bin/sh
## purpose: Start enabled services and stop with LED blinking
## license: GPLv3+, http://www.gnu.org/licenses/gpl-3.0.html
## author: Jan Sperling , 2017
sd_mountdir="/tmp/sd"
LOGDIR="${sd_mountdir}/log"
LOGFILE="${LOGDIR}/ft_boot.log"
if [ -f "${sd_mountdir}/mijia-720p-hack.cfg" ]; then
. "${sd_mountdir}/mijia-720p-hack.cfg"
fi
(
echo "Executing /mnt/data/test/boot.sh"
## Start enabled services
if [ "${ENABLE_TELNETD}" -eq 1 ]; then
/mnt/data/imi/imi_init/_S50telnet start
if ! grep -q telnetd /tmp/etc/restartd.conf; then
echo "telnetd \"/usr/sbin/telnetd\" \"/mnt/data/imi/imi_init/_S50telnet restart\" \"/bin/echo 'telnetd is running'\"" >> /tmp/etc/restartd.conf
if pgrep /mnt/data/restartd/restartd > /dev/null; then
/mnt/data/imi/imi_init/S99restartd restart
fi
fi
fi
if [ "${ENABLE_SSHD}" -eq 1 ]; then
${sd_mountdir}/mijia-720p-hack/scripts/S99dropbear start
fi
if [ "${ENABLE_HTTPD}" -eq 1 ]; then
${sd_mountdir}/mijia-720p-hack/scripts/S99lighttpd start
fi
if [ "${ENABLE_FTPD}" -eq 1 ]; then
${sd_mountdir}/mijia-720p-hack/scripts/S99ftpd start
fi
if [ "${ENABLE_SAMBA}" -eq 1 ]; then
${sd_mountdir}/mijia-720p-hack/scripts/S99samba start
fi
if [ "${ENABLE_RTSP}" -eq 1 ]; then
${sd_mountdir}/mijia-720p-hack/scripts/S99rtsp start
fi
## Sync time
/usr/sbin/ntpd -q -p "${NTP_SERVER}"
## LED blue: 0, red: 1, set blue.
if [ "$(/usr/sbin/nvram get light)" = "on" ]; then
/mnt/data/miot/ledctl 0 80 0 0 0 2
else
/mnt/data/miot/ledctl 0 0 1 0 0 2
fi
/mnt/data/miot/ledctl 1 0 1 0 0 2
## Put our bins into PATH
if [ -d "${sd_mountdir}/mijia-720p-hack/bin" ] &&
! mountpoint -q /tmp/sd/ft; then
mount --rbind "${sd_mountdir}/mijia-720p-hack/bin" /tmp/sd/ft
fi
## Cleanup
if [ -f /mnt/data/test/boot.sh ]; then
rm /mnt/data/test/boot.sh
fi
) >> "${LOGFILE}" 2>&1