diff --git a/README.md b/README.md index 56db248..2f24a61 100755 --- a/README.md +++ b/README.md @@ -10,6 +10,12 @@ functions: 6. Automatically archive the recordings. # Release notes +## 0.5.04: +* Fixing hack not persisting through 4.X.6.241 update. +* Getting rid of all the init file specific modifications. +* Supporting the new logging method used in 4.X.6.241. +* Stopping spamming log messages. + ## 0.5.03: * Fixing broken SD card simuation on latest v3 firmware (4.36.0.252) diff --git a/build.sh b/build.sh index 0add5a1..9015257 100755 --- a/build.sh +++ b/build.sh @@ -22,7 +22,6 @@ tar \ ./main.sh \ ./hack_ver.inc \ ./bin \ - ./init \ >>.tmp/Upgrade/wyze_hack.sh chmod a+x .tmp/Upgrade/wyze_hack.sh diff --git a/release/wyze_hacks_0_5_04.zip b/release/wyze_hacks_0_5_04.zip new file mode 100755 index 0000000..36995a5 Binary files /dev/null and b/release/wyze_hacks_0_5_04.zip differ diff --git a/wyze_hack/hack_ver.inc b/wyze_hack/hack_ver.inc index 1d6171a..6193e58 100755 --- a/wyze_hack/hack_ver.inc +++ b/wyze_hack/hack_ver.inc @@ -1 +1 @@ -export WYZEHACK_VER=0.5.03 +export WYZEHACK_VER=0.5.04 diff --git a/wyze_hack/init/da25f6c6166b4ecbab3c0e5d511c8819/4.10.6.218 b/wyze_hack/init/da25f6c6166b4ecbab3c0e5d511c8819/4.10.6.218 deleted file mode 100755 index e69de29..0000000 diff --git a/wyze_hack/init/da25f6c6166b4ecbab3c0e5d511c8819/app_init_mod.sh b/wyze_hack/init/da25f6c6166b4ecbab3c0e5d511c8819/app_init_mod.sh deleted file mode 100755 index 443f3d9..0000000 --- a/wyze_hack/init/da25f6c6166b4ecbab3c0e5d511c8819/app_init_mod.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/sh - -mkdaemon() { - mkdir -p /var/log/$1 - # dmon options - # --stderr-redir Redirects stderr to the log file as well - # --max-respawns Sets the number of times dmon will restart a failed process - # --environ Sets an environment variable. Used to remove buffering on stdout - # - # drlog options - # --max-size The max size 1 log file can grow too - # --max-files The number of logs that will exist at once - # - dmon \ - --stderr-redir \ - --max-respawns $2 \ - --environ "LD_PRELOAD=libsetunbuf.so" \ - /system/bin/$1 \ - -- drlog \ - --max-size 10k \ - --max-files 1 \ - /var/log/$1 -} - -chmod -R 755 /system - -cd /tmp -if [ -f /system/.upgrade ]; then - cd /backupa - echo "init upgrading!!!!!!!!!!!!" - sh ./upgrade.sh - rm /system/.upgrade -fi - -if [ -f /configs/.upgrade ]; then - echo "new init upgrading!!!!!!!!!!!!" - logfile=/configs/upgrade.log - echo "sh /configs/merge_upgrade.sh ... " - sh /configs/merge_upgrade.sh >> $logfile 2>&1 & - exit 0 -fi - -# Update timestamp to something reasonable (the time this firmware was built) -CURRENT_EPOCH_TIME=$(date +%s) -FIRMWARE_BUILD_EPOCH_TIME=$(cat /system/init/firmware_build_epoch_time.txt) -FIRMWARE_BUILD_MINUS_ONE_DAY_EPOCH_TIME=$(($FIRMWARE_BUILD_EPOCH_TIME-86400)) -# If "current time" < ("firmware build time" - "one day") -# Then update time to "firmware build time" -if [ "$CURRENT_EPOCH_TIME" -lt "$FIRMWARE_BUILD_MINUS_ONE_DAY_EPOCH_TIME" ]; then - echo "Updating device time to:" - date -s "@$FIRMWARE_BUILD_EPOCH_TIME" -fi - -export LD_LIBRARY_PATH=/tmp:$LD_LIBRARY_PATH -echo "nameserver 8.8.8.8" >> /tmp/resolv.conf - -echo "################################" -echo "######## this is dafang ########" -echo "################################" - - -insmod /driver/tx-isp.ko isp_clk=100000000 -insmod /driver/exfat.ko -insmod /driver/sample_motor.ko -insmod /driver/sinfo.ko -insmod /driver/sample_pwm_core.ko -insmod /driver/sample_pwm_hal.ko -insmod /driver/audio.ko - -if [ -f /driver/8189es.ko ]; then - insmod /driver/8189es.ko -else - insmod /driver/rtl8189ftv.ko -fi - -echo 47 > /sys/class/gpio/export -echo out > /sys/class/gpio/gpio47/direction -echo 1 > /sys/class/gpio/gpio47/value - -echo 61 > /sys/class/gpio/export -echo "out" > /sys/class/gpio/gpio61/direction -echo 1 > /sys/class/gpio/gpio61/value -sleep 1 -echo 0 > /sys/class/gpio/gpio61/value - - -#wpa_supplicant -Dwext -i wlan0 -c /system/etc/wpa_supplicant.conf -B -#udhcpc -i wlan0 -s /system/etc/udhcpc.script -q - -#ifconfig eth0 up -#udhcpc -i eth0 -s /system/etc/udhcpc.script -q -ifconfig eth0 10.10.10.10 netmask 255.255.255.0 -route add default gw 10.10.10.1 - -# Copy certificates into RAM, allowing it to be update -if [ -f /system/bin/cacert.pem ]; then - cp /system/bin/cacert.pem /tmp/cacert.pem -else - echo "WARNING!!! TLS Certs not found at /system/bin/cacert.pem" - echo " ALL HTTPS TRAFFIC EXPECTED TO FAIL" -fi - -# open ircut -#cp /system/bin/setir /tmp/ -#config ip address - -###/system/bin/carrier-server --st=imx322 -###/system/bin/singleBoadTest -/system/bin/test_UP & -/system/bin/sdkshellcalltool & -/system/bin/hl_client & -/system/bin/iCamera & -/system/bin/dongle_app & -/system/bin/sinker & - -for i in $(seq 1 2) -do - sleep 10 - pidof iCamera > /dev/null - if pidof iCamera > /dev/null; then - echo "iCamera is Running" - exit - fi -done - -echo "iCamera not running" -echo "restore system from backup" -touch /configs/.upgrade -touch /configs/.fsrepair - -sleep 1 -reboot diff --git a/wyze_hack/init/da25f6c6166b4ecbab3c0e5d511c8819/app_init_orig.sh b/wyze_hack/init/da25f6c6166b4ecbab3c0e5d511c8819/app_init_orig.sh deleted file mode 100755 index fc1d3e5..0000000 --- a/wyze_hack/init/da25f6c6166b4ecbab3c0e5d511c8819/app_init_orig.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/sh - -mkdaemon() { - mkdir -p /var/log/$1 - # dmon options - # --stderr-redir Redirects stderr to the log file as well - # --max-respawns Sets the number of times dmon will restart a failed process - # --environ Sets an environment variable. Used to remove buffering on stdout - # - # drlog options - # --max-size The max size 1 log file can grow too - # --max-files The number of logs that will exist at once - # - dmon \ - --stderr-redir \ - --max-respawns $2 \ - --environ "LD_PRELOAD=libsetunbuf.so" \ - /system/bin/$1 \ - -- drlog \ - --max-size 10k \ - --max-files 1 \ - /var/log/$1 -} - -chmod -R 755 /system - -cd /tmp -if [ -f /system/.upgrade ]; then - cd /backupa - echo "init upgrading!!!!!!!!!!!!" - sh ./upgrade.sh - rm /system/.upgrade -fi - -if [ -f /configs/.upgrade ]; then - echo "new init upgrading!!!!!!!!!!!!" - logfile=/configs/upgrade.log - echo "sh /configs/merge_upgrade.sh ... " - sh /configs/merge_upgrade.sh >> $logfile 2>&1 & - exit 0 -fi - -# Update timestamp to something reasonable (the time this firmware was built) -CURRENT_EPOCH_TIME=$(date +%s) -FIRMWARE_BUILD_EPOCH_TIME=$(cat /system/init/firmware_build_epoch_time.txt) -FIRMWARE_BUILD_MINUS_ONE_DAY_EPOCH_TIME=$(($FIRMWARE_BUILD_EPOCH_TIME-86400)) -# If "current time" < ("firmware build time" - "one day") -# Then update time to "firmware build time" -if [ "$CURRENT_EPOCH_TIME" -lt "$FIRMWARE_BUILD_MINUS_ONE_DAY_EPOCH_TIME" ]; then - echo "Updating device time to:" - date -s "@$FIRMWARE_BUILD_EPOCH_TIME" -fi - -export LD_LIBRARY_PATH=/tmp:$LD_LIBRARY_PATH -echo "nameserver 8.8.8.8" >> /tmp/resolv.conf - -echo "################################" -echo "######## this is dafang ########" -echo "################################" - - -insmod /driver/tx-isp.ko isp_clk=100000000 -insmod /driver/exfat.ko -insmod /driver/sample_motor.ko -insmod /driver/sinfo.ko -insmod /driver/sample_pwm_core.ko -insmod /driver/sample_pwm_hal.ko -insmod /driver/audio.ko - -if [ -f /driver/8189es.ko ]; then - insmod /driver/8189es.ko -else - insmod /driver/rtl8189ftv.ko -fi - -echo 47 > /sys/class/gpio/export -echo out > /sys/class/gpio/gpio47/direction -echo 1 > /sys/class/gpio/gpio47/value - -echo 61 > /sys/class/gpio/export -echo "out" > /sys/class/gpio/gpio61/direction -echo 1 > /sys/class/gpio/gpio61/value -sleep 1 -echo 0 > /sys/class/gpio/gpio61/value - - -#wpa_supplicant -Dwext -i wlan0 -c /system/etc/wpa_supplicant.conf -B -#udhcpc -i wlan0 -s /system/etc/udhcpc.script -q - -#ifconfig eth0 up -#udhcpc -i eth0 -s /system/etc/udhcpc.script -q -ifconfig eth0 10.10.10.10 netmask 255.255.255.0 -route add default gw 10.10.10.1 - -# Copy certificates into RAM, allowing it to be update -if [ -f /system/bin/cacert.pem ]; then - cp /system/bin/cacert.pem /tmp/cacert.pem -else - echo "WARNING!!! TLS Certs not found at /system/bin/cacert.pem" - echo " ALL HTTPS TRAFFIC EXPECTED TO FAIL" -fi - -# open ircut -#cp /system/bin/setir /tmp/ -#config ip address - -###/system/bin/carrier-server --st=imx322 -###/system/bin/singleBoadTest -mkdaemon test_UP 20 -mkdaemon sdkshellcalltool 20 -mkdaemon hl_client 20 -mkdaemon iCamera 0 -mkdaemon dongle_app 20 -mkdaemon sinker 20 - -for i in $(seq 1 2) -do - sleep 10 - pidof iCamera > /dev/null - if pidof iCamera > /dev/null; then - echo "iCamera is Running" - exit - fi -done - -echo "iCamera not running" -echo "restore system from backup" -touch /configs/.upgrade -touch /configs/.fsrepair - -sleep 1 -reboot diff --git a/wyze_hack/init/da25f6c6166b4ecbab3c0e5d511c8819/init.sh b/wyze_hack/init/da25f6c6166b4ecbab3c0e5d511c8819/init.sh deleted file mode 100755 index df96172..0000000 --- a/wyze_hack/init/da25f6c6166b4ecbab3c0e5d511c8819/init.sh +++ /dev/null @@ -1,2 +0,0 @@ -# For this version, we have to modify their app_init.sh script -LD_PRELOAD=$WYZEHACK_DIR/bin/libhacks.so $WYZEHACK_DIR/init/$WYZEINIT_MD5/app_init_mod.sh & diff --git a/wyze_hack/init/e9ebf06d64a385f7e4c762dccc3023c9/4.9.6.218 b/wyze_hack/init/e9ebf06d64a385f7e4c762dccc3023c9/4.9.6.218 deleted file mode 100755 index e69de29..0000000 diff --git a/wyze_hack/init/e9ebf06d64a385f7e4c762dccc3023c9/app_init_mod.sh b/wyze_hack/init/e9ebf06d64a385f7e4c762dccc3023c9/app_init_mod.sh deleted file mode 100755 index ca34da8..0000000 --- a/wyze_hack/init/e9ebf06d64a385f7e4c762dccc3023c9/app_init_mod.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/sh - -mkdaemon() { - mkdir -p /var/log/$1 - # dmon options - # --stderr-redir Redirects stderr to the log file as well - # --max-respawns Sets the number of times dmon will restart a failed process - # --environ Sets an environment variable. Used to remove buffering on stdout - # - # drlog options - # --max-size The max size 1 log file can grow too - # --max-files The number of logs that will exist at once - # - dmon \ - --stderr-redir \ - --max-respawns $2 \ - /system/bin/$1 -} - -chmod -R 755 /system - -cd /tmp -if [ -f /system/.upgrade ]; then - cd /backupa - echo "init upgrading!!!!!!!!!!!!" - sh ./upgrade.sh - rm /system/.upgrade -fi - -if [ -f /configs/.upgrade ]; then - echo "new init upgrading!!!!!!!!!!!!" - logfile=/configs/upgrade.log - echo "sh /configs/merge_upgrade.sh ... " - sh /configs/merge_upgrade.sh >> $logfile 2>&1 & - exit 0 -fi - -# Update timestamp to something reasonable (the time this firmware was built) -CURRENT_EPOCH_TIME=$(date +%s) -FIRMWARE_BUILD_EPOCH_TIME=$(cat /system/init/firmware_build_epoch_time.txt) -FIRMWARE_BUILD_MINUS_ONE_DAY_EPOCH_TIME=$(($FIRMWARE_BUILD_EPOCH_TIME-86400)) -# If "current time" < ("firmware build time" - "one day") -# Then update time to "firmware build time" -if [ "$CURRENT_EPOCH_TIME" -lt "$FIRMWARE_BUILD_MINUS_ONE_DAY_EPOCH_TIME" ]; then - echo "Updating device time to:" - date -s "@$FIRMWARE_BUILD_EPOCH_TIME" -fi - - -export LD_LIBRARY_PATH=/tmp:$LD_LIBRARY_PATH -echo "nameserver 8.8.8.8" >> /tmp/resolv.conf - -echo "################################" -echo "####### this is xiaofang #######" -echo "################################" - -insmod /driver/tx-isp.ko isp_clk=100000000 -insmod /driver/exfat.ko -insmod /driver/sample_motor.ko -insmod /driver/sinfo.ko -insmod /driver/sample_pwm_core.ko -insmod /driver/sample_pwm_hal.ko -insmod /driver/audio.ko spk_gpio=-1 sign_mode=0 -insmod /driver/rtl8189ftv.ko - -echo 47 > /sys/class/gpio/export -echo out > /sys/class/gpio/gpio47/direction -echo 1 > /sys/class/gpio/gpio47/value - -echo 63 > /sys/class/gpio/export -echo out > /sys/class/gpio/gpio63/direction -echo 1 > /sys/class/gpio/gpio63/value - - -#wpa_supplicant -Dwext -i wlan0 -c /system/etc/wpa_supplicant.conf -B -#udhcpc -i wlan0 -s /system/etc/udhcpc.script -q - -#ifconfig eth0 up -#udhcpc -i eth0 -s /system/etc/udhcpc.script - -ifconfig eth0 10.10.10.10 netmask 255.255.255.0 -route add default gw 10.10.10.1 - -# Copy certificates into RAM, allowing it to be update -if [ -f /system/bin/cacert.pem ]; then - cp /system/bin/cacert.pem /tmp/cacert.pem -else - echo "WARNING!!! TLS Certs not found at /system/bin/cacert.pem" - echo " ALL HTTPS TRAFFIC EXPECTED TO FAIL" -fi - - -# open ircut -#cp /system/bin/setir /tmp/ -#config ip address - - -###/system/bin/carrier-server --st=imx322 -###/system/bin/singleBoadTest -/system/bin/test_UP & -/system/bin/sdkshellcalltool & -/system/bin/hl_client & -/system/bin/iCamera & -/system/bin/dongle_app & -/system/bin/sinker & - -for i in $(seq 1 2) -do - sleep 10 - pidof iCamera > /dev/null - if [ 0 -eq $? ]; then - echo "iCamera is Running" - exit - fi -done - -echo "iCamera not running" -echo "restore system from backup" -touch /configs/.upgrade -touch /configs/.fsrepair - -sleep 1 -reboot diff --git a/wyze_hack/init/e9ebf06d64a385f7e4c762dccc3023c9/app_init_orig.sh b/wyze_hack/init/e9ebf06d64a385f7e4c762dccc3023c9/app_init_orig.sh deleted file mode 100755 index 9e219e5..0000000 --- a/wyze_hack/init/e9ebf06d64a385f7e4c762dccc3023c9/app_init_orig.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/sh - -mkdaemon() { - mkdir -p /var/log/$1 - # dmon options - # --stderr-redir Redirects stderr to the log file as well - # --max-respawns Sets the number of times dmon will restart a failed process - # --environ Sets an environment variable. Used to remove buffering on stdout - # - # drlog options - # --max-size The max size 1 log file can grow too - # --max-files The number of logs that will exist at once - # - dmon \ - --stderr-redir \ - --max-respawns $2 \ - --environ "LD_PRELOAD=libsetunbuf.so" \ - /system/bin/$1 \ - -- drlog \ - --max-size 10k \ - --max-files 1 \ - /var/log/$1 -} - -chmod -R 755 /system - -cd /tmp -if [ -f /system/.upgrade ]; then - cd /backupa - echo "init upgrading!!!!!!!!!!!!" - sh ./upgrade.sh - rm /system/.upgrade -fi - -if [ -f /configs/.upgrade ]; then - echo "new init upgrading!!!!!!!!!!!!" - logfile=/configs/upgrade.log - echo "sh /configs/merge_upgrade.sh ... " - sh /configs/merge_upgrade.sh >> $logfile 2>&1 & - exit 0 -fi - -# Update timestamp to something reasonable (the time this firmware was built) -CURRENT_EPOCH_TIME=$(date +%s) -FIRMWARE_BUILD_EPOCH_TIME=$(cat /system/init/firmware_build_epoch_time.txt) -FIRMWARE_BUILD_MINUS_ONE_DAY_EPOCH_TIME=$(($FIRMWARE_BUILD_EPOCH_TIME-86400)) -# If "current time" < ("firmware build time" - "one day") -# Then update time to "firmware build time" -if [ "$CURRENT_EPOCH_TIME" -lt "$FIRMWARE_BUILD_MINUS_ONE_DAY_EPOCH_TIME" ]; then - echo "Updating device time to:" - date -s "@$FIRMWARE_BUILD_EPOCH_TIME" -fi - - -export LD_LIBRARY_PATH=/tmp:$LD_LIBRARY_PATH -echo "nameserver 8.8.8.8" >> /tmp/resolv.conf - -echo "################################" -echo "####### this is xiaofang #######" -echo "################################" - -insmod /driver/tx-isp.ko isp_clk=100000000 -insmod /driver/exfat.ko -insmod /driver/sample_motor.ko -insmod /driver/sinfo.ko -insmod /driver/sample_pwm_core.ko -insmod /driver/sample_pwm_hal.ko -insmod /driver/audio.ko spk_gpio=-1 sign_mode=0 -insmod /driver/rtl8189ftv.ko - -echo 47 > /sys/class/gpio/export -echo out > /sys/class/gpio/gpio47/direction -echo 1 > /sys/class/gpio/gpio47/value - -echo 63 > /sys/class/gpio/export -echo out > /sys/class/gpio/gpio63/direction -echo 1 > /sys/class/gpio/gpio63/value - - -#wpa_supplicant -Dwext -i wlan0 -c /system/etc/wpa_supplicant.conf -B -#udhcpc -i wlan0 -s /system/etc/udhcpc.script -q - -#ifconfig eth0 up -#udhcpc -i eth0 -s /system/etc/udhcpc.script - -ifconfig eth0 10.10.10.10 netmask 255.255.255.0 -route add default gw 10.10.10.1 - -# Copy certificates into RAM, allowing it to be update -if [ -f /system/bin/cacert.pem ]; then - cp /system/bin/cacert.pem /tmp/cacert.pem -else - echo "WARNING!!! TLS Certs not found at /system/bin/cacert.pem" - echo " ALL HTTPS TRAFFIC EXPECTED TO FAIL" -fi - - -# open ircut -#cp /system/bin/setir /tmp/ -#config ip address - - -###/system/bin/carrier-server --st=imx322 -###/system/bin/singleBoadTest -mkdaemon test_UP 20 -mkdaemon sdkshellcalltool 20 -mkdaemon hl_client 20 -mkdaemon iCamera 0 -mkdaemon dongle_app 20 -mkdaemon sinker 20 - -for i in $(seq 1 2) -do - sleep 10 - pidof iCamera > /dev/null - if [ 0 -eq $? ]; then - echo "iCamera is Running" - exit - fi -done - -echo "iCamera not running" -echo "restore system from backup" -touch /configs/.upgrade -touch /configs/.fsrepair - -sleep 1 -reboot - diff --git a/wyze_hack/init/e9ebf06d64a385f7e4c762dccc3023c9/init.sh b/wyze_hack/init/e9ebf06d64a385f7e4c762dccc3023c9/init.sh deleted file mode 100755 index df96172..0000000 --- a/wyze_hack/init/e9ebf06d64a385f7e4c762dccc3023c9/init.sh +++ /dev/null @@ -1,2 +0,0 @@ -# For this version, we have to modify their app_init.sh script -LD_PRELOAD=$WYZEHACK_DIR/bin/libhacks.so $WYZEHACK_DIR/init/$WYZEINIT_MD5/app_init_mod.sh & diff --git a/wyze_hack/init/unknown/init.sh b/wyze_hack/init/unknown/init.sh deleted file mode 100755 index bb084f9..0000000 --- a/wyze_hack/init/unknown/init.sh +++ /dev/null @@ -1,2 +0,0 @@ -# By default, load original app_init.sh with libhacks.so injected -LD_PRELOAD=$WYZEHACK_DIR/bin/libhacks.so $WYZEINIT_SCRIPT & diff --git a/wyze_hack/main.sh b/wyze_hack/main.sh index 251d4e1..38be4b7 100755 --- a/wyze_hack/main.sh +++ b/wyze_hack/main.sh @@ -118,6 +118,7 @@ wait_wlan() { hook_init() { if grep "wyze_hack.sh" /etc/init.d/rcS; then + echo "WyzeHack: hard modified, no need to hook ..." return 0 fi @@ -136,15 +137,18 @@ hook_init() { local SYSTEM_DIR=${1:-/system} if [ ! -L $SYSTEM_DIR/init/app_init.sh ]; then - cp $SYSTEM_DIR/init/app_init.sh $WYZEINIT_SCRIPT + echo "WyzeHack: backing up app_init.sh ..." + cp $SYSTEM_DIR/init/app_init.sh $SYSTEM_DIR/init/app_init_orig.sh fi local APP_INIT=$(readlink $SYSTEM_DIR/init/app_init.sh) if [ "$APP_INIT" != "$WYZEHACK_BIN" ]; then + echo "WyzeHack: setting up symlink ..." ln -s -f $WYZEHACK_BIN $SYSTEM_DIR/init/app_init.sh fi + ls -la $SYSTEM_DIR/init return 0 } @@ -402,7 +406,7 @@ check_nfs() { return 1 fi - if ! timeout -t $NFS_TIMEOUT df /media/mmcblk0p1; + if ! timeout -t $NFS_TIMEOUT df /media/mmcblk0p1 > /dev/null 2>&1; then echo "WyzeHack: NFS no longer mounted as /media/mmcblk0p1" return 1 @@ -414,7 +418,7 @@ check_nfs() { sys_monitor() { while true; do local REBOOT_FLAG=0 - if ! pgrep -f telnetd; then + if ! pgrep -f telnetd >/dev/null 2>&1; then echo "WyzeHack: Starting telnetd..." busybox telnetd fi @@ -424,6 +428,11 @@ sys_monitor() { fi if [ "$SYNC_BOOT_LOG" = "1" ]; then + if pidof syslogd > /dev/null 2>&1 && \ + ! pidof logread > /dev/null 2>&1 ; then + logread + logread -f & + fi log_sync fi @@ -465,36 +474,48 @@ sys_monitor() { done echo "WyzeHack: Rebooting..." - killall sleep + killall sleep >/dev/null 2>&1 sync sleep 10 /sbin/reboot } cmd_reboot() { + set -x echo "WyzeHack: Camera is rebooting in 10 seconds ..." - if [ ! -f /system/.system ]; + if [ ! -z $IN_UPDATE ]; then - echo "WyzeHack: System partition not mounted, mounting..." - mount -t jffs2 /dev/mtdblock4 /system + echo "WyzeHack: In update, checking system partition ..." + cd / + umount -f /system || echo "WyzeHack: umount system failed ..." + mount -t jffs2 /dev/mtdblock4 /system || echo "WyzeHack: mount system failed ..." fi - hook_init - killall sleep + hook_init || echo "WyzeHack: hook_init failed ..." + killall sleep >/dev/null 2>&1 sync sleep 10 /sbin/reboot $@ } cmd_run() { - # Run original script when no config file is found or in the middle of upgrade + # Run original script when no config file is found or unknown device model if [ ! -f "$WYZEHACK_CFG" ] || \ - [ -f /system/.upgrade ] || \ - [ -f /configs/.upgrade ] || \ [ -z "$DEVICE_MODEL" ]; then $WYZEINIT_SCRIPT & - return 1 + return 0 + fi + + # Run original script with reboot hook when device is in the middle of + # upgrade + if [ -f /system/.upgrade ] || \ + [ -f /configs/.upgrade ]; then + export IN_UPDATE=1 + export PATH=$WYZEHACK_DIR/bin:$PATH + export LD_LIBRARY_PATH=$WYZEHACK_DIR/bin:$LD_LIBRARY_PATH + $WYZEINIT_SCRIPT & + return 0 fi # Log syncing @@ -524,20 +545,12 @@ cmd_run() { if [ ! -z $MMC_GPIO_REDIR ];then echo "1" > $MMC_GPIO_REDIR fi - $WYZEHACK_DIR/bin/hackutils init - - export WYZEINIT_MD5=$(md5sum $WYZEINIT_SCRIPT| grep -oE "^[0-9a-f]*") - echo "WyzeHack: app_init signature: $WYZEINIT_MD5" - - local LOADER_SCRIPT="$WYZEHACK_DIR/init/$WYZEINIT_MD5/init.sh" - if [ ! -f "$LOADER_SCRIPT" ]; - then - echo "WyzeHack: Unknown app_init.sh signature:$WYZEINIT_MD5" - LOADER_SCRIPT="$WYZEHACK_DIR/init/unknown/init.sh" - fi - # Load init script for the current firmware version - source $LOADER_SCRIPT + # libsetunbuf.so is used as LD_PRELOAD for later v2 firmwares, so + # replace it with ours + ln -s $WYZEHACK_DIR/bin/libhacks.so $WYZEHACK_DIR/bin/libsetunbuf.so + $WYZEHACK_DIR/bin/hackutils init + LD_PRELOAD=$WYZEHACK_DIR/bin/libhacks.so $WYZEINIT_SCRIPT & fi # Wait until WIFI is connected @@ -611,13 +624,16 @@ cmd_install() { cp -rL /etc $SD_DIR/debug fi - # Always try to enable telnetd - echo "WyzeHack: Enabling telnetd..." - busybox telnetd + if ! pgrep -f telnetd > /dev/null 2>&1; then + # Swapping shadow file so we can telnetd in without password. This + # is for debugging purpose. + set_passwd 'root::10933:0:99999:7:::' + + # Always try to enable telnetd + echo "WyzeHack: Enabling telnetd..." + busybox telnetd + fi - # Swapping shadow file so we can telnetd in without password. This - # is for debugging purpose. - set_passwd 'root::10933:0:99999:7:::' if [ -z "$WYZEAPP_VER" ]; then echo "WyzeHack: Wyze version not found!!!"