New init system (#216)

* new init system

* update new init scripts

* update checksum

* fix broken audio promps with new init scripts

* fix debug/upgrade mode

* fix bonding and eth0 hw addr

* add checksum

* fix bonding setup

* add rtsp auth disable

* adjust network init scripts path

* recreated repo and re added cron scripts (#211)

* recreated repo and re added cron scripts

* rename cron script and move it to the right folder.

* Delete .vs directory

remove .vs directory

* add deubg message to bonding rc.d script

* add crontab variable to wz_mini.conf

* fix mp4write

* add syslog debug feature

* fix syslog init blocking

* fix syslog save function

* increase imp_helper rerun delay

* update init scripts

* fix bonding and usb-direct

* update checksum

* add netmon for bonding

* fix supervisor function

* update model detection

* fix debugging injection on T20 devices

Co-authored-by: sideup66 <47700565+sideup66@users.noreply.github.com>
This commit is contained in:
gtxaspec
2022-08-07 18:46:00 -07:00
committed by GitHub
parent 98743f21c9
commit 9ce6bbd92a
59 changed files with 2131 additions and 1222 deletions

View File

@@ -10,7 +10,7 @@ if [ -d /opt/wz_mini/tmp/log_gather ] ; then
rm -rf /opt/wz_mini/tmp/log_gather
create_dir
else
create_dir
create_dir
fi
echo "copy wz_mini logs"
@@ -64,8 +64,8 @@ if [ -f /tmp/sd_check_result.txt ]; then
fi
if [[ "$RTSP_PASSWORD" == "" ]]; then
echo "password is blank in config"
RTSP_PASSWORD=$(cat /opt/wz_mini/tmp/wlan0_mac)
echo "password is blank in config"
RTSP_PASSWORD=$(cat /opt/wz_mini/tmp/wlan0_mac)
fi
cd /opt/wz_mini/tmp/log_gather

View File

@@ -0,0 +1,9 @@
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
#45 05 * * * /sbin/reboot

View File

@@ -0,0 +1,41 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Bind mount system files.
# Description: Replace specific system files with our customized versions via bind mount
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
echo "Replace stock busybox"
mount --bind /opt/wz_mini/bin/busybox /bin/busybox
echo "Replace stock fstab"
mount --bind /opt/wz_mini/etc/fstab /etc/fstab
echo "Replace stock inittab"
mount --bind /opt/wz_mini/etc/inittab /etc/inittab
echo "Replace /etc/profile for local/ssh shells"
mount --bind /opt/wz_mini/etc/profile /etc/profile
if [ -d /lib/modules ]; then
echo "Mount kernel modules in /lib"
mount --bind /opt/wz_mini/lib/modules /lib/modules
fi
echo "Replace system hostname"
echo $CUSTOM_HOSTNAME > /opt/wz_mini/etc/hostname
mount --bind /opt/wz_mini/etc/hostname /etc/hostname
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,30 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Mount tmpfs
# Description: Mount tmpfs for system and wz_mini
### END INIT INFO
./opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
echo "Mount wz_mini tmpfs"
mount -t tmpfs /opt/wz_mini/tmp
echo "Create workspace directory"
mkdir /opt/wz_mini/tmp/.storage
echo "Mounting global tmpfs"
mount -t tmpfs /tmp
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,23 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Setup BusyBox
# Description: Install BusyBox applets to wz_mini $PATH
### END INIT INFO
case "$1" in
start)
echo "#####$(basename "$0")#####"
echo "Install busybox applets"
mkdir /opt/wz_mini/tmp/.bin
/opt/wz_mini/bin/busybox --install -s /opt/wz_mini/tmp/.bin
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,47 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Detect device model
# Description: Detect which model device we are, and configure the system accordingly
### END INIT INFO
case "$1" in
start)
echo "#####$(basename "$0")#####"
##DETECT CAMERA MODEL & PLATFORM TYPE
#V2=WYZEC1-JZ
#PANv1=WYZECP1_JEF
#PANv2=HL_PAN2
#V3=WYZE_CAKP2JFUS
#DB3=WYZEDB3
#V3C=ATOM_CamV3C
#mtdblock9 only exists on the T20 platform, indicating V2 or PANv1
if [ -b /dev/mtdblock9 ]; then
mkdir /opt/wz_mini/tmp/params
mount -t jffs2 /dev/mtdblock9 /opt/wz_mini/tmp/params
touch /opt/wz_mini/tmp/.$(cat /opt/wz_mini/tmp/params/config/.product_config | grep PRODUCT_MODEL | sed -e 's#.*=\(\)#\1#')
touch /opt/wz_mini/tmp/.T20
echo "$(cat /opt/wz_mini/tmp/params/config/.product_config | grep PRODUCT_MODEL | sed -e 's#.*=\(\)#\1#') detected"
umount /opt/wz_mini/tmp/params
rm -rf /opt/wz_mini/tmp/params
elif [ -b /dev/mtdblock6 ]; then
mkdir /opt/wz_mini/tmp/configs
mount -t jffs2 /dev/mtdblock6 /opt/wz_mini/tmp/configs
touch /opt/wz_mini/tmp/.$(cat /opt/wz_mini/tmp/configs/.product_config | grep PRODUCT_MODEL | sed -e 's#.*=\(\)#\1#')
touch /opt/wz_mini/tmp/.T31
echo "$(cat /opt/wz_mini/tmp/configs/.product_config | grep PRODUCT_MODEL | sed -e 's#.*=\(\)#\1#') detected"
umount /opt/wz_mini/tmp/configs
rm -rf /opt/wz_mini/tmp/configs
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,28 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Mount /system
# Description: Mount /system for manipulation, before app_init.sh does
### END INIT INFO
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "mounting /system"
mount -t jffs2 /dev/mtdblock4 /system
elif [ -f /opt/wz_mini/tmp/.T31 ]; then
echo "mounting /system"
mount /dev/mtdblock3 /system
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,30 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Detect device CAR
# Description: Detect which CAR device
### END INIT INFO
case "$1" in
start)
echo "#####$(basename "$0")#####"
echo "Checking for CAR FW"
if [ -f /opt/wz_mini/tmp/.WYZEC1-JZ ]; then
if cat /system/bin/app.ver | grep 4.55; then
touch /opt/wz_mini/tmp/.CAR
echo "CAR FW detected!"
else
echo "CAR not detected"
fi
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,69 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Inject commands into app_init.sh
# Description: Patch app_init.sh to inject wz_mini's init.d scripts
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
echo "Copy stock rcS"
cp /etc/init.d/rcS /opt/wz_mini/tmp/.storage/rcS
echo "Add verbose debugging to rcS"
sed -i '/^\# Set mdev.*/iset -x\n' /opt/wz_mini/tmp/.storage/rcS
echo "Inject init.d scripts to rcS"
sed -i '/^# Run init script.*/i/opt/wz_mini/etc/rc.d/K01network \&\n' /opt/wz_mini/tmp/.storage/rcS
sed -i '/^# Run init script.*/i/opt/wz_mini/etc/rc.d/K03rcd\n' /opt/wz_mini/tmp/.storage/rcS
echo "Modify Global Paths in rcS"
sed -i '/sbin:/s/$/:\/opt\/wz_mini\/bin/' /opt/wz_mini/tmp/.storage/rcS
sed -i '/system\/\lib/s/$/:\/opt\/wz_mini\/lib/' /opt/wz_mini/tmp/.storage/rcS
#Custom PATH hooks
#sed -i '/^# Run init script.*/i#Hook Library PATH here\nexport LD_LIBRARY_PATH=/tmp/test/lib:$LD_LIBRARY_PATH\n' /opt/wz_mini/tmp/.storage/rcS
#sed -i '/^# Run init script.*/i#Hook system PATH here\nexport PATH=/tmp/test/bin:$PATH\n' /opt/wz_mini/tmp/.storage/rcS
echo "Copy factory app_init.sh"
cp /system/init/app_init.sh /opt/wz_mini/tmp/.storage/app_init.sh
echo "Replace factory app_init.sh path"
sed -i '/\/system\/init\/app_init.sh/,+4d' /opt/wz_mini/tmp/.storage/rcS
sed -i '/Run init script.*/a /opt/wz_mini/tmp/.storage/app_init.sh \&\n' /opt/wz_mini/tmp/.storage/rcS
sed -i '/\/system\/init\/app_init.sh/,+2d' /opt/wz_mini/tmp/.storage/rcS
if [[ "$DEBUG_ENABLED" == "true" ]]; then
sed -i '/app_init.sh/,+4d' /opt/wz_mini/tmp/.storage/rcS
sed -i '/^# Run init/i/bin/sh /etc/profile' /opt/wz_mini/tmp/.storage/rcS
touch /tmp/dbgflag
elif [[ "$WEB_CAM_ENABLE" == "true" ]]; then
sed -i '/app_init.sh/,+4d' /opt/wz_mini/tmp/.storage/rcS
sed -i '/^# Run init/i/opt/wz_mini/etc/rc.d/K02webcam &' /opt/wz_mini/tmp/.storage/rcS
touch /tmp/dbgflag
elif [[ -d /opt/Upgrade ]]; then
sed -i '/app_init.sh/,+4d' /opt/wz_mini/tmp/.storage/rcS
sed -i '/^# Run init/i/bin/sh /etc/profile' /opt/wz_mini/tmp/.storage/rcS
sed -i '/^# Mount configs.*/i/opt/wz_mini/bin/upgrade-run.sh &\n' /opt/wz_mini/tmp/.storage/rcS
touch /tmp/dbgflag
fi
echo "Enable libcallback"
if [[ "$LIBCALLBACK_ENABLE" == "true" ]] || ([[ "$RTSP_HI_RES_ENABLED" == "true" ]] || [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]); then
echo "set path for iCamera"
sed -i 's/\/system\/bin\/iCamera/\/opt\/wz_mini\/usr\/bin\/iCamera/g' /opt/wz_mini/tmp/.storage/app_init.sh
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,30 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Change system password
# Description: Replace system password with wz_mini's version
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
echo "Replace stock password"
cp /opt/wz_mini/etc/shadow /opt/wz_mini/tmp/.storage/shadow
if [[ "$DEBUG_PASSWORD" == "true" ]]; then
sed -i 's/:[^:]*/:/' /opt/wz_mini/tmp/.storage/shadow
echo "Remove stock password"
fi
mount --bind /opt/wz_mini/tmp/.storage/shadow /etc/shadow
chmod 400 /etc/shadow
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,40 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Check for first boot of wz_mini
# Description: Check to see if this is the first time wz_mini is booting, if it is, play an audio prompt
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
. /opt/wz_mini/etc/rc.common
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [ -e /opt/wz_mini/etc/.first_boot ]; then
echo "First boot already completed"
else
echo "First boot, initializing"
touch /opt/wz_mini/etc/.first_boot
#May need different gpio for PANv1
#We don't rmmod this module, as it is marked [permanent] by the kernel on T20
if [ -f /opt/wz_mini/tmp/.T20 ]; then
insmod /opt/wz_mini/lib/modules/3.10.14/extra/audio.ko sign_mode=0
LD_LIBRARY_PATH='/opt/wz_mini/lib' /opt/wz_mini/bin/audioplay_t20 /opt/wz_mini/usr/share/audio/init_v2.wav $AUDIO_PROMPT_VOLUME
else
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/extra/audio.ko spk_gpio=$GPIO alc_mode=0 mic_gain=0
/opt/wz_mini/bin/audioplay_t31 /opt/wz_mini/usr/share/audio/init.wav $AUDIO_PROMPT_VOLUME
rmmod audio
fi
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,160 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Load kernel modules
# Description: Load kernel modules depending on model and configuration
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
. /opt/wz_mini/etc/rc.common
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [[ "$ENABLE_RTL8189FS_DRIVER" == "true" ]] || [[ "$ENABLE_RTL8189FS_DRIVER" == "" ]]; then
echo "Enable 8189fs"
if [ -f /opt/wz_mini/tmp/.WYZEC1-JZ ]; then
sed -i 's/\/driver\/rtl8189ftv.ko/\/opt\/wz_mini\/lib\/modules\/3.10.14\/extra\/8189fs.ko rtw_power_mgnt=0 rtw_enusbss=0 rtw_drv_log_level=0/g' /opt/wz_mini/tmp/.storage/app_init.sh
elif [ -f /opt/wz_mini/tmp/.WYZECP1_JEF ]; then
sed -i 's/insmod \/driver\/8189es.ko/insmod \/opt\/wz_mini\/lib\/modules\/3.10.14\/extra\/8189es.ko rtw_power_mgnt=0 rtw_enusbss=0 rtw_drv_log_level=0/g' /opt/wz_mini/tmp/.storage/app_init.sh
elif [ -f /opt/wz_mini/tmp/.WYZE_CAKP2JFUS ]; then
sed -i 's/\/system\/driver\/rtl8189ftv.ko/\/opt\/wz_mini\/lib\/modules\/3.10.14\_\_isvp_swan_1.0\_\_\/extra\/8189fs.ko rtw_power_mgnt=0 rtw_enusbss=0 rtw_drv_log_level=0/g' /opt/wz_mini/tmp/.storage/app_init.sh
elif [ -f /opt/wz_mini/tmp/.ATOM_CamV3C ]; then
sed -i 's/\/system\/driver\/rtl8189ftv.ko/\/opt\/wz_mini\/lib\/modules\/3.10.14\_\_isvp_swan_1.0\_\_\/extra\/8189fs.ko rtw_power_mgnt=0 rtw_enusbss=0 rtw_drv_log_level=0/g' /opt/wz_mini/tmp/.storage/app_init.sh
fi
fi
if [[ "$ENABLE_ATBM603X_DRIVER" == "true" ]] || [[ "$ENABLE_ATBM603X_DRIVER" == "" ]]; then
echo "Enable atbm603x_wifi_sdio"
if [ -f /opt/wz_mini/tmp/.ATOM_CamV3C ]; then
sed -i 's/\/thirdlib\/atbm603x_wifi_sdio.ko/\/opt\/wz_mini\/lib\/modules\/3.10.14\_\_isvp_swan_1.0\_\_\/extra\/atbm603x_wifi_sdio.ko atbm_printk_mask=0/g' /opt/wz_mini/tmp/.storage/app_init.sh
elif [ -f /opt/wz_mini/tmp/.T31 ] && ! [ -f /opt/wz_mini/tmp/.ATOM_CamV3C ]; then
sed -i 's/\/system\/driver\/atbm603x_wifi_sdio.ko/\/opt\/wz_mini\/lib\/modules\/3.10.14\_\_isvp_swan_1.0\_\_\/extra\/atbm603x_wifi_sdio.ko atbm_printk_mask=0/g' /opt/wz_mini/tmp/.storage/app_init.sh
fi
fi
if [ -f /opt/wz_mini/tmp/.CAR ] || [[ "$ENABLE_CAR_DRIVER" == "true" ]]; then
echo "Enable cp210x serial driver for car"
modprobe cp210x
fi
if ([[ "$RTSP_HI_RES_ENABLED" == "true" ]] || [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]) && ! [[ -e /tmp/dbgflag ]]; then
if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]] && [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "Load video loopback driver at video6 video7"
insmod /opt/wz_mini/lib/modules/3.10.14/extra/v4l2loopback_V2.ko video_nr=6,7
else
echo "Load video loopback driver at video1 video2"
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/extra/v4l2loopback.ko video_nr=1,2
fi
elif [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "Load video loopback driver at video7"
insmod /opt/wz_mini/lib/modules/3.10.14/extra/v4l2loopback_V2.ko video_nr=7
else
echo "Load video loopback driver at video2"
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/extra/v4l2loopback.ko video_nr=2
fi
elif [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "Load video loopback driver at video6"
insmod /opt/wz_mini/lib/modules/3.10.14/extra/v4l2loopback_V2.ko video_nr=6
else
echo "Load video loopback driver at video1"
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/extra/v4l2loopback.ko video_nr=1
fi
fi
fi
if [[ "$ENABLE_NFSv4" == "true" ]]; then
insmod $KMOD_PATH/kernel/lib/oid_registry.ko
insmod $KMOD_PATH/kernel/net/dns_resolver/dns_resolver.ko
insmod $KMOD_PATH/kernel/fs/nfs/nfsv4.ko
insmod $KMOD_PATH/kernel/net/sunrpc/auth_gss/auth_rpcgss.ko
echo "NFSv4 enabled"
fi
if [[ "$ENABLE_IPTABLES" == "true" ]]; then
insmod $KMOD_PATH/kernel/net/netfilter/x_tables.ko
insmod $KMOD_PATH/kernel/net/ipv4/netfilter/ip_tables.ko
insmod $KMOD_PATH/kernel/net/ipv4/netfilter/ipt_REJECT.ko
insmod $KMOD_PATH/kernel/net/ipv4/netfilter/iptable_filter.ko
insmod $KMOD_PATH/kernel/net/ipv4/netfilter/iptable_mangle.ko
echo "iptables IPv4 enabled"
if [[ "$ENABLE_IPV6" == "true" ]]; then
insmod $KMOD_PATH/kernel/net/ipv6/netfilter/ip6_tables.ko
insmod $KMOD_PATH/kernel/net/ipv6/netfilter/ip6t_REJECT.ko
insmod $KMOD_PATH/kernel/net/ipv6/netfilter/ip6table_filter.ko
insmod $KMOD_PATH/kernel/net/ipv6/netfilter/ip6table_mangle.ko
echo "iptables IPv6 enabled"
fi
fi
if [[ "$ENABLE_WIREGUARD" == "true" ]]; then
insmod $KMOD_PATH/kernel/net/ipv4/tunnel4.ko
insmod $KMOD_PATH/kernel/net/ipv4/ip_tunnel.ko
insmod $KMOD_PATH/kernel/net/wireguard/wireguard.ko
echo "Wireguard enabled"
fi
if [[ "$ENABLE_CIFS" == "true" ]]; then
insmod $KMOD_PATH/kernel/fs/cifs/cifs.ko
echo "CIFS enabled"
fi
if [[ "$ENABLE_USB_STORAGE" == "true" ]]; then
insmod $KMOD_PATH/kernel/drivers/scsi/scsi_mod.ko
insmod $KMOD_PATH/kernel/drivers/scsi/sd_mod.ko
insmod $KMOD_PATH/kernel/drivers/usb/storage/usb-storage.ko
echo "usb_storage enabled"
fi
if [[ "$ENABLE_EXT4" == "true" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
insmod $KMOD_PATH/kernel/lib/crc16.ko
fi
insmod $KMOD_PATH/kernel/fs/jbd2/jbd2.ko
insmod $KMOD_PATH/kernel/fs/mbcache.ko
insmod $KMOD_PATH/kernel/fs/ext4/ext4.ko
echo "ext4 support enabled"
fi
if [[ "$BONDING_ENABLED" == "true" ]]; then
if [[ "$BONDING_LINK_MONITORING_FREQ_MS" == "" ]]; then
BONDING_LINK_MONITORING_FREQ_MS="100"
fi
if [[ "$BONDING_DOWN_DELAY_MS" == "" ]]; then
BONDING_DOWN_DELAY_MS="5000"
fi
if [[ "$BONDING_UP_DELAY_MS" == "" ]]; then
BONDING_UP_DELAY_MS="5000"
fi
if [[ "$BONDING_PRIMARY_INTERFACE" == "" ]]; then
BONDING_PRIMARY_INTERFACE="eth0"
fi
if [[ "$BONDING_SECONDARY_INTERFACE" == "" ]]; then
BONDING_SECONDARY_INTERFACE="wlan0"
fi
if [[ "$BONDING_FAIL_OVER_MAC" == "" ]]; then
BONDING_FAIL_OVER_MAC="0"
fi
echo "Insert the bonding driver into the kernel"
insmod $KMOD_PATH/kernel/drivers/net/bonding/bonding.ko mode=active-backup miimon="$BONDING_LINK_MONITORING_FREQ_MS" downdelay="$BONDING_DOWN_DELAY_MS" updelay="$BONDING_UP_DELAY_MS" primary="$BONDING_PRIMARY_INTERFACE" fail_over_mac="$BONDING_FAIL_OVER_MAC"
echo "Network bonding enabled"
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,52 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Backup critical device files
# Description: Backup /configs and /params directory, these files are unique to the device, and if lost the camera is unusable.
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [ -d /opt/.wz_backup ]; then
echo "Factory config backup directory missing"
else
echo "Creating factory config backup directory"
mkdir /opt/.wz_backup
fi
if [ -f /opt/wz_mini/tmp/.T31 ]; then
echo "T31 platform backup"
if [ -d /opt/.wz_backup/configs ]; then
echo "Factory configs backup directory present, not backing up again"
else
echo "Backup /configs"
cp -R /configs/ /opt/.wz_backup/
fi
elif [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "T20 platform backup"
if [ -d /opt/.wz_backup/configs ]; then
echo "Factory configs backup directory present, not backing up again"
else
echo "Backup /configs"
cp -R /configs/ /opt/.wz_backup/
fi
if [ -d /opt/.wz_backup/params ]; then
echo "Factory params backup directory present, not backing up again"
else
echo "Backup /params"
cp -R /params/ /opt/.wz_backup/
fi
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,23 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Start ssh daemon
# Description: Run the dropbear ssh daemon
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
echo "Running dropbear ssh server"
/opt/wz_mini/bin/dropbear -R -s -g
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,27 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Check for terminfo directory
# Description: Provide the proper terminfo files for nano and shells
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [ -d /opt/wz_mini/usr/share/terminfo ]; then
echo "Terminfo already present"
else
echo "Terminfo not present, extract"
tar xf /opt/wz_mini/usr/share/terminfo.tar -C /opt/wz_mini/usr/share/
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,26 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Disable factorycheck
# Description: On T31 devices, we must disable factory check to prevent it from unmounting our binds.
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [ -f /opt/wz_mini/tmp/.T31 ]; then
mount --bind /opt/wz_mini/bin/factorycheck /system/bin/factorycheck
touch /tmp/usrflag
echo "Replace factorycheck with dummy, to prevent bind unmount"
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

205
SD_ROOT/wz_mini/etc/init.d/wz_init.sh Executable file → Normal file
View File

@@ -1,5 +1,10 @@
#!/bin/sh
#init.d/ = early boot, before inittab is run
#rc.d/ = runs after /linuxrc, but before app_init.sh
#network.d/ runs after app_init.sh, and after wlan hw is ready
#rc.local.d/ = runs after app_init.sh and network has acquired an address
###This file is run by switch_root, from the initramfs in the kernel.
LOG_NAME=/opt/wz_mini/log/wz_init
if [[ -e $LOG_NAME.log || -L $LOG_NAME.log ]] ; then
@@ -13,10 +18,6 @@ fi
touch -- "$LOG_NAME".log
exec 1> $LOG_NAME.log 2>&1
export WZMINI_CFG=/opt/wz_mini/wz_mini.conf
[ -f $WZMINI_CFG ] && source $WZMINI_CFG
echo "welcome to wz_init.sh"
echo "PID $$"
@@ -31,182 +32,28 @@ echo '
|______|
'
set -x
# Start all init scripts in /etc/init.d
# executing them in numerical order.
#
for i in /opt/wz_mini/etc/init.d/S??* ;do
echo "replace stock busybox"
mount --bind /opt/wz_mini/bin/busybox /bin/busybox
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
echo "replace stock fstab"
mount --bind /opt/wz_mini/etc/fstab /etc/fstab
echo "mount wz_mini tmpfs"
mount -t tmpfs /opt/wz_mini/tmp
echo "install busybox applets"
mkdir /opt/wz_mini/tmp/.bin
/opt/wz_mini/bin/busybox --install -s /opt/wz_mini/tmp/.bin
##DETECT CAMERA MODEL & PLATFORM TYPE
#V2=WYZEC1-JZ
#PANv1=WYZECP1_JEF
#PANv2=HL_PAN2
#V3=WYZE_CAKP2JFUS
#DB3=WYZEDB3
#V3C=ATOM_CamV3C
#mtdblock9 only exists on the T20 platform, indicating V2 or PANv1
if [ -b /dev/mtdblock9 ]; then
mkdir /opt/wz_mini/tmp/params
mount -t jffs2 /dev/mtdblock9 /opt/wz_mini/tmp/params
touch /opt/wz_mini/tmp/.$(cat /opt/wz_mini/tmp/params/config/.product_config | grep PRODUCT_MODEL | sed -e 's#.*=\(\)#\1#')
touch /opt/wz_mini/tmp/.T20
umount /opt/wz_mini/tmp/params
rm -rf /opt/wz_mini/tmp/params
elif [ -b /dev/mtdblock6 ]; then
mkdir /opt/wz_mini/tmp/configs
mount -t jffs2 /dev/mtdblock6 /opt/wz_mini/tmp/configs
touch /opt/wz_mini/tmp/.$(cat /opt/wz_mini/tmp/configs/.product_config | grep PRODUCT_MODEL | sed -e 's#.*=\(\)#\1#')
touch /opt/wz_mini/tmp/.T31
umount /opt/wz_mini/tmp/configs
rm -rf /opt/wz_mini/tmp/configs
fi
#Set the correct GPIO for the audio driver (T31 only)
if [ -f /opt/wz_mini/tmp/.HL_PAN2 ]; then
GPIO=7
elif [ -f /opt/wz_mini/tmp/.WYZE_CAKP2JFUS ]; then
GPIO=63
fi
if [ -e /opt/wz_mini/etc/.first_boot ]; then
echo "first boot already completed"
else
echo "first boot, initializing"
if [ -f /opt/wz_mini/tmp/.T20 ]; then
#May need different gpio for PANv1
#We don't rmmod this module, as it is marked [permanent] by the kernel on T20
insmod /opt/wz_mini/lib/modules/3.10.14/extra/audio.ko sign_mode=0
LD_LIBRARY_PATH='/opt/wz_mini/lib' /opt/wz_mini/bin/audioplay_t20 /opt/wz_mini/usr/share/audio/init_v2.wav $AUDIO_PROMPT_VOLUME
else
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/extra/audio.ko spk_gpio=$GPIO alc_mode=0 mic_gain=0
/opt/wz_mini/bin/audioplay_t31 /opt/wz_mini/usr/share/audio/init.wav $AUDIO_PROMPT_VOLUME
rmmod audio
fi
fi
if [ -f /opt/wz_mini/etc/.first_boot ]; then
echo "Not first_boot"
else
echo "Set first_boot"
touch /opt/wz_mini/etc/.first_boot
fi
echo "replace stock inittab"
mount --bind /opt/wz_mini/etc/inittab /etc/inittab
echo "bind /etc/profile for local/ssh shells"
mount --bind /opt/wz_mini/etc/profile /etc/profile
echo "mounting global tmpfs"
mount -t tmpfs /tmp
echo "mount system to replace factorycheck with dummy, to prevent bind unmount"
if [ -f /opt/wz_mini/tmp/.T31 ]; then
mount /dev/mtdblock3 /system
mount --bind /opt/wz_mini/bin/factorycheck /system/bin/factorycheck
fi
touch /tmp/usrflag
echo "create workspace directory"
mkdir /opt/wz_mini/tmp/.storage
echo "copy stock rcS"
cp /etc/init.d/rcS /opt/wz_mini/tmp/.storage/rcS
echo "add wz_post inject to stock rcS"
sed -i '/^".*/aset -x' /opt/wz_mini/tmp/.storage/rcS
sed -i '/^# Run init script.*/i/opt/wz_mini/etc/init.d/wz_post.sh\n' /opt/wz_mini/tmp/.storage/rcS
sed -i '/sbin:/s/$/:\/opt\/wz_mini\/bin/' /opt/wz_mini/tmp/.storage/rcS
sed -i '/system\/\lib/s/$/:\/opt\/wz_mini\/lib/' /opt/wz_mini/tmp/.storage/rcS
#Custom PATH hooks
#sed -i '/^# Run init script.*/i#Hook Library PATH here\nexport LD_LIBRARY_PATH=/tmp/test/lib:$LD_LIBRARY_PATH\n' /opt/wz_mini/tmp/.storage/rcS
#sed -i '/^# Run init script.*/i#Hook system PATH here\nexport PATH=/tmp/test/bin:$PATH\n' /opt/wz_mini/tmp/.storage/rcS
if [ -f /opt/wz_mini/tmp/.T20 ]; then
mount -t jffs2 /dev/mtdblock4 /system
fi
#Check for Car FW
if [ -f /opt/wz_mini/tmp/.WYZEC1-JZ ]; then
if cat /system/bin/app.ver | grep 4.55; then
touch /opt/wz_mini/tmp/.CAR
fi
fi
echo "Copy factory app_init.sh"
cp /system/init/app_init.sh /opt/wz_mini/tmp/.storage/app_init.sh
echo "Replace factory app_init.sh path"
sed -i '/\/system\/init\/app_init.sh/,+4d' /opt/wz_mini/tmp/.storage/rcS
sed -i '/Run init script.*/a /opt/wz_mini/tmp/.storage/app_init.sh\n' /opt/wz_mini/tmp/.storage/rcS
sed -i '/\/system\/init\/app_init.sh/,+2d' /opt/wz_mini/tmp/.storage/rcS
echo "replace stock password"
cp /opt/wz_mini/etc/shadow /opt/wz_mini/tmp/.storage/shadow
if [[ "$DEBUG_PASSWORD" == "true" ]]; then
sed -i 's/:[^:]*/:/' /opt/wz_mini/tmp/.storage/shadow
fi
mount --bind /opt/wz_mini/tmp/.storage/shadow /etc/shadow
chmod 400 /etc/shadow
if [[ -e /opt/wz_mini/swap.gz ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
LD_LIBRARY_PATH='/opt/wz_mini/lib' /opt/wz_mini/bin/audioplay_t20 /opt/wz_mini/usr/share/audio/swap_v2.wav $AUDIO_PROMPT_VOLUME
else
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/extra/audio.ko spk_gpio=$GPIO alc_mode=0 mic_gain=0
/opt/wz_mini/bin/audioplay_t31 /opt/wz_mini/usr/share/audio/swap.wav $AUDIO_PROMPT_VOLUME
rmmod audio
fi
echo "swap archive present, extracting"
gzip -d /opt/wz_mini/swap.gz
mkswap /opt/wz_mini/swap
sync;echo 3 > /proc/sys/vm/drop_caches
else
echo "swap archive missing, not extracting"
fi
if [ -d /opt/wz_mini/usr/share/terminfo ]; then
echo "terminfo already present"
else
echo "terminfo not present, extract"
tar xf /opt/wz_mini/usr/share/terminfo.tar -C /opt/wz_mini/usr/share/
fi
echo "Run dropbear ssh server"
/opt/wz_mini/bin/dropbear -R -s -g
if [[ "$DEBUG_ENABLED" == "true" ]]; then
sed -i '/app_init.sh/,+4d' /opt/wz_mini/tmp/.storage/rcS
sed -i '/^# Run init/i/bin/sh /etc/profile' /opt/wz_mini/tmp/.storage/rcS
touch /tmp/dbgflag
elif [[ "$WEB_CAM_ENABLE" == "true" ]]; then
sed -i '/app_init.sh/,+4d' /opt/wz_mini/tmp/.storage/rcS
sed -i '/^# Run init/i/opt/wz_mini/etc/init.d/wz_cam.sh &' /opt/wz_mini/tmp/.storage/rcS
touch /tmp/dbgflag
elif [[ -d /opt/Upgrade ]]; then
sed -i '/app_init.sh/,+4d' /opt/wz_mini/tmp/.storage/rcS
sed -i '/^# Run init/i/bin/sh /etc/profile' /opt/wz_mini/tmp/.storage/rcS
sed -i '/^# Mount configs.*/i/opt/wz_mini/bin/upgrade-run.sh &\n' /opt/wz_mini/tmp/.storage/rcS
touch /tmp/dbgflag
fi
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done
/linuxrc

View File

@@ -1,153 +0,0 @@
#!/bin/sh
### This file is called by /etc/init.d/rcS, and is run before app_init.sh
LOG_NAME=/opt/wz_mini/log/wz_post
if [[ -e $LOG_NAME.log || -L $LOG_NAME.log ]] ; then
i=0
while [[ -e $LOG_NAME.log.$i || -L $LOG_NAME.log.$i ]] ; do
let i++
done
mv $LOG_NAME.log $LOG_NAME.log.$i
LOG_NAME=$LOG_NAME
fi
touch -- "$LOG_NAME".log
exec 1> $LOG_NAME.log 2>&1
set -x
if [ -e /tmp/dbgflag ];then
echo "debug mode, disabled"
exit 0
fi
export WZMINI_CFG=/opt/wz_mini/wz_mini.conf
[ -f $WZMINI_CFG ] && source $WZMINI_CFG
echo "welcome to wz_post.sh"
echo "PID $$"
#CAMERA CONFIGURATION FILES BACKUP
if [ -d /opt/.wz_backup ]; then
echo "backup directory missing"
else
echo "creating backup directory"
mkdir /opt/.wz_backup
fi
if [ -f /opt/wz_mini/tmp/.T31 ]; then
echo "T31 platform backup"
if [ -d /opt/.wz_backup/configs ]; then
echo "configs backup directory present, not backing up again"
else
echo "backup /configs"
cp -R /configs/ /opt/.wz_backup/
fi
elif [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "T20 platform backup"
if [ -d /opt/.wz_backup/configs ]; then
echo "configs backup directory present, not backing up again"
else
echo "backup /configs"
cp -R /configs/ /opt/.wz_backup/
fi
if [ -d /opt/.wz_backup/params ]; then
echo "configs backup directory present, not backing up again"
else
echo "backup /params"
cp -R /params/ /opt/.wz_backup/
fi
fi
#SWAP FILE, REQUIRED FOR OPERATION!
if [[ "$ENABLE_SWAP" == "true" ]] && [[ -e /opt/wz_mini/swap ]]; then
echo "swap file found, enable"
swapon /opt/wz_mini/swap
else
echo "swap file missing"
fi
if [ -d /lib/modules ]; then
echo "mount kernel modules"
mount --bind /opt/wz_mini/lib/modules /lib/modules
fi
## REPLACE STOCK MODULES
if [[ "$ENABLE_RTL8189FS_DRIVER" == "true" ]] || [[ "$ENABLE_RTL8189FS_DRIVER" == "" ]]; then
echo "Enable 8189fs"
if [ -f /opt/wz_mini/tmp/.WYZEC1-JZ ]; then
sed -i 's/\/driver\/rtl8189ftv.ko/\/opt\/wz_mini\/lib\/modules\/3.10.14\/extra\/8189fs.ko rtw_power_mgnt=0 rtw_enusbss=0 rtw_drv_log_level=0/g' /opt/wz_mini/tmp/.storage/app_init.sh
elif [ -f /opt/wz_mini/tmp/.WYZECP1_JEF ]; then
sed -i 's/insmod \/driver\/8189es.ko/insmod \/opt\/wz_mini\/lib\/modules\/3.10.14\/extra\/8189es.ko rtw_power_mgnt=0 rtw_enusbss=0 rtw_drv_log_level=0/g' /opt/wz_mini/tmp/.storage/app_init.sh
elif [ -f /opt/wz_mini/tmp/.WYZE_CAKP2JFUS ]; then
sed -i 's/\/system\/driver\/rtl8189ftv.ko/\/opt\/wz_mini\/lib\/modules\/3.10.14\_\_isvp_swan_1.0\_\_\/extra\/8189fs.ko rtw_power_mgnt=0 rtw_enusbss=0 rtw_drv_log_level=0/g' /opt/wz_mini/tmp/.storage/app_init.sh
elif [ -f /opt/wz_mini/tmp/.ATOM_CamV3C ]; then
sed -i 's/\/system\/driver\/rtl8189ftv.ko/\/opt\/wz_mini\/lib\/modules\/3.10.14\_\_isvp_swan_1.0\_\_\/extra\/8189fs.ko rtw_power_mgnt=0 rtw_enusbss=0 rtw_drv_log_level=0/g' /opt/wz_mini/tmp/.storage/app_init.sh
fi
fi
if [[ "$ENABLE_ATBM603X_DRIVER" == "true" ]] || [[ "$ENABLE_ATBM603X_DRIVER" == "" ]]; then
echo "Enable atbm603x_wifi_sdio"
if [ -f /opt/wz_mini/tmp/.ATOM_CamV3C ]; then
sed -i 's/\/thirdlib\/atbm603x_wifi_sdio.ko/\/opt\/wz_mini\/lib\/modules\/3.10.14\_\_isvp_swan_1.0\_\_\/extra\/atbm603x_wifi_sdio.ko atbm_printk_mask=0/g' /opt/wz_mini/tmp/.storage/app_init.sh
elif [ -f /opt/wz_mini/tmp/.T31 ] && ! [ -f /opt/wz_mini/tmp/.ATOM_CamV3C ]; then
sed -i 's/\/system\/driver\/atbm603x_wifi_sdio.ko/\/opt\/wz_mini\/lib\/modules\/3.10.14\_\_isvp_swan_1.0\_\_\/extra\/atbm603x_wifi_sdio.ko atbm_printk_mask=0/g' /opt/wz_mini/tmp/.storage/app_init.sh
fi
fi
##ENABLE LIBCALLBACK BY DEFAULT
if [[ "$LIBCALLBACK_ENABLE" == "true" ]] || ([[ "$RTSP_HI_RES_ENABLED" == "true" ]] || [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]); then
echo "set path for iCamera"
sed -i 's/\/system\/bin\/iCamera/\/opt\/wz_mini\/usr\/bin\/iCamera/g' /opt/wz_mini/tmp/.storage/app_init.sh
fi
#RTSP SERVER
if ([[ "$RTSP_HI_RES_ENABLED" == "true" ]] || [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]) && ! [[ -e /tmp/dbgflag ]]; then
if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]] && [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "load video loopback driver at video6 video7"
insmod /opt/wz_mini/lib/modules/3.10.14/extra/v4l2loopback_V2.ko video_nr=6,7
else
echo "load video loopback driver at video1 video2"
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/extra/v4l2loopback.ko video_nr=1,2
fi
elif [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "load video loopback driver at video7"
insmod /opt/wz_mini/lib/modules/3.10.14/extra/v4l2loopback_V2.ko video_nr=7
else
echo "load video loopback driver at video2"
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/extra/v4l2loopback.ko video_nr=2
fi
elif [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "load video loopback driver at video6"
insmod /opt/wz_mini/lib/modules/3.10.14/extra/v4l2loopback_V2.ko video_nr=6
else
echo "load video loopback driver at video1"
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/extra/v4l2loopback.ko video_nr=1
fi
fi
fi
#MOTORIZED CAMERA CONTROL
if [[ "$DISABLE_MOTOR" == "true" ]]; then
echo "Motor Disabled"
touch /opt/wz_mini/tmp/.ms
fi
#Enable serial driver for car
if [ -f /opt/wz_mini/tmp/.CAR ] || [[ "$ENABLE_CAR_DRIVER" == "true" ]]; then
modprobe cp210x
fi
/opt/wz_mini/etc/init.d/wz_user.sh &
##LIBRARY DEBUG
#cp /opt/wz_mini/lib/uClibc.tar /tmp
#tar -xf /tmp/uClibc.tar -C /tmp
#mount --bind /tmp/lib /lib
#cp /system/bin/iCamera /opt/wz_mini/tmp/.storage/
#mount -o ro,bind /opt/wz_mini/usr/bin/iCamera-dbg /system/bin/iCamera

View File

@@ -1,625 +0,0 @@
#!/bin/sh
LOG_NAME=/opt/wz_mini/log/wz_user
if [[ -e $LOG_NAME.log || -L $LOG_NAME.log ]] ; then
i=0
while [[ -e $LOG_NAME.log.$i || -L $LOG_NAME.log.$i ]] ; do
let i++
done
mv $LOG_NAME.log $LOG_NAME.log.$i
LOG_NAME=$LOG_NAME
fi
touch -- "$LOG_NAME".log
exec 1> $LOG_NAME.log 2>&1
set -x
echo "welcome to wz_user.sh"
echo "PID $$"
if [[ -e /tmp/dbgflag ]];then
echo "debug mode, disabled"
exit 0
fi
export WZMINI_CFG=/opt/wz_mini/wz_mini.conf
[ -f $WZMINI_CFG ] && source $WZMINI_CFG
hostname_set() {
echo "set hostname"
hostname $CUSTOM_HOSTNAME
}
first_run_check() {
if [ -e /opt/wz_mini/tmp/.wz_user_firstrun ]; then
echo "wz_user.sh already run once, exit."
exit 0
fi
}
store_mac() {
echo "store original mac"
cat /sys/class/net/wlan0/address | tr '[:lower:]' '[:upper:]' > /opt/wz_mini/tmp/wlan0_mac
}
wait_wlan() {
##Check if the driver has been loaded for the onboard wlan0, store the MAC.
while true
do
if ifconfig wlan0 | grep "HWaddr"; then
echo "wlan0 hwaddr is up"
store_mac
break
else
echo "wlan0 hwaddr not ready yet..."
sleep 5
fi
done
}
wpa_check() {
##Check if wpa_supplicant has been created by iCamera
if [ -e /tmp/wpa_supplicant.conf ]; then
wait_wlan
echo "wpa_supplicant.conf ready"
else
echo "wpa_supplicant.conf not ready, wait some time for creation."
COUNT=0
ATTEMPTS=15
until [[ -e /tmp/wpa_supplicant.conf ]] || [[ $COUNT -eq $ATTEMPTS ]]; do
echo -e "$(( COUNT++ ))... \c"
sleep 5
wpa_check
done
if [[ $COUNT -eq $ATTEMPTS ]]; then
echo "time exceeded waiting for iCamera, continue potentially broken condition without network."
fi
fi
}
wlanold_check() {
#Have we renamed interfaces yet?
if [ -d /sys/class/net/wlanold ]; then
echo "wlanold exist"
eth_wlan_up
else
echo "wlanold doesn't exist"
if [[ "$BONDING_ENABLED" == "true" ]] && ([[ "$ENABLE_USB_ETH" == "true" ]] || [[ "$ENABLE_USB_DIRECT" == "true" ]]); then
rename_interface_and_setup_bonding bond0 "$BONDING_PRIMARY_INTERFACE" "$BONDING_SECONDARY_INTERFACE"
else
rename_interface $1
fi
fi
}
netloop() {
##While loop for check
while true
do
wlanold_check $1
echo "wlan0 not ready yet..."
sleep 5
done
}
rename_interface() {
##Fool iCamera by renaming the hardline interface to wlan0
echo "renaming interfaces"
ifconfig $1 down
ifconfig wlan0 down
/opt/wz_mini/bin/busybox ip link set wlan0 name wlanold
/opt/wz_mini/bin/busybox ip addr flush dev wlanold
/opt/wz_mini/bin/busybox ip link set $1 name wlan0
eth_wlan_up
}
rename_interface_and_setup_bonding() {
##Fool iCamera by renaming the hardline interface to wlan0
## $1 Bonding Interface, $2 Primary Interface, $3 Secondary Interface
bonding_interface=$1
primary_interface=$2
secondary_interface=$3
echo "renaming interfaces"
# Bring all interfaces down
ifconfig $bonding_interface down
ifconfig $primary_interface down
ifconfig $secondary_interface down
# Have to bring bonding interface up to be able to bond our slaves.
/opt/wz_mini/bin/busybox ip link set $bonding_interface up
# Rename the real wlan0 interface if needed/used
if [[ "$primary_interface" == "wlan0" ]]; then
/opt/wz_mini/bin/busybox ip link set $primary_interface name wlanold
/opt/wz_mini/bin/busybox ip addr flush dev wlanold
primary_interface="wlanold"
# Because we just changed the name of the primary interface, we need to
# tell the bonding driver about the name change as well.
echo "$primary_interface" > /sys/devices/virtual/net/$bonding_interface/bonding/primary
fi
if [[ "$secondary_interface" == "wlan0" ]]; then
/opt/wz_mini/bin/busybox ip link set $secondary_interface name wlanold
/opt/wz_mini/bin/busybox ip addr flush dev wlanold
secondary_interface="wlanold"
fi
# Enslave the Ethernet and Original Wifi interfaces
# under the bonding interface.
/opt/wz_mini/tmp/.bin/ifenslave $bonding_interface $primary_interface $secondary_interface
# Have to bring bonding interface down to be rename the interface
/opt/wz_mini/bin/busybox ip link set $bonding_interface down
# Name the bonding interface to be the "new" wlan0 interface
/opt/wz_mini/bin/busybox ip link set $bonding_interface name wlan0
# Bring the newly renamed wlan0 (actually the bond interface) back up
eth_wlan_up
}
bonding_setup() {
echo "bonding kernel module setup"
if [[ "$BONDING_ENABLED" == "true" ]]; then
if [[ "$BONDING_LINK_MONITORING_FREQ_MS" == "" ]]; then
BONDING_LINK_MONITORING_FREQ_MS="100"
fi
if [[ "$BONDING_DOWN_DELAY_MS" == "" ]]; then
BONDING_DOWN_DELAY_MS="5000"
fi
if [[ "$BONDING_UP_DELAY_MS" == "" ]]; then
BONDING_UP_DELAY_MS="5000"
fi
if [[ "$BONDING_PRIMARY_INTERFACE" == "" ]]; then
BONDING_PRIMARY_INTERFACE="$1"
fi
if [[ "$BONDING_SECONDARY_INTERFACE" == "" ]]; then
BONDING_SECONDARY_INTERFACE="$2"
fi
if [[ "$BONDING_FAIL_OVER_MAC" == "" ]]; then
BONDING_FAIL_OVER_MAC="0"
fi
# Insert the bonding driver into the kernel
insmod $KMOD_PATH/kernel/drivers/net/bonding/bonding.ko mode=active-backup miimon="$BONDING_LINK_MONITORING_FREQ_MS" downdelay="$BONDING_DOWN_DELAY_MS" updelay="$BONDING_UP_DELAY_MS" primary="$BONDING_PRIMARY_INTERFACE" fail_over_mac="$BONDING_FAIL_OVER_MAC"
fi
}
eth_wlan_up() {
##Run DHCP client, and bind mount our fake wpa_cli.sh to fool iCamera
ifconfig wlan0 up
pkill udhcpc
udhcpc -i wlan0 -x hostname:$CUSTOM_HOSTNAME -p /var/run/udhcpc.pid -b
# If running with Interface Bonding enabled, kill any existing
# wpa_supplicant that might be running and spawn our own instead
if [[ "$BONDING_ENABLED" == "true" ]] && ([[ "$ENABLE_USB_ETH" == "true" ]] || [[ "$ENABLE_USB_DIRECT" == "true" ]]); then
/opt/wz_mini/bin/busybox killall wpa_supplicant
wpa_supplicant -D nl80211 -i wlanold -c /tmp/wpa_supplicant.conf -B -s
fi
if [ -f /opt/wz_mini/tmp/.T20 ]; then
mount -o bind /opt/wz_mini/bin/wpa_cli.sh /system/bin/wpa_cli
else
mount -o bind /opt/wz_mini/bin/wpa_cli.sh /bin/wpa_cli
fi
break
}
swap_enable() {
if [ -e /opt/wz_mini/swap ]; then
echo "Swap file exists"
if cat /proc/swaps | grep "mini" ; then
echo "Swap is already enabled"
else
echo "Enable swap"
swapon /opt/wz_mini/swap
fi
else
echo "Swap file missing!"
fi
}
dmesg_log() {
DMESG_LOG=/opt/wz_mini/log/dmesg
if [[ -e $DMESG_LOG.log || -L $DMESG_LOG.log ]] ; then
i=0
while [[ -e $DMESG_LOG.log.$i || -L $DMESG_LOG.log.$i ]] ; do
let i++
done
mv $DMESG_LOG.log $DMESG_LOG.log.$i
DMESG_LOG=$DMESG_LOG
fi
touch -- "$DMESG_LOG".log
dmesg > $DMESG_LOG.log 2>&1
}
trim_logs() {
echo "Deleting logs older than 5 boots..."
find /opt/wz_mini/log -name '*log*' | while read file; do
[ "${file#/opt/wz_mini/log/*log.}" -gt 5 ] && rm -v "$file"
done
}
first_run_check
wpa_check
#Set module dir depending on platform
if [ -f /opt/wz_mini/tmp/.T20 ]; then
KMOD_PATH="/opt/wz_mini/lib/modules/3.10.14"
else
KMOD_PATH="/opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__"
fi
swap_enable
if [[ "$ENABLE_IPV6" == "true" ]]; then
echo "ipv6 enabled"
else
echo "ipv6 disabled"
sysctl -w net.ipv6.conf.all.disable_ipv6=1
fi
if [[ "$ENABLE_NFSv4" == "true" ]]; then
insmod $KMOD_PATH/kernel/lib/oid_registry.ko
insmod $KMOD_PATH/kernel/net/dns_resolver/dns_resolver.ko
insmod $KMOD_PATH/kernel/fs/nfs/nfsv4.ko
insmod $KMOD_PATH/kernel/net/sunrpc/auth_gss/auth_rpcgss.ko
echo nfsv4 enabled
else
echo nfsv4 disabled
fi
if [[ "$ENABLE_IPTABLES" == "true" ]]; then
insmod $KMOD_PATH/kernel/net/netfilter/x_tables.ko
insmod $KMOD_PATH/kernel/net/ipv4/netfilter/ip_tables.ko
insmod $KMOD_PATH/kernel/net/ipv4/netfilter/ipt_REJECT.ko
insmod $KMOD_PATH/kernel/net/ipv4/netfilter/iptable_filter.ko
insmod $KMOD_PATH/kernel/net/ipv4/netfilter/iptable_mangle.ko
echo "iptables ipv4 enabled"
if [[ "$ENABLE_IPV6" == "true" ]]; then
insmod $KMOD_PATH/kernel/net/ipv6/netfilter/ip6_tables.ko
insmod $KMOD_PATH/kernel/net/ipv6/netfilter/ip6t_REJECT.ko
insmod $KMOD_PATH/kernel/net/ipv6/netfilter/ip6table_filter.ko
insmod $KMOD_PATH/kernel/net/ipv6/netfilter/ip6table_mangle.ko
echo "iptables ipv6 enabled"
fi
else
echo "iptables disabled"
fi
if [[ "$ENABLE_USB_ETH" == "true" ]]; then
insmod $KMOD_PATH/kernel/drivers/net/usb/usbnet.ko
# Auto-Detect an Ethernet Driver and load it
if [[ "$ENABLE_USB_ETH_MODULE_AUTODETECT" == "true" ]]; then
for DEVICE in `lsusb | awk '{print $6}'| tr '[:upper:]' '[:lower:]'`; do
case $DEVICE in
'077b:2226' | '0846:1040' | '2001:1a00' | '0b95:1720' | '07b8:420a' |\
'08dd:90ff' | '0557:2009' | '0411:003d' | '0411:006e' | '6189:182d' |\
'0df6:0056' | '07aa:0017' | '1189:0893' | '1631:6200' | '04f1:3008' |\
'17ef:7203' | '0b95:772b' | '0b95:7720' | '0b95:1780' | '0789:0160' |\
'13b1:0018' | '1557:7720' | '07d1:3c05' | '2001:3c05' | '2001:1a02' |\
'1737:0039' | '04bb:0930' | '050d:5055' | '05ac:1402' | '0b95:772a' |\
'14ea:ab11' | '0db0:a877' | '0b95:7e2b' | '0b95:172a' | '066b:20f9')
echo "Loading ASIX Ethernet driver..."
modprobe asix
;;
'0b95:1790' | '0b95:178a' | '0df6:0072')
echo "Loading AX88179 Gigabit Ethernet driver..."
modprobe ax88179_178a
;;
'1004:61aa' | '046d:c11f' | '1410:b001' | '1410:9010' | '413c:8195' |\
'413c:8196' | '413c:819b' | '16d5:650a' | '12d1:14ac')
echo "Loading USB CDC Ethernet driver..."
modprobe cdc_ether
;;
'0bda:8152')
echo "Loading Realtek RTL8152 driver..."
modprobe r8152
;;
esac
done
fi
# Manually load any other Ethernet Drivers if asked for
if [[ "$ENABLE_USB_ETH_MODULE_MANUAL" != "" ]]; then
for i in $(echo "$ENABLE_USB_ETH_MODULE_MANUAL" | tr "," "\n")
do
insmod $KMOD_PATH/kernel/drivers/net/usb/$i.ko
done
fi
bonding_setup eth0 wlan0
swap_enable
netloop eth0
else
echo "USB Ethernet disabled"
fi
if [[ "$ENABLE_USB_DIRECT" == "true" ]]; then
HOST_MACADDR=$(echo "$CUSTOM_HOSTNAME"|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo connect > /sys/devices/platform/jz-dwc2/dwc2/udc/dwc2/soft_connect
sleep 1
devmem 0x10000040 32 0x0b800096
sleep 1
devmem 0x13500000 32 0x001100cc
else
#Set dwc2 ID_PIN driver memory
devmem 0x13500000 32 0x001100cc
devmem 0x10000040 32 0x0b000096
#wipe the bits to set the ID_PIN, only for the V3.
devmem 0x10000040 32 0x0b000FFF
fi
insmod $KMOD_PATH/kernel/drivers/usb/gadget/libcomposite.ko
if [ -f /opt/wz_mini/tmp/.T31 ]; then
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/usb/gadget/u_ether.ko
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/usb/gadget/usb_f_ncm.ko
fi
insmod $KMOD_PATH/kernel/drivers/usb/gadget/g_ncm.ko iManufacturer=wz_mini_ncm host_addr="$HOST_MACADDR" dev_addr="$USB_DIRECT_MAC_ADDR"
sleep 1
bonding_setup usb0 wlan0
swap_enable
netloop usb0
else
echo "USB Direct disabled"
fi
if [[ "$ENABLE_USB_RNDIS" == "true" ]]; then
if [[ "$ENABLE_USB_ETH" == "true" ]] || [[ "$ENABLE_USB_DIRECT" == "true" ]]; then
echo "RNDIS is not compatible with ENABLE_USB_ETH or ENABLE_USB_DIRECT. Please enable only ENABLE_USB_RNDIS"
else
insmod $KMOD_PATH/kernel/drivers/net/usb/usbnet.ko
insmod $KMOD_PATH/kernel/drivers/net/usb/cdc_ether.ko
insmod $KMOD_PATH/kernel/drivers/net/usb/rndis_host.ko
sleep 1
swap_enable
netloop usb0
fi
else
echo "usb rndis disabled"
fi
if [[ "$ENABLE_WIREGUARD" == "true" ]]; then
insmod $KMOD_PATH/kernel/net/ipv4/tunnel4.ko
insmod $KMOD_PATH/kernel/net/ipv4/ip_tunnel.ko
insmod $KMOD_PATH/kernel/net/wireguard/wireguard.ko
if [[ "$WIREGUARD_IPV4" != "" ]]; then
if [ -d /opt/wz_mini/etc/wireguard ]; then
echo "wireguard dir exists"
else
mkdir -p /opt/wz_mini/etc/wireguard
fi
if [ ! -f /opt/wz_mini/etc/wireguard/privatekey ]; then
(umask 277 && /opt/wz_mini/bin/wg genkey | /opt/wz_mini/bin/busybox tee /opt/wz_mini/etc/wireguard/privatekey | /opt/wz_mini/bin/wg pubkey > /opt/wz_mini/etc/wireguard/publickey)
fi
/opt/wz_mini/bin/busybox ip link add dev wg0 type wireguard
/opt/wz_mini/bin/busybox ip address add dev wg0 "$WIREGUARD_IPV4"
/opt/wz_mini/bin/wg set wg0 private-key /opt/wz_mini/etc/wireguard/privatekey
/opt/wz_mini/bin/busybox ip link set wg0 up
fi
if [[ "$WIREGUARD_PEER_PUBLIC_KEY" != "" ]] && [[ "$WIREGUARD_PEER_ALLOWED_IPS" != "" ]] && [[ "$WIREGUARD_PEER_ENDPOINT" != "" ]] && [[ "$WIREGUARD_PEER_KEEP_ALIVE" != "" ]]; then
/opt/wz_mini/bin/wg set wg0 peer "$WIREGUARD_PEER_PUBLIC_KEY" allowed-ips "$WIREGUARD_PEER_ALLOWED_IPS" endpoint "$WIREGUARD_PEER_ENDPOINT" persistent-keepalive "$WIREGUARD_PEER_KEEP_ALIVE"
/opt/wz_mini/bin/busybox ip route add "$WIREGUARD_PEER_ALLOWED_IPS" dev wg0
fi
else
echo "wireguard disabled"
fi
if [[ "$ENABLE_CIFS" == "true" ]]; then
insmod $KMOD_PATH/kernel/fs/cifs/cifs.ko
else
echo "cifs disabled"
fi
if [[ "$ENABLE_USB_STORAGE" == "true" ]]; then
insmod $KMOD_PATH/kernel/drivers/scsi/scsi_mod.ko
insmod $KMOD_PATH/kernel/drivers/scsi/sd_mod.ko
insmod $KMOD_PATH/kernel/drivers/usb/storage/usb-storage.ko
else
echo "usb_storage disabled"
fi
if [[ "$ENABLE_EXT4" == "true" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
insmod $KMOD_PATH/kernel/lib/crc16.ko
fi
insmod $KMOD_PATH/kernel/fs/jbd2/jbd2.ko
insmod $KMOD_PATH/kernel/fs/mbcache.ko
insmod $KMOD_PATH/kernel/fs/ext4/ext4.ko
else
echo "ext4 disabled"
fi
if [[ "$DISABLE_FW_UPGRADE" == "true" ]]; then
mkdir /tmp/Upgrade
mount -t tmpfs -o size=1,nr_inodes=1 none /tmp/Upgrade
#Setting this host causes iCamera to segfault, lets ignore it for now
#echo -e "127.0.0.1 localhost \n127.0.0.1 wyze-upgrade-service.wyzecam.com" > /opt/wz_mini/tmp/.storage/hosts
#mount --bind /opt/wz_mini/tmp/.storage/hosts /etc/hosts
/opt/wz_mini/bin/busybox inotifyd /opt/wz_mini/usr/bin/watch_up.sh /tmp:n > /dev/null 2>&1 &
else
mkdir /tmp/Upgrade
/opt/wz_mini/bin/busybox inotifyd /opt/wz_mini/usr/bin/watch_up.sh /tmp:n > /dev/null 2>&1 &
fi
if [[ "$REMOTE_SPOTLIGHT" == "true" ]]; then
/opt/wz_mini/bin/socat pty,link=/dev/ttyUSB0,raw tcp:"$REMOTE_SPOTLIGHT_HOST":9000 &
echo "remote accessory enabled"
else
echo "remote accessory disabled"
fi
if [[ "$ENABLE_MP4_WRITE" == "true" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "mp4_write is not supported on T20"
else
/opt/wz_mini/bin/cmd mp4write on
echo "mp4_write enabled"
fi
else
echo "mp4 write disabled"
fi
if [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
HI_VIDEO_DEV="/dev/video6"
else
HI_VIDEO_DEV="/dev/video1"
fi
swap_enable
if [[ "$RTSP_PASSWORD" = "" ]]; then
RTSP_PASSWORD=$(cat /opt/wz_mini/tmp/wlan0_mac)
fi
/opt/wz_mini/bin/cmd video 0 on
if [[ "$RTSP_HI_RES_ENABLE_AUDIO" == "true" ]]; then
/opt/wz_mini/bin/cmd audio 0 on
AUDIO_CH="-C 1"
AUDIO_FMT="-a S16_LE"
DEVICE1="$HI_VIDEO_DEV,hw:0,0"
else
DEVICE1="$HI_VIDEO_DEV"
echo "rtsp audio disabled"
fi
else
echo "rtsp disabled"
fi
if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
LOW_VIDEO_DEV="/dev/video7"
else
LOW_VIDEO_DEV="/dev/video2"
fi
swap_enable
/opt/wz_mini/bin/cmd video 1 on
if [[ "$RTSP_PASSWORD" = "" ]]; then
RTSP_PASSWORD=$(cat /opt/wz_mini/tmp/wlan0_mac)
fi
if [[ "$RTSP_LOW_RES_ENABLE_AUDIO" == "true" ]]; then
/opt/wz_mini/bin/cmd audio 1 on
AUDIO_CH="-C 1"
AUDIO_FMT="-a S16_LE"
DEVICE2="$LOW_VIDEO_DEV,hw:2,0"
else
DEVICE2="$LOW_VIDEO_DEV"
echo "rtsp audio disabled"
fi
else
echo "rtsp disabled"
fi
if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]] || [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
echo "delay RTSP for iCamera"
#This delay is required. Sometimes, if you start the rtsp server too soon, live view will break on the app.
sleep 5
LD_LIBRARY_PATH=/opt/wz_mini/lib /opt/wz_mini/bin/v4l2rtspserver $AUDIO_CH $AUDIO_FMT -F0 -U "$RTSP_LOGIN":"$RTSP_PASSWORD" -P "$RTSP_PORT" $DEVICE1 $DEVICE2 &
sleep 1
echo "Set imp variables via helper"
/opt/wz_mini/usr/bin/imp_helper.sh > /dev/null 2>&1 &
fi
if ([[ "$RTSP_LOW_RES_ENABLED" == "true" ]] || [[ "$RTSP_HI_RES_ENABLED" == "true" ]]) && [[ "$RTMP_STREAM_ENABLED" == "true" ]] && ([[ "$RTSP_LOW_RES_ENABLE_AUDIO" == "true" ]] || [[ "$RTSP_HI_RES_ENABLE_AUDIO" == "true" ]]); then
if [[ "$RTMP_STREAM_DISABLE_AUDIO" == "true" ]]; then
RTMP_AUDIO="no_audio"
fi
echo "delay RTMP server"
#Follow the delay from the RTSP server
sleep 5
/opt/wz_mini/bin/rtmp-stream.sh "$RMTP_STREAM_SERVICE" "$RTMP_AUDIO" &
fi
if [[ "$NIGHT_DROP_DISABLE" == "true" ]]; then
touch /opt/wz_mini/tmp/.nd
fi
if [[ "$ENABLE_LOCAL_DNS" == "true" ]]; then
dnsmasq -C /opt/wz_mini/etc/dnsmasq.conf
rm -f /tmp/resolv.conf
cp /opt/wz_mini/etc/resolv.conf /tmp/resolv.conf
fi
if [[ "$WEB_SERVER_ENABLED" == "true" ]]; then
httpd -p 80 -h /opt/wz_mini/www
fi
hostname_set
touch /opt/wz_mini/tmp/.wz_user_firstrun
pkill -f dumpload #Kill dumpload so it won't waste cpu or ram gathering cores and uploading them when something crashes
sysctl -w kernel.core_pattern='|/bin/false'
dmesg_log
trim_logs
sync;echo 3 > /proc/sys/vm/drop_caches
if [ -f "$CUSTOM_SCRIPT_PATH" ]; then
echo "starting custom script"
$CUSTOM_SCRIPT_PATH &
else
echo "no custom script configured in wz_mini.conf"
fi
echo "searching for custom scripts in /opt/wz_mini/etc/rc.local.d"
if [ -d "${1:-/opt/wz_mini/etc/rc.local.d}" ] ; then
for filename in $(find /opt/wz_mini/etc/rc.local.d/ -name "*.sh" | /opt/wz_mini/bin/busybox sort) ; do
if [ -f "${filename}" ] && [ -x "${filename}" ]; then
echo "running ${filename}"
"${filename}" &
fi
done
fi
echo "finished executing custom scripts from /opt/wz_mini/etc/rc.local.d"
echo "wz_user.sh done" > /dev/kmsg

View File

@@ -0,0 +1,25 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: WLAN HW Init check
# Description: Make sure the WLAN hardware is functional and initialized before proceeding.
### END INIT INFO
. /opt/wz_mini/etc/rc.common
case "$1" in
start)
echo "#####$(basename "$0")#####"
#Wait for wlan hardware to be intitialized in app_init.sh, this must be blocking.
#Lets come up with a solution for some cameras with failed wlan hw, someone on reddit mentioned it"
echo "Waiting for wlan hw init"
wait_for_wlan $(basename "$0")
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,25 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Enable/Disable IPv6
# Description: Enable/Disable IPv6 based on the user configuration
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
if ! [[ "$ENABLE_IPV6" == "true" ]]; then
sysctl -w net.ipv6.conf.all.disable_ipv6=1
echo "ipv6 disabled"
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,50 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Wireguard support
# Description: Enable Wireguard support
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
. /opt/wz_mini/etc/rc.common
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [[ "$ENABLE_WIREGUARD" == "true" ]]; then
if [[ "$WIREGUARD_IPV4" != "" ]]; then
if [ -d /opt/wz_mini/etc/wireguard ]; then
echo "Wireguard dir exists"
else
mkdir -p /opt/wz_mini/etc/wireguard
fi
if [ ! -f /opt/wz_mini/etc/wireguard/privatekey ]; then
(umask 277 && /opt/wz_mini/bin/wg genkey | /opt/wz_mini/bin/busybox tee /opt/wz_mini/etc/wireguard/privatekey | /opt/wz_mini/bin/wg pubkey > /opt/wz_mini/etc/wireguard/publickey)
fi
/opt/wz_mini/bin/busybox ip link add dev wg0 type wireguard
/opt/wz_mini/bin/busybox ip address add dev wg0 "$WIREGUARD_IPV4"
/opt/wz_mini/bin/wg set wg0 private-key /opt/wz_mini/etc/wireguard/privatekey
/opt/wz_mini/bin/busybox ip link set wg0 up
fi
if [[ "$WIREGUARD_PEER_PUBLIC_KEY" != "" ]] && [[ "$WIREGUARD_PEER_ALLOWED_IPS" != "" ]] && [[ "$WIREGUARD_PEER_ENDPOINT" != "" ]] && [[ "$WIREGUARD_PEER_KEEP_ALIVE" != "" ]]; then
/opt/wz_mini/bin/wg set wg0 peer "$WIREGUARD_PEER_PUBLIC_KEY" allowed-ips "$WIREGUARD_PEER_ALLOWED_IPS" endpoint "$WIREGUARD_PEER_ENDPOINT" persistent-keepalive "$WIREGUARD_PEER_KEEP_ALIVE"
/opt/wz_mini/bin/busybox ip route add "$WIREGUARD_PEER_ALLOWED_IPS" dev wg0
fi
else
echo "Wireguard disabled"
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,25 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Set system hostname
# Description: Set system hostname
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
echo "Set hostname to $CUSTOM_HOSTNAME"
hostname $CUSTOM_HOSTNAME
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,34 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [[ "$ENABLE_LOCAL_DNS" == "true" ]]; then
dnsmasq -C /opt/wz_mini/etc/dnsmasq.conf
rm -f /tmp/resolv.conf
cp /opt/wz_mini/etc/resolv.conf /tmp/resolv.conf
echo "dnsmasq enabled"
fi
;;
stop)
pkill dnsmasq
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac

View File

@@ -0,0 +1,32 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Basic Web Server
# Description: If enabled, start the httpd web server
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [[ "$WEB_SERVER_ENABLED" == "true" ]]; then
httpd -p 80 -h /opt/wz_mini/www
echo "httpd enabled"
fi
;;
stop)
pkill dnsmasq
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac

View File

@@ -0,0 +1,36 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Remote USB Accessory Support
# Description: If enabled, support remote usb accessories using socat
### END INIT INFO
. /opt/wz_mini/etc/rc.common
. /opt/wz_mini/wz_mini.conf
remote() {
wait_for_wlan_ip $(basename "$0")
echo "#####$(basename "$0")#####"
if [[ "$REMOTE_SPOTLIGHT" == "true" ]]; then
/opt/wz_mini/bin/socat pty,link=/dev/ttyUSB0,raw tcp:"$REMOTE_SPOTLIGHT_HOST":9000 &
echo "Remote accessory support enabled"
else
echo "Remote accessory support disabled"
fi
}
case "$1" in
start)
remote &
;;
stop)
pkill socat
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,29 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Store WLAN HW Address
# Description: Store the WLAN HW Address for use by other scripts
### END INIT INFO
. /opt/wz_mini/etc/rc.common
storemac() {
wait_for_wlan_wpa $(basename "$0")
echo "#####$(basename "$0")#####"
cat /sys/class/net/wlan0/address | tr '[:lower:]' '[:upper:]' > /opt/wz_mini/tmp/wlan0_mac
echo "store original mac"
}
case "$1" in
start)
storemac
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,129 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Start RTSP Server
# Description: Provide RTSP Streaming Video over IP
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
RTSP=/opt/wz_mini/log/v4l2rtspserver
if [[ -e $RTSP.log || -L $RTSP.log ]] ; then
i=0
while [[ -e $RTSP.log.$i || -L $RTSP.log.$i ]] ; do
let i++
done
mv $RTSP.log $RTSP.log.$i
RTSP=$RTSP
fi
touch -- "$RTSP".log
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
HI_VIDEO_DEV="/dev/video6"
else
HI_VIDEO_DEV="/dev/video1"
fi
if [[ "$RTSP_PASSWORD" = "" ]]; then
RTSP_PASSWORD=$(cat /opt/wz_mini/tmp/wlan0_mac)
fi
echo "Enable video ch 0"
/opt/wz_mini/bin/cmd video 0 on > /dev/null
if [[ "$RTSP_HI_RES_ENABLE_AUDIO" == "true" ]]; then
echo "Enable audio ch 0"
/opt/wz_mini/bin/cmd audio 0 on > /dev/null
AUDIO_CH="-C 1"
AUDIO_FMT="-a S16_LE"
DEVICE1="$HI_VIDEO_DEV,hw:0,0"
else
DEVICE1="$HI_VIDEO_DEV"
echo "rtsp audio disabled"
fi
else
echo "rtsp disabled"
fi
if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
LOW_VIDEO_DEV="/dev/video7"
else
LOW_VIDEO_DEV="/dev/video2"
fi
echo "Enable video ch 1"
/opt/wz_mini/bin/cmd video 1 on > /dev/null
if [[ "$RTSP_PASSWORD" = "" ]]; then
RTSP_PASSWORD=$(cat /opt/wz_mini/tmp/wlan0_mac)
fi
if [[ "$RTSP_LOW_RES_ENABLE_AUDIO" == "true" ]]; then
echo "Enable video ch 1"
/opt/wz_mini/bin/cmd audio 1 on > /dev/null
AUDIO_CH="-C 1"
AUDIO_FMT="-a S16_LE"
DEVICE2="$LOW_VIDEO_DEV,hw:2,0"
else
DEVICE2="$LOW_VIDEO_DEV"
echo "rtsp audio disabled"
fi
else
echo "rtsp disabled"
fi
if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]] || [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
echo "delay RTSP for iCamera"
#This delay is required. Sometimes, if you start the rtsp server too soon, live view will break on the app.
sleep 5
if [[ "$RTSP_AUTH_DISABLE" == "true" ]]; then
echo "Starting RTSP server"
LD_LIBRARY_PATH=/opt/wz_mini/lib LD_PRELOAD=/system/lib/libsetunbuf.so /opt/wz_mini/bin/v4l2rtspserver $AUDIO_CH $AUDIO_FMT -F0 -P "$RTSP_PORT" $DEVICE1 $DEVICE2 > $RTSP.log 2>&1 &
else
echo "Starting RTSP server"
LD_LIBRARY_PATH=/opt/wz_mini/lib LD_PRELOAD=/system/lib/libsetunbuf.so /opt/wz_mini/bin/v4l2rtspserver $AUDIO_CH $AUDIO_FMT -F0 -U "$RTSP_LOGIN":"$RTSP_PASSWORD" -P "$RTSP_PORT" $DEVICE1 $DEVICE2 > $RTSP.log 2>&1 &
fi
sleep 1
echo "Set imp variables via helper"
/opt/wz_mini/usr/bin/imp_helper.sh > /dev/null 2>&1 &
fi
sync;echo 3 > /proc/sys/vm/drop_caches
;;
stop)
pkill v4l2rtspserver
cmd video 0 off
cmd audio 0 off
cmd video 1 off
cmd audio 1 off
pkill imp_helper.sh
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac

View File

@@ -0,0 +1,36 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Start rtsp service
# Description: Enable RTMP Streaming Video
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
if ([[ "$RTSP_LOW_RES_ENABLED" == "true" ]] || [[ "$RTSP_HI_RES_ENABLED" == "true" ]]) && [[ "$RTMP_STREAM_ENABLED" == "true" ]] && ([[ "$RTSP_LOW_RES_ENABLE_AUDIO" == "true" ]] || [[ "$RTSP_HI_RES_ENABLE_AUDIO" == "true" ]]); then
if [[ "$RTMP_STREAM_DISABLE_AUDIO" == "true" ]]; then
RTMP_AUDIO="no_audio"
fi
echo "delay RTMP server"
#Follow the delay from the RTSP server
sleep 5
/opt/wz_mini/bin/rtmp-stream.sh "$RMTP_STREAM_SERVICE" "$RTMP_AUDIO" &
fi
;;
stop)
pkill dnsmasq
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac

81
SD_ROOT/wz_mini/etc/rc.common Executable file
View File

@@ -0,0 +1,81 @@
#!/bin/sh
source /opt/wz_mini/wz_mini.conf
#Set module dir depending on platform
if [ -f /opt/wz_mini/tmp/.T20 ]; then
KMOD_PATH="/opt/wz_mini/lib/modules/3.10.14"
else
KMOD_PATH="/opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__"
fi
if [[ "$ENABLE_USB_ETH" == "true" ]]; then
ALT_IFACE=eth0
elif [[ "$ENABLE_USB_DIRECT" == "true" ]] || [[ "$ENABLE_USB_RNDIS" == "true" ]]; then
ALT_IFACE=usb0
fi
#Set the correct GPIO for the audio driver (T31 only)
if [ -f /opt/wz_mini/tmp/.HL_PAN2 ]; then
GPIO=7
elif [ -f /opt/wz_mini/tmp/.WYZE_CAKP2JFUS ]; then
GPIO=63
fi
wait_for_wlan() {
while true; do
if ifconfig wlan0 | grep "HWaddr" > /dev/null; then
break
fi
echo "$1: Network HW not ready yet, try again in 5 seconds"
sleep 5
done
}
wait_for_wlan_wpa() {
while true; do
if [ -e /tmp/wpa_supplicant.conf ]; then
break
fi
echo "$1: wpa_supplicant not initialized yet, try again in 5 seconds"
sleep 5
done
}
wait_for_wlan_ip() {
while true; do
if ifconfig wlan0 | grep "inet addr" > /dev/null; then
break
fi
echo "$1: IP Address not acquired yet, try again in 5 seconds"
sleep 5
done
}
wait_for_icamera() {
while ! pgrep -f "/system/bin/iCamera" > /dev/null; do
sleep 5
done
}
gateway_supervisor() {
count=0
while [ true ]; do
if ! ping -c1 -W 2 `/opt/wz_mini/bin/busybox ip route | awk '/default/ { print $3 }'` >& /dev/null; then
echo "$1: Unable to reach default route via USB Direct Link, ifdown usb0..."
count=0
ifconfig usb0 down
sleep 10
else
if [[ $count -ne 1 ]]
then
#echo "Connected."
count=1
sleep 5
fi
sleep 1
fi
done
}

View File

@@ -0,0 +1,67 @@
#!/bin/sh
. /opt/wz_mini/etc/rc.common
. /opt/wz_mini/wz_mini.conf
if [ -e /tmp/dbgflag ]; then
echo "debug enabled, network.d disabled."
exit 0
fi
wait_for_wlan $(basename "$0")
for i in /opt/wz_mini/etc/network.d/S??* ;do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done
wait_for_wlan_ip $(basename "$0")
for i in /opt/wz_mini/etc/rc.local.d/* ;do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done
if [ -f "$CUSTOM_SCRIPT_PATH" ]; then
echo "Starting custom script"
$CUSTOM_SCRIPT_PATH &
else
echo "No custom script configured in wz_mini.conf"
fi
/opt/wz_mini/etc/rc.d/K15logging
echo "wz_mini done" > /dev/kmsg

View File

@@ -2,12 +2,12 @@
LOG_NAME=/opt/wz_mini/log/wz_cam
if [[ -e $LOG_NAME.log || -L $LOG_NAME.log ]] ; then
i=0
while [[ -e $LOG_NAME.log.$i || -L $LOG_NAME.log.$i ]] ; do
let i++
done
mv $LOG_NAME.log $LOG_NAME.log.$i
LOG_NAME=$LOG_NAME
i=0
while [[ -e $LOG_NAME.log.$i || -L $LOG_NAME.log.$i ]] ; do
let i++
done
mv $LOG_NAME.log $LOG_NAME.log.$i
LOG_NAME=$LOG_NAME
fi
touch -- "$LOG_NAME".log
exec 1> $LOG_NAME.log 2>&1
@@ -16,21 +16,19 @@ export WZMINI_CFG=/opt/wz_mini/wz_mini.conf
[ -f $WZMINI_CFG ] && source $WZMINI_CFG
set -x
echo "welcome to wz_cam.sh"
echo "PID $$"
if [ -f /opt/wz_mini/tmp/.T31 ]; then
if [ -f /opt/wz_mini/tmp/.T31 ]; then
cp /opt/wz_mini/etc/uvc.config /opt/wz_mini/usr/bin/uvc.config
if [[ "WEB_CAM_FPS_RATE" != "" ]]; then
sed -i "s/fps_num :30/fps_num :$WEB_CAM_FPS_RATE/" "/opt/wz_mini/usr/bin/uvc.config"
sed -i "s/fps_num :30/fps_num :$WEB_CAM_FPS_RATE/" "/opt/wz_mini/usr/bin/uvc.config"
fi
if [[ "WEB_CAM_BIT_RATE" != "" ]]; then
sed -i "s/bitrate :8000/bitrate :$WEB_CAM_BIT_RATE/" "/opt/wz_mini/usr/bin/uvc.config"
sed -i "s/bitrate :8000/bitrate :$WEB_CAM_BIT_RATE/" "/opt/wz_mini/usr/bin/uvc.config"
fi
echo 1 > /proc/sys/vm/overcommit_memory
@@ -49,10 +47,10 @@ echo "PID $$"
sleep 1
#Set dwc2 ID_PIN driver memory
echo "Set dwc2 ID_PIN driver memory"
devmem 0x13500000 32 0x001100cc
devmem 0x10000040 32 0x0b000096
#wipe the bits to set the ID_PIN
echo "Wipe dwc2 memory bits to set the ID_PIN"
devmem 0x10000040 32 0x0b000FFF
sleep 1
@@ -71,11 +69,11 @@ else
cp /opt/wz_mini/etc/uvc_v2.config /opt/wz_mini/usr/bin/uvc.config
if [[ "WEB_CAM_FPS_RATE" != "" ]]; then
sed -i "s/fps_num :30/fps_num :$WEB_CAM_FPS_RATE/" "/opt/wz_mini/usr/bin/uvc.config"
sed -i "s/fps_num :30/fps_num :$WEB_CAM_FPS_RATE/" "/opt/wz_mini/usr/bin/uvc.config"
fi
if [[ "WEB_CAM_BIT_RATE" != "" ]]; then
sed -i "s/bitrate :8000/bitrate :$WEB_CAM_BIT_RATE/" "/opt/wz_mini/usr/bin/uvc.config"
sed -i "s/bitrate :8000/bitrate :$WEB_CAM_BIT_RATE/" "/opt/wz_mini/usr/bin/uvc.config"
fi
mount --bind /opt/wz_mini/usr/bin /system/bin

View File

@@ -0,0 +1,27 @@
#!/bin/sh
if [ -e /tmp/dbgflag ]; then
echo "debug enabled, rc.d disabled."
exit 0
fi
for i in /opt/wz_mini/etc/rc.d/S??* ;do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done

View File

@@ -0,0 +1,23 @@
#!/bin/sh
source /opt/wz_mini/wz_mini.conf
echo "Store dmesg logs"
DMESG_LOG=/opt/wz_mini/log/dmesg
if [[ -e $DMESG_LOG.log || -L $DMESG_LOG.log ]] ; then
i=0
while [[ -e $DMESG_LOG.log.$i || -L $DMESG_LOG.log.$i ]] ; do
let i++
done
mv $DMESG_LOG.log $DMESG_LOG.log.$i
DMESG_LOG=$DMESG_LOG
fi
touch -- "$DMESG_LOG".log
dmesg > $DMESG_LOG.log 2>&1
echo "Deleting logs older than 5 boots..."
find /opt/wz_mini/log -name '*log*' | while read file; do
[ "${file#/opt/wz_mini/log/*log.}" -gt 5 ] && rm -v "$file"
done

View File

@@ -0,0 +1,45 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Extract Swap archive
# Description: Enable required swap file for system. System will crash without it.
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
. /opt/wz_mini/etc/rc.common
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [ -e /opt/wz_mini/swap.gz ]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
LD_LIBRARY_PATH='/opt/wz_mini/lib' /opt/wz_mini/bin/audioplay_t20 /opt/wz_mini/usr/share/audio/swap_v2.wav $AUDIO_PROMPT_VOLUME
else
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/extra/audio.ko spk_gpio=$GPIO alc_mode=0 mic_gain=0
/opt/wz_mini/bin/audioplay_t31 /opt/wz_mini/usr/share/audio/swap.wav $AUDIO_PROMPT_VOLUME
rmmod audio
fi
echo "Swap archive present, extracting"
gzip -d /opt/wz_mini/swap.gz
mkswap /opt/wz_mini/swap
sync;echo 3 > /proc/sys/vm/drop_caches
else
echo "Swap archive missing, not extracting"
fi
if [[ "$ENABLE_SWAP" == "true" ]] && [[ -e /opt/wz_mini/swap ]]; then
echo "Swap file found, enable"
/opt/wz_mini/bin/busybox swapon /opt/wz_mini/swap
else
echo "Swap file missing"
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,71 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: USB Ethernet Support
# Description: Enable USB Ethernet adapter support and kernel module
### END INIT INFO
. /opt/wz_mini/etc/rc.common
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [[ "$ENABLE_USB_ETH" == "true" ]]; then
insmod $KMOD_PATH/kernel/drivers/net/usb/usbnet.ko
echo "Auto-Detect an Ethernet Driver and load it"
if [[ "$ENABLE_USB_ETH_MODULE_AUTODETECT" == "true" ]]; then
for DEVICE in `lsusb | awk '{print $6}'| tr '[:upper:]' '[:lower:]'`; do
case $DEVICE in
'077b:2226' | '0846:1040' | '2001:1a00' | '0b95:1720' | '07b8:420a' |\
'08dd:90ff' | '0557:2009' | '0411:003d' | '0411:006e' | '6189:182d' |\
'0df6:0056' | '07aa:0017' | '1189:0893' | '1631:6200' | '04f1:3008' |\
'17ef:7203' | '0b95:772b' | '0b95:7720' | '0b95:1780' | '0789:0160' |\
'13b1:0018' | '1557:7720' | '07d1:3c05' | '2001:3c05' | '2001:1a02' |\
'1737:0039' | '04bb:0930' | '050d:5055' | '05ac:1402' | '0b95:772a' |\
'14ea:ab11' | '0db0:a877' | '0b95:7e2b' | '0b95:172a' | '066b:20f9')
echo "Loading ASIX Ethernet driver..."
modprobe asix
;;
'0b95:1790' | '0b95:178a' | '0df6:0072')
echo "Loading AX88179 Gigabit Ethernet driver..."
modprobe ax88179_178a
;;
'1004:61aa' | '046d:c11f' | '1410:b001' | '1410:9010' | '413c:8195' |\
'413c:8196' | '413c:819b' | '16d5:650a' | '12d1:14ac')
echo "Loading USB CDC Ethernet driver..."
modprobe cdc_ether
;;
'0bda:8152')
echo "Loading Realtek RTL8152 driver..."
modprobe r8152
;;
esac
done
fi
echo "Manually load any other Ethernet Drivers if asked for"
if [[ "$ENABLE_USB_ETH_MODULE_MANUAL" != "" ]]; then
for i in $(echo "$ENABLE_USB_ETH_MODULE_MANUAL" | tr "," "\n")
do
insmod $KMOD_PATH/kernel/drivers/net/usb/$i.ko
done
fi
cat /sys/class/net/eth0/address | tr '[:lower:]' '[:upper:]' > /opt/wz_mini/tmp/eth0_mac
else
echo "USB Ethernet disabled"
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,54 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: USB Direct Networking
# Description: Enable USB Direct Networking kernel modules and support
### END INIT INFO
. /opt/wz_mini/etc/rc.common
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [[ "$ENABLE_USB_DIRECT" == "true" ]]; then
HOST_MACADDR=$(echo "$CUSTOM_HOSTNAME"|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo connect > /sys/devices/platform/jz-dwc2/dwc2/udc/dwc2/soft_connect
sleep 1
devmem 0x10000040 32 0x0b800096
sleep 1
devmem 0x13500000 32 0x001100cc
else
echo "Set dwc2 ID_PIN driver memory"
devmem 0x13500000 32 0x001100cc
devmem 0x10000040 32 0x0b000096
echo "wipe dwc2 memory bits to set the ID_PIN, only for the V3"
devmem 0x10000040 32 0x0b000FFF
fi
insmod $KMOD_PATH/kernel/drivers/usb/gadget/libcomposite.ko
if [ -f /opt/wz_mini/tmp/.T31 ]; then
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/usb/gadget/u_ether.ko
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/usb/gadget/usb_f_ncm.ko
fi
insmod $KMOD_PATH/kernel/drivers/usb/gadget/g_ncm.ko iManufacturer=wz_mini_ncm host_addr="$HOST_MACADDR" dev_addr="$USB_DIRECT_MAC_ADDR"
echo "USB Direct enabled"
else
echo "USB Direct disabled"
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,35 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: USB RNDIS Tethering Support
# Description: Enable USB RNDIS Tethering kernel modules and support
### END INIT INFO
. /opt/wz_mini/etc/rc.common
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
if [[ "$ENABLE_USB_RNDIS" == "true" ]]; then
if [[ "$ENABLE_USB_ETH" == "true" ]] || [[ "$ENABLE_USB_DIRECT" == "true" ]]; then
echo "RNDIS is not compatible with ENABLE_USB_ETH or ENABLE_USB_DIRECT. Please enable only ENABLE_USB_RNDIS"
else
insmod $KMOD_PATH/kernel/drivers/net/usb/usbnet.ko
insmod $KMOD_PATH/kernel/drivers/net/usb/cdc_ether.ko
insmod $KMOD_PATH/kernel/drivers/net/usb/rndis_host.ko
fi
echo "USB RNDIS enabled"
else
echo "USB RNDIS disabled"
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,51 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Configure alternate networking
# Description: Configure networking that is not onboard WLAN
### END INIT INFO
. /opt/wz_mini/etc/rc.common
. /opt/wz_mini/wz_mini.conf
alternate_iface() {
if [[ "$ENABLE_USB_ETH" == "true" ]] || [[ "$ENABLE_USB_DIRECT" == "true" ]] || [[ "$ENABLE_USB_RNDIS" == "true" ]]; then
wait_for_wlan_wpa $(basename "$0")
echo "#####$(basename "$0")#####"
echo "Renaming interfaces"
ifconfig $ALT_IFACE down
ifconfig wlan0 down
/opt/wz_mini/bin/busybox ip link set wlan0 name wlanold
/opt/wz_mini/bin/busybox ip addr flush dev wlanold
/opt/wz_mini/bin/busybox ip link set $ALT_IFACE name wlan0
if [ -f /opt/wz_mini/tmp/.T20 ]; then
mount -o bind /opt/wz_mini/bin/wpa_cli.sh /system/bin/wpa_cli
else
mount -o bind /opt/wz_mini/bin/wpa_cli.sh /bin/wpa_cli
fi
else
echo "No alternate iface enabled"
fi
}
case "$1" in
start)
if ! [[ "$BONDING_ENABLED" == "true" ]]; then
alternate_iface &
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,98 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Network bonding support
# Description: Enable bonding support as configured by user
### END INIT INFO
. /opt/wz_mini/etc/rc.common
. /opt/wz_mini/wz_mini.conf
bonding_setup() {
echo "#####$(basename "$0")#####"
echo "waiting until wlan0 is up with the modified HWaddr"
wait_for_wlan_wpa $(basename "$0")
##Fool iCamera by renaming the hardline interface to wlan0
## $1 Bonding Interface, $2 Primary Interface, $3 Secondary Interface
echo "renaming interfaces"
#Prevent iCamera from cycling the wlan0 interface
mount --bind /opt/wz_mini/usr/bin/restart_wlan0.sh /system/bin/restart_wlan0.sh
# Bring all interfaces down
ifconfig bond0 down
ifconfig $BONDING_PRIMARY_INTERFACE down
ifconfig $BONDING_SECONDARY_INTERFACE down
# Have to bring bonding interface up to be able to bond our slaves.
/opt/wz_mini/bin/busybox ip link set bond0 up
# Rename the real wlan0 interface if needed/used
if [[ "$BONDING_PRIMARY_INTERFACE" == "wlan0" ]]; then
/opt/wz_mini/bin/busybox ip link set $BONDING_PRIMARY_INTERFACE name wlanold
/opt/wz_mini/bin/busybox ip addr flush dev wlanold
BONDING_PRIMARY_INTERFACE="wlanold"
# Because we just changed the name of the primary interface, we need to
# tell the bonding driver about the name change as well.
echo "$BONDING_PRIMARY_INTERFACE" > /sys/devices/virtual/net/bond0/bonding/primary
fi
if [[ "$BONDING_SECONDARY_INTERFACE" == "wlan0" ]]; then
/opt/wz_mini/bin/busybox ip link set $BONDING_SECONDARY_INTERFACE name wlanold
/opt/wz_mini/bin/busybox ip addr flush dev wlanold
BONDING_SECONDARY_INTERFACE="wlanold"
fi
# Enslave the Ethernet and Original Wifi interfaces
# under the bonding interface.
/opt/wz_mini/tmp/.bin/ifenslave bond0 $BONDING_PRIMARY_INTERFACE $BONDING_SECONDARY_INTERFACE
# Have to bring bonding interface down to be rename the interface
/opt/wz_mini/bin/busybox ip link set bond0 down
# Name the bonding interface to be the "new" wlan0 interface
/opt/wz_mini/bin/busybox ip link set bond0 name wlan0
# Bring the newly renamed wlan0 (actually the bond interface) back up in the next step
#Run the DHCP client, and bind mount our fake wpa_cli.sh to fool iCamera
ifconfig wlan0 up
pkill udhcpc
udhcpc -i wlan0 -x hostname:$CUSTOM_HOSTNAME -p /var/run/udhcpc.pid -b
# If running with Interface Bonding enabled, kill any existing
# wpa_supplicant that might be running and spawn our own instead
if [[ "$BONDING_ENABLED" == "true" ]] && ([[ "$ENABLE_USB_ETH" == "true" ]] || [[ "$ENABLE_USB_DIRECT" == "true" ]]); then
echo "Restarting wpa_supplicant due to bonding"
/opt/wz_mini/bin/busybox killall wpa_supplicant
wpa_supplicant -D nl80211 -i wlanold -c /tmp/wpa_supplicant.conf -B -s
fi
if [ -f /opt/wz_mini/tmp/.T20 ]; then
mount -o bind /opt/wz_mini/bin/wpa_cli.sh /system/bin/wpa_cli
else
mount -o bind /opt/wz_mini/bin/wpa_cli.sh /bin/wpa_cli
fi
echo "Run network monitor for USB Direct"
/opt/wz_mini/usr/bin/netmon.sh &
}
case "$1" in
start)
if [[ "$BONDING_ENABLED" == "true" ]] && ([[ "$ENABLE_USB_ETH" == "true" ]] || [[ "$ENABLE_USB_DIRECT" == "true" ]]); then
bonding_setup &
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,31 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Disable coredump
# Description: Disable dumpload and disable kernel coredump support
### END INIT INFO
. /opt/wz_mini/etc/rc.common
core() {
wait_for_wlan_wpa $(basename "$0")
echo "#####$(basename "$0")#####"
echo "Killing dumpload"
/opt/wz_mini/bin/busybox pkill -f dumpload
echo "Setting kernel core pattern"
sysctl -w kernel.core_pattern='|/bin/false' > /dev/null
}
case "$1" in
start)
core &
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,34 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: FW Upgrade Intercept
# Description: Intercept FW Upgrades from vendor
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [[ "$DISABLE_FW_UPGRADE" == "true" ]]; then
mkdir /tmp/Upgrade
mount -t tmpfs -o size=1,nr_inodes=1 none /tmp/Upgrade
#Setting this host causes iCamera to segfault, lets ignore it for now
#echo -e "127.0.0.1 localhost \n127.0.0.1 wyze-upgrade-service.wyzecam.com" > /opt/wz_mini/tmp/.storage/hosts
#mount --bind /opt/wz_mini/tmp/.storage/hosts /etc/hosts
/opt/wz_mini/bin/busybox inotifyd /opt/wz_mini/usr/bin/watch_up.sh /tmp:n > /dev/null 2>&1 &
echo "Firmware updates disabled"
else
echo "Firmwware updates enabled, monitor script running"
mkdir /tmp/Upgrade
/opt/wz_mini/bin/busybox inotifyd /opt/wz_mini/usr/bin/watch_up.sh /tmp:n > /dev/null 2>&1 &
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,38 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: MP4WRITE Support
# Description: Prevent system trashing with mp4write support provided by libcallback, temporary video files are written direct to media instead of /tmp
### END INIT INFO
. /opt/wz_mini/etc/rc.common
. /opt/wz_mini/wz_mini.conf
mp4write() {
wait_for_icamera
echo "#####$(basename "$0")#####"
if [[ "$ENABLE_MP4_WRITE" == "true" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "mp4_write is not supported on T20"
else
/opt/wz_mini/bin/cmd mp4write on > /dev/null
echo "mp4_write enabled"
fi
else
echo "mp4_write disabled"
fi
}
case "$1" in
start)
mp4write &
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,25 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Enable NightDrop support
# Description: Prevent the system from dropping FPS during night mode
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [[ "$NIGHT_DROP_DISABLE" == "true" ]]; then
echo "Night Drop Disable, Enabled"
touch /opt/wz_mini/tmp/.nd
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,27 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Disable Motor
# Description: Disable Motor on specified devices
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [[ "$DISABLE_MOTOR" == "true" ]]; then
echo "Motor Disabled"
touch /opt/wz_mini/tmp/.ms
else
echo "Motor enabled"
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,39 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Set system FPS
# Description: Set system FPS if greater than factory defaults
### END INIT INFO
. /opt/wz_mini/wz_mini.conf
case "$1" in
start)
echo "#####$(basename "$0")#####"
echo "Seting system FPS if greater than default"
if [ $RTSP_HI_RES_FPS -gt 20 ]; then
if cat /configs/.user_config | grep fps; then
sed -i "s/fps.*/fps\=$RTSP_HI_RES_FPS/" /configs/.user_config
else
sed -i "/\[SETTING\].*/a fps=$RTSP_HI_RES_FPS" /configs/.user_config
fi
elif [ $RTSP_LOW_RES_FPS -gt 20 ]; then
if cat /configs/.user_config | grep fps; then
sed -i "s/fps.*/fps\=$RTSP_LOW_RES_FPS/" /configs/.user_config
else
sed -i "/\[SETTING\].*/a fps=$RTSP_LOW_RES_FPS" /configs/.user_config
fi
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,31 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Start cron daemon
# Description: Enable cron service
### END INIT INFO
. /opt/wz_mini/etc/rc.common
. /opt/wz_mini/wz_mini.conf
autostart_crond() {
wait_for_wlan_ip $(basename "$0")
echo "#####$(basename "$0")#####"
/opt/wz_mini/tmp/.bin/crond -b -c /opt/wz_mini/etc/cron/
}
case "$1" in
start)
if [[ "$ENABLE_CRONTAB" == "true" ]]; then
autostart_crond &
fi
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,43 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Store syslogs
# Description: Enable storing of syslogs to media
### END INIT INFO
. /opt/wz_mini/etc/rc.common
. /opt/wz_mini/wz_mini.conf
syslog_save() {
wait_for_icamera
echo "#####$(basename "$0")#####"
if [[ "$ENABLE_SYSLOG_SAVE" == "true" ]]; then
echo "Store syslog logs"
SYSLOG_LOG=/opt/wz_mini/log/syslog
if [[ -e $SYSLOG_LOG.log || -L $SYSLOG_LOG.log ]] ; then
i=0
while [[ -e $SYSLOG_LOG.log.$i || -L $SYSLOG_LOG.log.$i ]] ; do
let i++
done
mv $SYSLOG_LOG.log $SYSLOG_LOG.log.$i
SYSLOG_LOG=$SYSLOG_LOG
fi
touch -- "$SYSLOG_LOG".log
logread -F > $SYSLOG_LOG.log &
fi
}
case "$1" in
start)
syslog_save &
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac

View File

@@ -0,0 +1,5 @@
#!/bin/sh
#This file executes last, after rc.local.d/

View File

@@ -68,6 +68,8 @@ RTSP_LOW_RES_MAX_BITRATE=""
RTSP_LOW_RES_TARGET_BITRATE=""
RTSP_LOW_RES_ENC_PARAMETER=""
RTSP_AUTH_DISABLE="false"
#####RTMP STREAMING#####
#### REQUIRES RTSP ####
### AND RTSP AUDIO ###
@@ -93,12 +95,14 @@ DISABLE_MOTOR="false"
ENABLE_FSCK_ON_BOOT="false"
ENABLE_CAR_DRIVER="false"
ENABLE_LOCAL_DNS="false"
ENABLE_CRONTAB="false"
#####DEBUG#####
#drops you to a shell via serial, doesn't load app_init.sh
DEBUG_ENABLED="false"
DEBUG_INITRAMFS_ENABLED="false"
DEBUG_PASSWORD="false"
ENABLE_SYSLOG_SAVE="false"
####WEB####
WEB_SERVER_ENABLED="false"

View File

@@ -1 +1 @@
Wed Aug 3 07:53:41 PM PDT 2022
Sun Aug 7 06:32:44 PM PDT 2022

View File

@@ -9,146 +9,146 @@ export WZMINI_CFG=/opt/wz_mini/wz_mini.conf
[ -f $WZMINI_CFG ] && source $WZMINI_CFG
DELAY_BETWEEN=2
RE_RUN_DELAY=45
RE_RUN_DELAY=60
PARM=1
hi_res_monitor() {
if [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
if [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
if [[ "$RTSP_HI_RES_ENC_PARAMETER" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
if [[ $RTSP_HI_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]]; then
/system/bin/impdbg --enc_rc_s 0:0:4:$RTSP_HI_RES_ENC_PARAMETER
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
echo "Invalid encoder value"
fi
else
if [[ $RTSP_HI_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]]; then
/system/bin/impdbg --enc_rc_s 0:44:4:$RTSP_HI_RES_ENC_PARAMETER
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
echo "Invalid encoder value"
fi
fi
fi
if [[ "$RTSP_HI_RES_ENC_PARAMETER" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
if [[ $RTSP_HI_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]]; then
/system/bin/impdbg --enc_rc_s 0:0:4:$RTSP_HI_RES_ENC_PARAMETER
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
echo "Invalid encoder value"
fi
else
if [[ $RTSP_HI_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]]; then
/system/bin/impdbg --enc_rc_s 0:44:4:$RTSP_HI_RES_ENC_PARAMETER
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
echo "Invalid encoder value"
fi
fi
fi
if [[ "$RTSP_HI_RES_MAX_BITRATE" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
/system/bin/impdbg --enc_rc_s 0:28:4:$RTSP_HI_RES_MAX_BITRATE
if [[ "$RTSP_HI_RES_MAX_BITRATE" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
/system/bin/impdbg --enc_rc_s 0:28:4:$RTSP_HI_RES_MAX_BITRATE
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
/system/bin/impdbg --enc_rc_s 0:52:4:$RTSP_HI_RES_MAX_BITRATE
else
/system/bin/impdbg --enc_rc_s 0:52:4:$RTSP_HI_RES_MAX_BITRATE
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
fi
fi
fi
fi
if [[ "$RTSP_HI_RES_TARGET_BITRATE" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "not supported on T20"
else
/system/bin/impdbg --enc_rc_s 0:48:4:$RTSP_HI_RES_TARGET_BITRATE
if [[ "$RTSP_HI_RES_TARGET_BITRATE" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "not supported on T20"
else
/system/bin/impdbg --enc_rc_s 0:48:4:$RTSP_HI_RES_TARGET_BITRATE
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
fi
fi
fi
fi
if [[ "$RTSP_HI_RES_FPS" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
/system/bin/impdbg --enc_rc_s 0:8:4:$RTSP_HI_RES_FPS
if [[ "$RTSP_HI_RES_FPS" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
/system/bin/impdbg --enc_rc_s 0:8:4:$RTSP_HI_RES_FPS
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
/system/bin/impdbg --enc_rc_s 0:80:4:$RTSP_HI_RES_FPS
else
/system/bin/impdbg --enc_rc_s 0:80:4:$RTSP_HI_RES_FPS
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
fi
fi
fi
fi
if [ $PARM == 1 ]; then
echo "No Hi-Res imp variables enabled, check Low-Res"
if [ $PARM == 1 ]; then
echo "No Hi-Res imp variables enabled, check Low-Res"
fi
low_res_monitor
else
echo "Hi-Res RTSP not enabled"
low_res_monitor
fi
low_res_monitor
else
echo "Hi-Res RTSP not enabled"
low_res_monitor
fi
}
low_res_monitor () {
if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then
if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then
if [[ "$RTSP_LOW_RES_ENC_PARAMETER" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
if [[ $RTSP_LOW_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]]; then
/system/bin/impdbg --enc_rc_s 1:0:4:$RTSP_LOW_RES_ENC_PARAMETER
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
echo "Invalid encoder value"
fi
else
if [[ $RTSP_LOW_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]]; then
/system/bin/impdbg --enc_rc_s 1:44:4:$RTSP_LOW_RES_ENC_PARAMETER
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
echo "Invalid encoder value"
fi
fi
fi
if [[ "$RTSP_LOW_RES_ENC_PARAMETER" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
if [[ $RTSP_LOW_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]]; then
/system/bin/impdbg --enc_rc_s 1:0:4:$RTSP_LOW_RES_ENC_PARAMETER
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
echo "Invalid encoder value"
fi
else
if [[ $RTSP_LOW_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]]; then
/system/bin/impdbg --enc_rc_s 1:44:4:$RTSP_LOW_RES_ENC_PARAMETER
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
echo "Invalid encoder value"
fi
fi
fi
if [[ "$RTSP_LOW_RES_MAX_BITRATE" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
/system/bin/impdbg --enc_rc_s 1:28:4:$RTSP_LOW_RES_MAX_BITRATE
if [[ "$RTSP_LOW_RES_MAX_BITRATE" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
/system/bin/impdbg --enc_rc_s 1:28:4:$RTSP_LOW_RES_MAX_BITRATE
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
/system/bin/impdbg --enc_rc_s 1:52:4:$RTSP_LOW_RES_MAX_BITRATE
else
/system/bin/impdbg --enc_rc_s 1:52:4:$RTSP_LOW_RES_MAX_BITRATE
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
fi
fi
fi
fi
if [[ "$RTSP_LOW_RES_TARGET_BITRATE" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "not supported on T20"
else
/system/bin/impdbg --enc_rc_s 1:48:4:$RTSP_LOW_RES_TARGET_BITRATE
if [[ "$RTSP_LOW_RES_TARGET_BITRATE" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "not supported on T20"
else
/system/bin/impdbg --enc_rc_s 1:48:4:$RTSP_LOW_RES_TARGET_BITRATE
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
fi
fi
fi
fi
if [[ "$RTSP_LOW_RES_FPS" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
/system/bin/impdbg --enc_rc_s 1:8:4:$RTSP_LOW_RES_FPS
if [[ "$RTSP_LOW_RES_FPS" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
/system/bin/impdbg --enc_rc_s 1:8:4:$RTSP_LOW_RES_FPS
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
/system/bin/impdbg --enc_rc_s 1:80:4:$RTSP_LOW_RES_FPS
else
/system/bin/impdbg --enc_rc_s 1:80:4:$RTSP_LOW_RES_FPS
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
fi
fi
fi
fi
if [ $PARM == 1 ]; then
echo "No Low-Res imp variables enabled, exit"
break
fi
else
echo "Low-Res RTSP not enabled"
if [[ "$RTSP_HI_RES_ENABLED" == "true" ]] && [ $PARM -gt 1 ]; then
hi_res_monitor
if [ $PARM == 1 ]; then
echo "No Low-Res imp variables enabled, exit"
break
fi
else
break
echo "Low-Res RTSP not enabled"
if [[ "$RTSP_HI_RES_ENABLED" == "true" ]] && [ $PARM -gt 1 ]; then
hi_res_monitor
else
break
fi
fi
fi
}
while true; do

View File

@@ -0,0 +1,14 @@
#!/bin/sh
. /opt/wz_mini/wz_mini.conf
. /opt/wz_mini/etc/rc.common
if [[ "$ENABLE_USB_DIRECT" == "true" ]]; then
wait_for_wlan_ip $(basename "$0")
sleep 5
gateway_supervisor $(basename "$0") &
fi
echo "kill udhcpc extra"
kill $(pgrep -f 'udhcpc -i wlan0 -H WyzeCam')

View File

@@ -0,0 +1,3 @@
#!/bin/sh
echo "up"

View File

@@ -68,6 +68,8 @@ RTSP_LOW_RES_MAX_BITRATE=""
RTSP_LOW_RES_TARGET_BITRATE=""
RTSP_LOW_RES_ENC_PARAMETER=""
RTSP_AUTH_DISABLE="false"
#####RTMP STREAMING#####
#### REQUIRES RTSP ####
### AND RTSP AUDIO ###
@@ -93,12 +95,14 @@ DISABLE_MOTOR="false"
ENABLE_FSCK_ON_BOOT="false"
ENABLE_CAR_DRIVER="false"
ENABLE_LOCAL_DNS="false"
ENABLE_CRONTAB="false"
#####DEBUG#####
#drops you to a shell via serial, doesn't load app_init.sh
DEBUG_ENABLED="false"
DEBUG_INITRAMFS_ENABLED="false"
DEBUG_PASSWORD="false"
ENABLE_SYSLOG_SAVE="false"
####WEB####
WEB_SERVER_ENABLED="false"