"
+ if [ -n "${F_hacks_enable}" ]; then
+ echo "HACKS_ENABLED=1"
+ cmd="s/^\(HACKS_ENABLED\)=0/\1=1/;"
+ else
+ echo "HACKS_ENABLED=0"
+ cmd="s/^\(HACKS_ENABLED\)=1/\1=0/;"
+ fi
+
+ if [ -n "${F_disable_cloud}" ]; then
+ echo "DISABLE_CLOUD=1"
+ cmd="$cmd s/^\(DISABLE_CLOUD\)=0/\1=1/;"
+ else
+ echo "DISABLE_CLOUD=0"
+ cmd="$cmd s/^\(DISABLE_CLOUD\)=1/\1=0/;"
+ fi
+ sed -i.bak "$cmd" /etc/fang_hacks.cfg 2>&1
+ echo "
"
+ if [ $? -eq 0 ]; then echo "Success"; else echo "Failed"; fi
+ ;;
+ settz)
+ tz=$(printf '%b' "${F_tz//%/\\x}")
+ if [ $(cat /etc/TZ) != "$tz" ]; then
+ echo "Setting TZ to '$tz'... "
+ echo "$tz" > /etc/TZ
+ echo "Syncing time... "
+ /usr/sbin/ntpd -q -n -p time.google.com 2>&1
+ fi
+ hst=$(printf '%b' "${F_hostname//%/\\x}")
+ if [ $(cat /etc/hostname) != "$hst" ]; then
+ echo "Setting hostname to '$hst'... "
+ echo "$hst" > /etc/hostname
+ fi
+ if [ $? -eq 0 ]; then echo " Success "; else echo " Failed "; fi
+ ;;
+ expandfs)
+ source /media/mmcblk0p2/data/etc/profile >/dev/null
+ if type awk >/dev/null; then
+ if type fdisk >/dev/null; then
+ p2_start=$(fdisk -l /dev/mmcblk0 | grep mmcblk0p2 | awk '{print $2}')
+ echo "Found the start point of mmcblk0p2: $p2_start "
+ fdisk /dev/mmcblk0 >/dev/null << __EOF__
+d
+2
+n
+p
+2
+$p2_start
+
+p
+w
+__EOF__
+ sync
+ touch /etc/.resize_runonce
+ echo "Ok, Partition resized, please reboot now "
+ else
+ echo "fdisk not found! "
+ fi
+ else
+ echo "awk not found!"
+ fi
+ ;;
+ *)
+ echo "Unsupported command '$F_cmd'"
+ ;;
+ esac
+fi
+
+echo ""
+echo ""
diff --git a/cfg_rtsp b/cfg_rtsp
new file mode 100644
index 0000000..baa26fc
--- /dev/null
+++ b/cfg_rtsp
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+echo "Content-type: text/html"
+echo ""
+
+CMDLINE="`grep -m 1 "_server" /media/mmcblk0p2/data/etc/scripts/20-rtsp-server`"
+
+cat << EOF
+
+
+
+Fang Hacks
+
+
+
+
Configure RTSP
+
+
+
+
+
+
+
+
+
+
Command line options:
+Availability of some options depends on the program/version that is installed
+ -A username:password: username and password for authentication
+ -Q length: Number of frame queue (default 10)
+ ZXF options :
+ -D frame delay: Number of frames to delay (default 0)
+ -R record thresh: Motion detection threshold to record (default -1, <0 for off)
+ -L record length: Number of frames to record per file (must be >= 10*fps)
+ -B record buffer: Number of frames to record prior to motion (must be <= 60)
+ RTSP options :
+ -u url : unicast url (default unicast)
+ -m url : multicast url (default multicast)
+ -M addr : multicast group (default is a random address)
+ -P port : RTSP port (default 554)
+ -T port : RTSP over HTTP port (default 0)
+ V4L2 options :
+ -F fps : V4L2 capture framerate (default 30)
+ -i isp_fps : ISP capture framerate (default 30)
+ -W width : V4L2 capture width (default 1280)
+ -H height : V4L2 capture height (default 720)
+ V4L2 H264 options :
+ -b bitrate : V4L2 capture bitrate kbps(default 1024 kbps)
+ -g gop : V4L2 capture gop (default 30 )
+ device : V4L2 capture device (default /dev/video1)
+ V4L2 MJPEG options :
+ -j mjpeg_qp : MJPEG streaming and qp (default is 60)
+ -c capture path enable (default is disable)
+ -s encoder scale (1/2/4) (default is 1)
+ -a : enable A-law pcm streaming
+EOF
+#note: to display command line options, following works in shell but does not work in script, needs to be improved
+#eval "$(grep -m 1 "_server" /media/mmcblk0p2/data/etc/test/20-rtsp-server | awk '{ print $1 }') -h"
+cat << EOF
+
+EOF
+CMDLINE=$(echo $QUERY_STRING | sed 's/^.....//' | sed -e "s/\+/ /g" | sed -e "s/\%3E/>/g" | sed -e "s/\%26/\&/g" | sed -e "s/\%24/\$/g")
+#don't save the file if it doesn't include _server in the command
+if [ -z "${CMDLINE##*_server*}" ]; then
+ sed -i '/_server/c\'"$CMDLINE" /media/mmcblk0p2/data/etc/scripts/20-rtsp-server 2>&1
+ echo "File saved"
+else
+ echo "error"
+fi
+cat << EOF
+
+EOF
+HACKS_HOME="/media/mmcblk0p2/data"
+if [ -x "/etc/fang_hacks.sh" ]; then
+ echo "Script is already installed! "
+ if [ ! $(mount |grep /media/mmcblk0p2) ]; then
+ echo "Error: Nothing is mounted on /media/mmcblk0p2!"
+ echo ""
+ echo " "
+ elif [ ! -d "$HACKS_HOME" ]; then
+ echo "Error: No 'data' directory found in /media/mmcblk0p2!"
+ echo " "
+ else
+ if [ -e "/etc/.resize_runonce" ]; then
+ echo "Reboot required to apply new partition layout!"
+ echo " "
+ elif [ -e "$HACKS_HOME/.resize" ]; then
+ echo "Expand data partition (/media/mmcblk0p2)?"
+ echo ""
+ echo " "
+ fi
+ fi
+ if [ -e /etc/fang_hacks.cfg ]; then
+ source /etc/fang_hacks.cfg
+ echo ""
+ fi
+ echo "Apply updates from sd-card?"
+ echo ""
+else
+ echo "Do you want to apply Xiao Fang hacks? "
+ echo ""
+fi
+
+cat << EOF
+
+
+
+
+
+
+
+
+
+
+
+
+
Date:
+
+
+
+
+
+
System uptime:
+
$(uptime)
+
+
+
Version:
+
$(cat /etc/os-release | cut -d'=' -f2)
+
+
+
Kernel:
+
$(uname -a)
+
+
+
Process list:
+
$(ps)
+
+
+
Mounts:
+
$(mount)
+
+
+
+
+
+EOF
From 1a4c648f5b96ee61f9459a1f4973aa2ecbdca66c Mon Sep 17 00:00:00 2001
From: zavviodotcom <30752771+zavviodotcom@users.noreply.github.com>
Date: Sat, 5 Aug 2017 10:03:14 -0600
Subject: [PATCH 02/13] Add files via upload
add functionality to configure rtsp server from web interface (there probably is easier way to do this)
also add functionality to power-off from web interface
---
bootstrap/www/action | 4 ++
bootstrap/www/cfg_rtsp | 73 +++++++++++++++++++++++++++++++++++++
bootstrap/www/cfg_rtsp_save | 49 +++++++++++++++++++++++++
bootstrap/www/status | 6 ++-
4 files changed, 130 insertions(+), 2 deletions(-)
create mode 100644 bootstrap/www/cfg_rtsp
create mode 100644 bootstrap/www/cfg_rtsp_save
diff --git a/bootstrap/www/action b/bootstrap/www/action
index de76c76..0728891 100755
--- a/bootstrap/www/action
+++ b/bootstrap/www/action
@@ -108,6 +108,10 @@ if [ -n "$F_cmd" ]; then
echo "Rebooting device... "
/sbin/reboot
;;
+ poweroff)
+ echo "Powering off... "
+ /sbin/poweroff
+ ;;
telnetd)
echo "Starting default telnetd (port 23)... "
start_telnetd
diff --git a/bootstrap/www/cfg_rtsp b/bootstrap/www/cfg_rtsp
new file mode 100644
index 0000000..baa26fc
--- /dev/null
+++ b/bootstrap/www/cfg_rtsp
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+echo "Content-type: text/html"
+echo ""
+
+CMDLINE="`grep -m 1 "_server" /media/mmcblk0p2/data/etc/scripts/20-rtsp-server`"
+
+cat << EOF
+
+
+
+Fang Hacks
+
+
+
+
Configure RTSP
+
+
+
+
+
+
+
+
+
+
Command line options:
+Availability of some options depends on the program/version that is installed
+ -A username:password: username and password for authentication
+ -Q length: Number of frame queue (default 10)
+ ZXF options :
+ -D frame delay: Number of frames to delay (default 0)
+ -R record thresh: Motion detection threshold to record (default -1, <0 for off)
+ -L record length: Number of frames to record per file (must be >= 10*fps)
+ -B record buffer: Number of frames to record prior to motion (must be <= 60)
+ RTSP options :
+ -u url : unicast url (default unicast)
+ -m url : multicast url (default multicast)
+ -M addr : multicast group (default is a random address)
+ -P port : RTSP port (default 554)
+ -T port : RTSP over HTTP port (default 0)
+ V4L2 options :
+ -F fps : V4L2 capture framerate (default 30)
+ -i isp_fps : ISP capture framerate (default 30)
+ -W width : V4L2 capture width (default 1280)
+ -H height : V4L2 capture height (default 720)
+ V4L2 H264 options :
+ -b bitrate : V4L2 capture bitrate kbps(default 1024 kbps)
+ -g gop : V4L2 capture gop (default 30 )
+ device : V4L2 capture device (default /dev/video1)
+ V4L2 MJPEG options :
+ -j mjpeg_qp : MJPEG streaming and qp (default is 60)
+ -c capture path enable (default is disable)
+ -s encoder scale (1/2/4) (default is 1)
+ -a : enable A-law pcm streaming
+EOF
+#note: to display command line options, following works in shell but does not work in script, needs to be improved
+#eval "$(grep -m 1 "_server" /media/mmcblk0p2/data/etc/test/20-rtsp-server | awk '{ print $1 }') -h"
+cat << EOF
+
+EOF
+CMDLINE=$(echo $QUERY_STRING | sed 's/^.....//' | sed -e "s/\+/ /g" | sed -e "s/\%3E/>/g" | sed -e "s/\%26/\&/g" | sed -e "s/\%24/\$/g")
+#don't save the file if it doesn't include _server in the command
+if [ -z "${CMDLINE##*_server*}" ]; then
+ sed -i '/_server/c\'"$CMDLINE" /media/mmcblk0p2/data/etc/scripts/20-rtsp-server 2>&1
+ echo "File saved"
+else
+ echo "error"
+fi
+cat << EOF
+
-EOF
-CMDLINE=$(echo $QUERY_STRING | sed 's/^.....//' | sed -e "s/\+/ /g" | sed -e "s/\%3E/>/g" | sed -e "s/\%26/\&/g" | sed -e "s/\%24/\$/g")
-#don't save the file if it doesn't include _server in the command
-if [ -z "${CMDLINE##*_server*}" ]; then
- sed -i '/_server/c\'"$CMDLINE" /media/mmcblk0p2/data/etc/scripts/20-rtsp-server 2>&1
- echo "File saved"
-else
- echo "error"
-fi
-cat << EOF
-
Command line options:
-Availability of some options depends on the program/version that is installed
- -A username:password: username and password for authentication
- -Q length: Number of frame queue (default 10)
- ZXF options :
- -D frame delay: Number of frames to delay (default 0)
- -R record thresh: Motion detection threshold to record (default -1, <0 for off)
- -L record length: Number of frames to record per file (must be >= 10*fps)
- -B record buffer: Number of frames to record prior to motion (must be <= 60)
- RTSP options :
- -u url : unicast url (default unicast)
- -m url : multicast url (default multicast)
- -M addr : multicast group (default is a random address)
- -P port : RTSP port (default 554)
- -T port : RTSP over HTTP port (default 0)
- V4L2 options :
- -F fps : V4L2 capture framerate (default 30)
- -i isp_fps : ISP capture framerate (default 30)
- -W width : V4L2 capture width (default 1280)
- -H height : V4L2 capture height (default 720)
- V4L2 H264 options :
- -b bitrate : V4L2 capture bitrate kbps(default 1024 kbps)
- -g gop : V4L2 capture gop (default 30 )
- device : V4L2 capture device (default /dev/video1)
- V4L2 MJPEG options :
- -j mjpeg_qp : MJPEG streaming and qp (default is 60)
- -c capture path enable (default is disable)
- -s encoder scale (1/2/4) (default is 1)
- -a : enable A-law pcm streaming
-EOF
-#note: to display command line options, following works in shell but does not work in script, needs to be improved
-#eval "$(grep -m 1 "_server" /media/mmcblk0p2/data/etc/test/20-rtsp-server | awk '{ print $1 }') -h"
-cat << EOF
-
-
-
-EOF
From 94f0a07c739055d128686b8a81e4441c7ce69a5a Mon Sep 17 00:00:00 2001
From: zavviodotcom <30752771+zavviodotcom@users.noreply.github.com>
Date: Sat, 5 Aug 2017 10:06:52 -0600
Subject: [PATCH 06/13] Delete action
deleting from incorrect folder
---
action | 202 ---------------------------------------------------------
1 file changed, 202 deletions(-)
delete mode 100644 action
diff --git a/action b/action
deleted file mode 100644
index 0728891..0000000
--- a/action
+++ /dev/null
@@ -1,202 +0,0 @@
-#!/bin/sh
-
-echo "Content-type: text/html"
-echo ""
-
-source func.cgi
-
-start_telnetd()
-{
- if [ $(pidof telnetd) ]; then
- pid=$(pidof telnetd)
- echo "Telnetd is already running! (PID: $pid) "
- echo "Killing PID $pid "
- kill $pid
- sleep 1
- fi
- /usr/sbin/telnetd &
- sleep 1
- echo "Started (PID: $(pidof telnetd)) "
-}
-
-manual_mount()
-{
- present=$(lsblk -o KNAME,FSTYPE |grep mmcblk0p2)
- if [ $? -eq 0 ]; then
- echo "Device is present (filesystem: $(echo $present | cut -d' ' -f2)) "
- if [ ! -d /media/mmcblk0p2 ]; then
- echo "Creating mount-point (/media/mmcblk0p2) "
- mkdir /media/mmcblk0p2
- fi
- mount /dev/mmcblk0p2 /media/mmcblk0p2 2>&1
- rc=$?
- echo " "
- if [ $rc -eq 0 ]; then echo "Mounted successfully! "; else echo "Failed to mount! "; fi
- else
- echo "Failed: The sd-card is not inserted or does not contain a mmcblk0p2 partition! "
- fi
-}
-
-update_file()
-{
- if [ ! -e "$2" ]; then
- echo "Source file not found: '$2' "
- return
- fi
-
- diff="$(diff "$1" "$2")"
- if [ $? -eq 0 ]; then
- echo "$1: Unchanged! "
- else
- echo "$1: Changed! "
- echo "