Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
some bugfixes, extend logging
  • Loading branch information
ghoost82 committed Dec 30, 2017
1 parent 34d444b commit 333be46
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -366,7 +366,7 @@ $(BUILDDIR)/samba: $(SOURCEDIR)/$(SAMBAARCHIVE)
touch $@

sdcard/manufacture.bin:
tar -cf $(TOPDIR)/sdcard/manufacture.bin test_drv
tar -cf $(TOPDIR)/sdcard/manufacture.bin manufacture/test_drv


gm_lib/rtspd:
Expand Down
6 changes: 3 additions & 3 deletions test_drv → manufacture/test_drv
Expand Up @@ -4,9 +4,9 @@
## author: Jan Sperling , 2017

if [ -d /mnt/media/mmcblk0p1 ]; then
mmcdir="/mnt/media/mmcblk0p1"
mmcdir="/mnt/media/mmcblk0p1"
elif [ -d /mnt/media/mmcblk0 ]; then
mmcdir="/mnt/media/mmcblk0"
mmcdir="/mnt/media/mmcblk0"
fi

if [ -f "${mmcdir}/mijia-720p-hack.cfg" ]; then
Expand Down Expand Up @@ -47,8 +47,8 @@ EOF
#FAKE rsa_decrypt
cp "\${2%/*}/md5.sum" "\$2"
EOF
chmod +x /mnt/data/ft/rsa_decrypt
fi
chmod +x /mnt/data/ft/rsa_decrypt
fi
echo "System prepared for hack, reboot"
reboot
Expand Down
17 changes: 10 additions & 7 deletions sdcard/ft/ft_boot.sh
Expand Up @@ -52,7 +52,7 @@ if [ -f "${sd_mountdir}/mijia-720p-hack.cfg" ]; then
fi

if [ "${DISABLE_HACK}" -eq 1 ]; then
echo "Hack disabled, proceed with default start" i| tee -a "${LOGFILE}"
echo "Hack disabled, proceed with default start" | tee -a "${LOGFILE}"
echo 0 > /tmp/ft_mode
do_vg_boot
exit
Expand Down Expand Up @@ -95,13 +95,14 @@ if ! mountpoint -q /etc; then
mount --rbind /tmp/etc /etc
fi


## Set time zone
##################################################################################
echo "Configure time zone"
rm /tmp/etc/TZ
echo "${TIMEZONE}" > /tmp/etc/TZ
export TZ="${TIMEZONE}"
if [ -n "${TIMEZONE}" ]; then
echo "Configure time zone"
rm /tmp/etc/TZ
echo "${TIMEZONE}" > /tmp/etc/TZ
export TZ="${TIMEZONE}"
fi

## Set root Password
##################################################################################
Expand All @@ -112,6 +113,7 @@ if [ -n "${ROOT_PASSWORD}" ]; then
if ! [ -d "${sd_mountdir}/mijia-720p-hack/tmp/samba" ]; then
mkdir -p "${sd_mountdir}/mijia-720p-hack/tmp/samba"
fi
echo "Setting Samba root password"
(echo "${ROOT_PASS}"; echo "${ROOT_PASS}") | "${sd_mountdir}/mijia-720p-hack/bin/smbpasswd" -a -s
fi
else
Expand All @@ -121,20 +123,21 @@ fi
## WIFI
##################################################################################
if [ -f "${sd_mountdir}/mijia-720p-hack/scripts/configure_wifi" ]; then
echo "Configure WiFi"
sh "${sd_mountdir}/mijia-720p-hack/scripts/configure_wifi"
fi

## Disable Cloud Services, streaming and OTA
##################################################################################
if [ -f "${sd_mountdir}/mijia-720p-hack/scripts/cloud_control" ]; then
echo "Configure Cloud Services"
sh "${sd_mountdir}/mijia-720p-hack/scripts/cloud_control"
fi

) >> "${LOGFILE}" 2>&1

## Start enabled Services
##################################################################################
echo "RTSP_OPTIONS=\"${RTSP_OPTIONS}\"" > /tmp/etc/rtsp
if ! [ -f /mnt/data/test/boot.sh ]; then
ln -s ${sd_mountdir}/mijia-720p-hack/scripts/.boot.sh /mnt/data/test/boot.sh
fi
Expand Down
Binary file modified sdcard/manufacture.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions sdcard/mijia-720p-hack.cfg
Expand Up @@ -14,9 +14,9 @@ ENABLE_SYSLOG=0
## Total Disconnect from Xioami servers, includes disable of streaming and OTA updater (0/1)
DISABLE_CLOUD=1
## Manage the camera via cloud but don't stream anything outside your network (0/1)
DISABLE_CLOUD_STREAMING=0
DISABLE_CLOUD_STREAMING=1
## Manage the camera via cloud but prevent online updates (0/1)
DISABLE_OTA=0
DISABLE_OTA=1
## Start telnet server at system boot (0/1)
ENABLE_TELNETD=1
## Start SSH server at system boot (0/1)
Expand Down
10 changes: 8 additions & 2 deletions sdcard/mijia-720p-hack/scripts/.boot.sh
Expand Up @@ -4,14 +4,20 @@
## 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/restartd.conf; then
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
Expand Down Expand Up @@ -57,4 +63,4 @@ if [ -f /mnt/data/test/boot.sh ]; then
rm /mnt/data/test/boot.sh
fi


) >> "${LOGFILE}" 2>&1
43 changes: 24 additions & 19 deletions sdcard/mijia-720p-hack/scripts/cloud_control
Expand Up @@ -23,7 +23,7 @@ disable_binary() {
if [ ! -f /tmp/disable-binary ]; then
cat > /tmp/disable-binary << EOF
#!/bin/sh
echo "$0 disabled"
echo "\$0 disabled with mijia-720p-hack"
EOF
chmod +x /tmp/disable-binary
fi
Expand All @@ -46,17 +46,17 @@ enable_binary() {
fi
}

## Prepare restartd
if ! [ -f /tmp/etc/restartd.conf.org ] &&
mountpoint -q /etc; then
cp /mnt/data/restartd/restartd.conf /tmp/etc/restartd.conf.org
fi
if ! mount | grep -q /mnt/data/restartd/restartd.conf; then
touch /tmp/etc/restartd.conf
mount --bind /tmp/etc/restartd.conf /mnt/data/restartd/restartd.conf
fi
/mnt/data/imi/imi_init/S99restartd stop
## Prepare restartd
if ! [ -f /tmp/etc/restartd.conf.org ] &&
mountpoint -q /etc; then
cp /mnt/data/restartd/restartd.conf /tmp/etc/restartd.conf.org
fi
if ! mount | grep -q /mnt/data/restartd/restartd.conf; then
touch /tmp/etc/restartd.conf
mount --bind /tmp/etc/restartd.conf /mnt/data/restartd/restartd.conf
fi

/mnt/data/imi/imi_init/S99restartd stop
> /tmp/etc/restartd.conf

if [ "${DISABLE_CLOUD}" -eq 1 ]; then
Expand All @@ -70,6 +70,8 @@ if [ "${DISABLE_CLOUD}" -eq 1 ]; then
disable_binary "/mnt/data/miot/miot_qrcode.sh"
#/mnt/data/imi/imi_init/S95miio_smb
disable_binary "/mnt/data/miio_smb/miio_smb" "miio_smb"
# cron
disable_binary "/mnt/data/miot/logmi.sh"
else
echo "Enabling Cloud"
#/mnt/data/imi/imi_init/S95miio_smb
Expand All @@ -81,6 +83,8 @@ else
#/mnt/data/imi/imi_init/S93miio_client
enable_binary "/mnt/data/ot_wifi_tool/miio_client" "miio_client"
enable_binary "/mnt/data/ot_wifi_tool/miio_client_helper_nomqtt.sh" "miio_client_helper"
# cron
enable_binary "/mnt/data/miot/logmi.sh"
fi

if [ "${DISABLE_CLOUD}" -eq 1 ] || [ "${DISABLE_CLOUD_STREAMING}" -eq 1 ]; then
Expand All @@ -107,11 +111,12 @@ else
enable_binary "/mnt/data/miio_ota/miio_ota" "miio_ota"
fi

#readd telnet to to restard.conf
if [ "${ENABLE_TELNETD}" -eq 1 ]; then
#readd telnet to to restard.conf
if [ "${ENABLE_TELNETD}" -eq 1 ] &&
! 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
fi
if pgrep /mnt/data/restartd/restartd > /dev/null; then
/mnt/data/imi/imi_init/S99restartd restart
fi
fi

if pgrep /mnt/data/restartd/restartd > /dev/null; then
/mnt/data/imi/imi_init/S99restartd restart
fi

0 comments on commit 333be46

Please sign in to comment.