move all configuration to wz_mini.conf and all scripting logic to wz_user.sh in etc/init.d

This commit is contained in:
Alfonso Gamboa 2022-05-24 22:20:37 -07:00
parent 46f3561555
commit 6c818efe5f
6 changed files with 134 additions and 102 deletions

View File

@ -105,7 +105,7 @@ Using this project can potentially expose your device to the open internet depen
## Customization
Edit run_mmc.sh, this is a script stored on the micro sd card that is run when the camera boots. You can change the hostname of the camera, mount NFS, add ping commands, anything you like.
Edit wz_mini.conf, this is stored on the micro sd card inside the wz_mini folder, and loads the configuration variables when the camera boots. You can change the hostname of the camera, add a path to a script to mount NFS, add ping commands, anything you like.
---
@ -273,8 +273,17 @@ WEB_CAM_FPS_RATE="25"
---
Run a custom script:
```
CUSTOM_SCRIPT_PATH=""
```
---
## Latest Updates
* 05-24-22: add `wz_mini.conf` to replace `run_mmc.sh`, all configuration variables are now stored in this file, scripting logic now in wz_user.sh inside init.d folder. add support for user to add a custom script to run on boot.
* 05-23-22: added simple wireguard startup configuration.
* 05-22-22: added fps variable for rtsp server, thanks @claudobahn.
* 05-22-22: Update wz_mini scripts and libraries to support v2 camera. experimental.

30
SD_ROOT/wz_mini/etc/init.d/v3_init.sh Normal file → Executable file
View File

@ -3,8 +3,14 @@
###DO NOT MODIFY UNLESS YOU KNOW WHAT YOU ARE DOING
###
###This file is run by switch_root, from the initramfs in the kernel.
exec 1> /opt/wz_mini/log/v3_init.log 2>&1
export WZMINI_CFG=/opt/wz_mini/wz_mini.conf
[ -f $WZMINI_CFG ] && source $WZMINI_CFG
echo "welcome to v3_init.sh"
echo "PID $$"
@ -21,16 +27,19 @@ echo '
set -x
#test for v2
mount -t jffs2 /dev/mtdblock9 /params
if cat /params/config/.product_config | grep WYZEC1-JZ; then
V2="true"
fi
#WCV3 AUDIO GPIO
GPIO=63
#replace stock busybox
mount --bind /opt/wz_mini/bin/busybox /bin/busybox
#WCV3 GPIO
GPIO=63
#test for v2
if [ -b /dev/mtdblock7 ]; then
mount -t jffs2 /dev/mtdblock9 /params
if cat /params/config/.product_config | grep WYZEC1-JZ; then
V2="true"
fi
fi
#Check model, change GPIO is HL_PAN2
if [[ "$V2" == "false" ]]; then
@ -139,13 +148,13 @@ fi
echo "Run dropbear ssh server"
/opt/wz_mini/bin/dropbear -R -s -g
if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "DEBUG_ENABLED\=") == "DEBUG_ENABLED\=\"true\"" ]]; then
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
else
if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "WEB_CAM_ENABLE\=") == "WEB_CAM_ENABLE\=\"true\"" ]]; then
if [[ "$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
@ -154,7 +163,8 @@ fi
fi
if ! [[ -e /tmp/dbgflag ]]; then
/opt/wz_mini/run_mmc.sh &
# /opt/wz_mini/run_mmc.sh &
/opt/wz_mini/etc/init.d/wz_user.sh &
else
echo "debug enabled, ignore run_mmc.sh"
fi

View File

@ -1,23 +1,33 @@
#!/bin/sh
##THIS FILE IS CALLED BY rcS, EXECUTED BEFORE app_init.sh IS RUN.
### This file is called by /etc/init.d/rcS, run before app_init.sh
exec 1> /opt/wz_mini/log/v3_post.log 2>&1
set -x
export WZMINI_CFG=/opt/wz_mini/wz_mini.conf
[ -f $WZMINI_CFG ] && source $WZMINI_CFG
echo "welcome to v3_post.sh"
echo "PID $$"
echo "mount kernel modules"
mount --bind /opt/wz_mini/lib/modules /lib/modules
if cat /params/config/.product_config | grep WYZEC1-JZ; then
V2="true"
if [ -d /lib/modules ]; then
echo "mount kernel modules"
mount --bind /opt/wz_mini/lib/modules /lib/modules
fi
if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_HI_RES_ENABLED\=") == "RTSP_HI_RES_ENABLED\=\"true\"" ]] || [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_LOW_RES_ENABLED\=") == "RTSP_LOW_RES_ENABLED\=\"true\"" ]] && ! [[ -e /tmp/dbgflag ]]; then
if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_LOW_RES_ENABLED\=") == "RTSP_LOW_RES_ENABLED\=\"true\"" ]] && [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_HI_RES_ENABLED\=") == "RTSP_HI_RES_ENABLED\=\"true\"" ]]; then
if [ -f /params/config/.product_config ]; then
if cat /params/config/.product_config | grep WYZEC1-JZ; then
V2="true"
fi
fi
##RTSP SERVER INIT
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 [[ "$V2" == "true"]]; then
echo "load video loopback driver at video6 video7"
insmod /opt/wz_mini/lib/modules/3.10.14_v2/kernel/v4l2loopback_V2.ko video_nr=6,7
@ -25,7 +35,7 @@ if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_HI_RES_ENABLED\=") == "RTSP_HI_
echo "load video loopback driver at video1 video2"
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/v4l2loopback.ko video_nr=1,2
fi
elif [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_LOW_RES_ENABLED\=") == "RTSP_LOW_RES_ENABLED\=\"true\"" ]]; then
elif [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then
if [[ "$V2" == "true"]]; then
echo "load video loopback driver at video7"
insmod /opt/wz_mini/lib/modules/3.10.14_v2/kernel/v4l2loopback_V2.ko video_nr=7
@ -33,7 +43,7 @@ if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_HI_RES_ENABLED\=") == "RTSP_HI_
echo "load video loopback driver at video2"
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/v4l2loopback.ko video_nr=2
fi
elif [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_HI_RES_ENABLED\=") == "RTSP_HI_RES_ENABLED\=\"true\"" ]]; then
elif [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
if [[ "$V2" == "true"]]; then
echo "load video loopback driver at video6"
insmod /opt/wz_mini/lib/modules/3.10.14_v2/kernel/v4l2loopback_V2.ko video_nr=6

0
SD_ROOT/wz_mini/etc/init.d/wz_cam.sh Normal file → Executable file
View File

View File

@ -1,82 +1,15 @@
#!/bin/sh
exec 1> /opt/wz_mini/log/run_mmc.log 2>&1
echo "welcome to run_mmc.sh"
echo "PID $$"
exec 1> /opt/wz_mini/log/wz_user.log 2>&1
set -x
HOSTNAME="WCV3"
echo "welcome to wz_user.sh"
echo "PID $$"
#### W E B CAMERA###
##THIS MODE DISABLES EVERYTHING AND IT WILL
## WORK AS A WEB CAMERA FOR YOUR PC ***ONLY***
WEB_CAM_ENABLE="false"
WEB_CAM_BIT_RATE="8000"
WEB_CAM_FPS_RATE="25"
export WZMINI_CFG=/opt/wz_mini/wz_mini.conf
#####NETWORKING#####
ENABLE_USB_ETH="false"
ENABLE_USB_DIRECT="false"
USB_DIRECT_MAC_ADDR="02:01:02:03:04:08"
ENABLE_USB_RNDIS="false"
ENABLE_IPV6="false"
ENABLE_WIREGUARD="false"
WIREGUARD_IPV4=""
WIREGUARD_PEER_ENDPOINT=""
WIREGUARD_PEER_PUBLIC_KEY=""
WIREGUARD_PEER_ALLOWED_IPS=""
WIREGUARD_PEER_KEEP_ALIVE=""
ENABLE_IPTABLES="false"
ENABLE_NFSv4="false"
#####ACCESSORIES#####
REMOTE_SPOTLIGHT="false"
REMOTE_SPOTLIGHT_HOST="0.0.0.0"
#####VIDEO STREAM#####
RTSP_LOGIN="admin"
RTSP_PASSWORD=""
RTSP_PORT="8554"
RTSP_HI_RES_ENABLED="false"
RTSP_HI_RES_ENABLE_AUDIO="false"
RTSP_HI_RES_FPS=""
RTSP_HI_RES_MAX_BITRATE=""
RTSP_HI_RES_TARGET_BITRATE=""
RTSP_HI_RES_ENC_PARAMETER=""
RTSP_LOW_RES_ENABLED="false"
RTSP_LOW_RES_ENABLE_AUDIO="false"
RTSP_LOW_RES_FPS=""
RTSP_LOW_RES_MAX_BITRATE=""
RTSP_LOW_RES_TARGET_BITRATE=""
RTSP_LOW_RES_ENC_PARAMETER=""
ENABLE_MP4_WRITE="false"
#####GENERAL#####
ENABLE_SWAP="true"
ENABLE_USB_STORAGE="false"
ENABLE_EXT4="false"
ENABLE_CIFS="false"
DISABLE_FW_UPGRADE="false"
SILENT_PROMPTS="false"
#####DEBUG#####
DEBUG_ENABLED="false"
#drops you to a shell via serial, doesn't load app_init.sh
#####################################
##########CONFIG END#################
#####################################
[ -f $WZMINI_CFG ] && source $WZMINI_CFG
hostname_set() {
echo "set hostname"
@ -556,13 +489,10 @@ fi
hostname_set
touch /opt/wz_mini/tmp/.run_mmc_firstrun
sync;echo 3 > /proc/sys/vm/drop_caches
sleep 3
#################################################
##############CUSTOM BEGIN#######################
#################################################
#Place commands here to run 30 seconds after boot
#such as mount nfs, ping, etc
#mount -t nfs -o nolock,rw,noatime,nodiratime 192.168.1.1:/volume1 /media/mmc/record &
if [ -f "$CUSTOM_SCRIPT_PATH" ]; then
echo "starting custom script"
$CUSTOM_SCRIPT_PATH &
else
echo "custom script not found"
fi

View File

@ -0,0 +1,73 @@
#wz_mini configuration
#### W E B CAMERA###
##THIS MODE DISABLES EVERYTHING AND IT WILL
## WORK AS A WEB CAMERA FOR YOUR PC ***ONLY***
WEB_CAM_ENABLE="false"
WEB_CAM_BIT_RATE="8000"
WEB_CAM_FPS_RATE="25"
#####NETWORKING#####
HOSTNAME="WCV3"
ENABLE_USB_ETH="false"
ENABLE_USB_DIRECT="false"
USB_DIRECT_MAC_ADDR="02:01:02:03:04:08"
ENABLE_USB_RNDIS="false"
ENABLE_IPV6="false"
ENABLE_WIREGUARD="false"
WIREGUARD_IPV4=""
WIREGUARD_PEER_ENDPOINT=""
WIREGUARD_PEER_PUBLIC_KEY=""
WIREGUARD_PEER_ALLOWED_IPS=""
WIREGUARD_PEER_KEEP_ALIVE=""
ENABLE_IPTABLES="false"
ENABLE_NFSv4="false"
#####ACCESSORIES#####
REMOTE_SPOTLIGHT="false"
REMOTE_SPOTLIGHT_HOST="0.0.0.0"
#####VIDEO STREAM#####
RTSP_LOGIN="admin"
RTSP_PASSWORD=""
RTSP_PORT="8554"
RTSP_HI_RES_ENABLED="false"
RTSP_HI_RES_ENABLE_AUDIO="false"
RTSP_HI_RES_FPS=""
RTSP_HI_RES_MAX_BITRATE=""
RTSP_HI_RES_TARGET_BITRATE=""
RTSP_HI_RES_ENC_PARAMETER=""
RTSP_LOW_RES_ENABLED="false"
RTSP_LOW_RES_ENABLE_AUDIO="false"
RTSP_LOW_RES_FPS=""
RTSP_LOW_RES_MAX_BITRATE=""
RTSP_LOW_RES_TARGET_BITRATE=""
RTSP_LOW_RES_ENC_PARAMETER=""
ENABLE_MP4_WRITE="false"
#####GENERAL#####
ENABLE_SWAP="true"
ENABLE_USB_STORAGE="false"
ENABLE_EXT4="false"
ENABLE_CIFS="false"
DISABLE_FW_UPGRADE="false"
SILENT_PROMPTS="false"
#####DEBUG#####
#drops you to a shell via serial, doesn't load app_init.sh
DEBUG_ENABLED="false"
DEBUG_INITRAMFS_ENABLED="false"
#####SCRIPTING#####
CUSTOM_SCRIPT_PATH=""