1
0
mirror of https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks.git synced 2025-09-09 15:40:45 +02:00

Moving config entries/cleanup

Moved some configutation options to the config files

Minor text changes

Converted a lot of spaces to tabs
This commit is contained in:
Combie81
2020-05-30 20:02:26 +01:00
committed by Julian Tatsch
parent 468de4de79
commit 5548ab554f
44 changed files with 1511 additions and 1440 deletions

View File

@@ -247,8 +247,8 @@ action "rm -rf ${DESTOVERRIDE} 2>/dev/null"
if [ -f "$VERSION_FILE" ]; then
LOCALCOMMITID=$(${JQ} -r .commit ${VERSION_FILE})
if [ ${LOCALCOMMITID} = ${REMOTECOMMITID} ]; then
logerror "You have already lastest version"
echo "You have already lastest version"
logerror "You are currently on the lastest version"
echo "You are currently on the lastest version"
exit 1
else
echo "Need to upgrade from ${LOCALCOMMITID} to ${REMOTECOMMITID}"

View File

@@ -0,0 +1,6 @@
# min hour day month weekday command
*/15 * * * * busybox run-parts /system/sdcard/config/cron/periodic/15min
0 * * * * busybox run-parts /system/sdcard/config/cron/periodic/hourly
0 2 * * * busybox run-parts /system/sdcard/config/cron/periodic/daily
0 3 * * 6 busybox run-parts /system/sdcard/config/cron/periodic/weekly
0 5 1 * * busybox run-parts /system/sdcard/config/cron/periodic/monthly

View File

@@ -15,16 +15,16 @@ mimetype.assign = (
)
index-file.names = ( "index.html" )
server.modules = ("mod_alias",
"mod_auth",
"mod_authn_file",
"mod_redirect",
"mod_rewrite",
"mod_cgi",
"mod_fastcgi",
"mod_dirlisting",
"mod_staticfile",
"mod_accesslog",
"mod_openssl")
"mod_auth",
"mod_authn_file",
"mod_redirect",
"mod_rewrite",
"mod_cgi",
"mod_fastcgi",
"mod_dirlisting",
"mod_staticfile",
"mod_accesslog",
"mod_openssl")
cgi.assign = ( ".cgi" => "/bin/sh" )
@@ -40,38 +40,38 @@ $SERVER["socket"] == ":443" {
# (we don't want to upgrade to SSL nor auth' this path)
$HTTP["url"] !~ "^/.well-known/(.*)" {
$HTTP["scheme"] == "https" {
auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/system/sdcard/config/lighttpd.user"
auth.require = ( "/" => ("method" => "basic", "realm" => "all", "require" => "user=root"))
alias.url = ( "/viewer" => "/system/sdcard/DCIM/" )
$HTTP["url"] =~ "^/viewer($|/)" { server.dir-listing = "enable" }
}
$HTTP["scheme"] == "https" {
auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/system/sdcard/config/lighttpd.user"
auth.require = ( "/" => ("method" => "basic", "realm" => "all", "require" => "user=root"))
alias.url = ( "/viewer" => "/system/sdcard/DCIM/" )
$HTTP["url"] =~ "^/viewer($|/)" { server.dir-listing = "enable" }
}
#If below 7 lines are commented out then SSL is disabled if un-commented SSL is enabled
#SSL is enabled by default
#If disabling SSL you must clear your site cookie
$HTTP["scheme"] == "http" {
# capture vhost name with regex conditiona -> %0 in redirect pattern
# must be the most inner block to the redirect rule
$HTTP["host"] =~ ".*" {
url.redirect = (".*" => "https://%0$0")
}
}
$HTTP["scheme"] == "http" {
# capture vhost name with regex conditiona -> %0 in redirect pattern
# must be the most inner block to the redirect rule
$HTTP["host"] =~ ".*" {
url.redirect = (".*" => "https://%0$0")
}
}
}
## enable debugging
#debug.log-request-header = "enable"
#debug.log-response-header = "enable"
#debug.log-request-handling = "enable"
#debug.log-file-not-found = "enable"
#debug.log-condition-handling = "enable"
#debug.log-request-header = "enable"
#debug.log-response-header = "enable"
#debug.log-request-handling = "enable"
#debug.log-file-not-found = "enable"
#debug.log-condition-handling = "enable"
## where to send error-messages to
server.errorlog = "/tmp/lighttpd-error.log"
server.errorlog = "/tmp/lighttpd-error.log"
## CGI (etc) stderr log
server.breakagelog = "/tmp/lighttpd-cgi-stderr.log"
server.breakagelog = "/tmp/lighttpd-cgi-stderr.log"
## accesslog module
accesslog.filename = "/tmp/lighttpd-access.log"
accesslog.filename = "/tmp/lighttpd-access.log"

View File

@@ -39,7 +39,7 @@ STATUSINTERVAL=30
# If the device doesn't come with a hardware sensor, your only option is to use 'virtual'.
#
# Options:
# hw = Use 'hw' if the device has build in hardware light sensor. For more details, see . See issue eg. #1120 for more details...
# virtual = Use 'virtual' calculations, based on the lightlevel on the image, also known as ISP exposure (from /proc/jz/isp/isp_info)
# false = Use 'false' (default) to DISABLE the topic (It will not publishing details about light level)
# hw = Use 'hw' if the device has build in hardware light sensor. For more details, see . See issue eg. #1120 for more details...
# virtual = Use 'virtual' calculations, based on the lightlevel on the image, also known as ISP exposure (from /proc/jz/isp/isp_info)
# false = Use 'false' (default) to DISABLE the topic (It will not publishing details about light level)
LIGHT_SENSOR="false"

View File

@@ -1,9 +1,9 @@
DISPLAY_AXIS=true
ENABLE_OSD=true
OSD="%H:%M:%S %d.%m.%Y"
COLOR=0
SIZE=0
POSY=
FIXEDW=0
DISPLAY_AXIS=false
COLOR=3
SIZE=18
SPACE=
POSY=
FIXEDW=false
FONTNAME=

View File

@@ -1,24 +1,24 @@
{
"presets":{
"home":{
"x":1400,
"y":350
},
"left":{
"x":0,
"y":350
},
"top":{
"x":1400,
"y":700
},
"right":{
"x":2800,
"y":350
},
"bottom":{
"x":1400,
"y":0
}
"home":{
"x":1400,
"y":350
},
"left":{
"x":0,
"y":350
},
"top":{
"x":1400,
"y":700
},
"right":{
"x":2800,
"y":350
},
"bottom":{
"x":1400,
"y":0
}
}
}

View File

@@ -1,6 +1,6 @@
#######################################################################
# Edit this file and move it to /system/sdcard/config/rtspserver.conf #
# if you need to add options, otherwise defaults will be used #
# if you need to add options, otherwise defaults will be used #
#######################################################################
# Configure RTSP Servers
@@ -15,6 +15,18 @@ PORT=8554
USERNAME=
USERPASSWORD=
#Path to save recordings to:
#Set to main Recording directory
DCIM_PATH="/system/sdcard/DCIM/Recording"
#Add a subdirectory if required:
#Add sub directory to main DCIM path seperated by date then by
#hour for faster loading over ftp
SUB_DIR="$(date +%Y-%m-%d)/$(date +%H)"
#Set the filename format to use
FILE_NAME="REC_$(date +%H-%M-%S.h264)"
# H264 RTSP server options
# Examples:
# RTSPH264OPTS="-W960 -H540"

View File

@@ -34,22 +34,22 @@ fi
export OPENSSL_CONF="${CONFIGPATH}/openssl.cnf"
if [ "$LETSENCRYPT_METHOD" = "webroot" ]; then
./acme.sh/acme.sh --issue -d ${LETSENCRYPT_DOMAIN} --home ${ACMEPATH} \
-w ${CONFIGPATH}/../www/ \
${DEBUG}
./acme.sh/acme.sh --issue -d ${LETSENCRYPT_DOMAIN} --home ${ACMEPATH} \
-w ${CONFIGPATH}/../www/ \
${DEBUG}
elif [ "$LETSENCRYPT_METHOD" = "dns" ]; then
./acme.sh/acme.sh --issue -d ${LETSENCRYPT_DOMAIN} --home ${ACMEPATH} \
--dns ${LETSENCRYPT_DNS_PROVIDER} \
${DEBUG}
./acme.sh/acme.sh --issue -d ${LETSENCRYPT_DOMAIN} --home ${ACMEPATH} \
--dns ${LETSENCRYPT_DNS_PROVIDER} \
${DEBUG}
fi
./acme.sh/acme.sh --install-cert -d ${LETSENCRYPT_DOMAIN} --home ${ACMEPATH} \
--cert-file ${ACMEPATH}/host.crt \
--key-file ${ACMEPATH}/host.key \
--fullchain-file ${ACMEPATH}/fullchain.crt \
--reloadcmd "cat ${ACMEPATH}/host.crt ${ACMEPATH}/host.key > ${CONFIGPATH}/lighttpd.pem ;\
pkill lighttpd.bin ;\
/system/sdcard/bin/lighttpd -f ${CONFIGPATH}/lighttpd.conf"
--cert-file ${ACMEPATH}/host.crt \
--key-file ${ACMEPATH}/host.key \
--fullchain-file ${ACMEPATH}/fullchain.crt \
--reloadcmd "cat ${ACMEPATH}/host.crt ${ACMEPATH}/host.key > ${CONFIGPATH}/lighttpd.pem ;\
pkill lighttpd.bin ;\
/system/sdcard/bin/lighttpd -f ${CONFIGPATH}/lighttpd.conf"
## Adding cronjob to keep the cert updated

View File

@@ -3,5 +3,5 @@
############################################################
# Add your Telegram credentials here (these are just examples)
apiToken="23132160:AAFrSEwzJ-X-64tLnD8JJ$JoAxWIMg$$w"
userChatId="30985132"
apiToken="yuorapitoken"
userChatId="yourchatid"

View File

@@ -3,6 +3,7 @@ TIMELAPSE_INTERVAL=2.0
# Duration of the script should run, in minutes, set to 0 for unlimited
TIMELAPSE_DURATION=0
# Save dir config
DCIM_PATH='/system/sdcard/DCIM/Timelapse'
SAVE_DIR_PER_DAY=1
# Enable compression
COMPRESSION_QUALITY=80
COMPRESSION_QUALITY=100

View File

@@ -13,12 +13,12 @@
FILECAMERAPOS=/system/sdcard/config/cameraposition
if [ -f ${FILECAMERAPOS} ]; then
# Get values in saved config file
origin_x_axis=`grep "x:" ${FILECAMERAPOS} | sed "s/x: //"`
origin_y_axis=`grep "y:" ${FILECAMERAPOS} | sed "s/y: //"`
# Get values in saved config file
origin_x_axis=`grep "x:" ${FILECAMERAPOS} | sed "s/x: //"`
origin_y_axis=`grep "y:" ${FILECAMERAPOS} | sed "s/y: //"`
else
# No such file exists: create it with the current values
/system/sdcard/bin/motor -d s > ${FILECAMERAPOS}
# No such file exists: create it with the current values
/system/sdcard/bin/motor -d s > ${FILECAMERAPOS}
fi
# go to home for both axis

View File

@@ -6,12 +6,12 @@ ctrl_interface_group=0
ap_scan=1
network={
ssid="SSID"
# Uncomment to connect to Hidden SSIDs
#scan_ssid=1
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP WEP104 WEP40
psk="PW"
priority=2
ssid="SSID"
# Uncomment to connect to Hidden SSIDs
#scan_ssid=1
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP WEP104 WEP40
psk="PW"
priority=2
}

View File

@@ -6,7 +6,7 @@ status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
@@ -14,16 +14,16 @@ start()
{
. $CONF_FILE
if [ -f /run/auto-night-detection.pid ]; then
echo "Auto night detection already running";
echo "Auto night detection already running";
else
if [ "$autonight_mode" == "sw" ]; then
echo "Starting software auto night detection"
/system/sdcard/bin/busybox nohup /system/sdcard/bin/autonight $sw_parameters &>/dev/null &
else
echo "Starting hardware auto night detection"
/system/sdcard/bin/busybox nohup /system/sdcard/bin/autonight $hw_parameters &>/dev/null &
fi
echo "$!" > "$PIDFILE"
if [ "$autonight_mode" == "sw" ]; then
echo "Starting software auto night detection"
/system/sdcard/bin/busybox nohup /system/sdcard/bin/autonight $sw_parameters &>/dev/null &
else
echo "Starting hardware auto night detection"
/system/sdcard/bin/busybox nohup /system/sdcard/bin/autonight $hw_parameters &>/dev/null &
fi
echo "$!" > "$PIDFILE"
fi
}
@@ -31,7 +31,7 @@ stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill "$pid" && rm "$PIDFILE"
kill "$pid" && rm "$PIDFILE"
fi
}
@@ -39,8 +39,8 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -6,14 +6,14 @@ if [ ! -f /system/sdcard/config/motion.conf ]; then
fi
if [ -f /system/sdcard/config/motion.conf ] ; then
. /system/sdcard/config/motion.conf 2>/dev/null
/system/sdcard/bin/setconf -k r -v ${region_of_interest} 2>/dev/null
if [ "$motion_detection" = "off" ]; then
/system/sdcard/bin/setconf -k m -v -1 2>/dev/null
else
/system/sdcard/bin/setconf -k m -v ${motion_sensitivity} 2>/dev/null
fi
/system/sdcard/bin/setconf -k z -v ${motion_indicator_color} 2>/dev/null
/system/sdcard/bin/setconf -k t -v ${motion_tracking} 2>/dev/null
/system/sdcard/bin/setconf -k u -v ${motion_timeout} 2>/dev/null
. /system/sdcard/config/motion.conf 2>/dev/null
/system/sdcard/bin/setconf -k r -v ${region_of_interest} 2>/dev/null
if [ "$motion_detection" = "off" ]; then
/system/sdcard/bin/setconf -k m -v -1 2>/dev/null
else
/system/sdcard/bin/setconf -k m -v ${motion_sensitivity} 2>/dev/null
fi
/system/sdcard/bin/setconf -k z -v ${motion_indicator_color} 2>/dev/null
/system/sdcard/bin/setconf -k t -v ${motion_tracking} 2>/dev/null
/system/sdcard/bin/setconf -k u -v ${motion_timeout} 2>/dev/null
fi;

View File

@@ -2,17 +2,17 @@
## Get OSD-Information
if [ -f /system/sdcard/config/osd.conf ]; then
. /system/sdcard/config/osd.conf > /dev/null 2>/dev/null
AXIS=""
# Call setconf only if we have something to set, to avoid outputing error messages
[ "${DISPLAY_AXIS}" = true ] && AXIS=$(/system/sdcard/bin/motor -d s | sed '3d' | awk '{printf ("%s ",$0)}' | awk '{print " X="$2,"Y="$4}')
[ "${ENABLE_OSD}" = true ] && /system/sdcard/bin/setconf -k o -v "${OSD}${AXIS}" 2>/dev/null
[ ! -z "${COLOR}" ] && /system/sdcard/bin/setconf -k c -v ${COLOR} 2>/dev/null
[ ! -z "${SIZE}" ] && /system/sdcard/bin/setconf -k s -v ${SIZE} 2>/dev/null
[ ! -z "${POSY}" ] && /system/sdcard/bin/setconf -k x -v ${POSY} 2>/dev/null
[ ! -z "${FIXEDW}" ] && /system/sdcard/bin/setconf -k w -v ${FIXEDW} 2>/dev/null
[ ! -z "${SPACE}" ] && /system/sdcard/bin/setconf -k p -v ${SPACE} 2>/dev/null
[ ! -z "${FONTNAME}" ] && /system/sdcard/bin/setconf -k e -v ${FONTNAME} 2>/dev/null
. /system/sdcard/config/osd.conf > /dev/null 2>/dev/null
AXIS=""
# Call setconf only if we have something to set, to avoid outputing error messages
[ "${DISPLAY_AXIS}" = true ] && AXIS=$(/system/sdcard/bin/motor -d s | sed '3d' | awk '{printf ("%s ",$0)}' | awk '{print " X="$2,"Y="$4}')
[ "${ENABLE_OSD}" = true ] && /system/sdcard/bin/setconf -k o -v "${OSD}${AXIS}" 2>/dev/null
[ ! -z "${COLOR}" ] && /system/sdcard/bin/setconf -k c -v ${COLOR} 2>/dev/null
[ ! -z "${SIZE}" ] && /system/sdcard/bin/setconf -k s -v ${SIZE} 2>/dev/null
[ ! -z "${POSY}" ] && /system/sdcard/bin/setconf -k x -v ${POSY} 2>/dev/null
[ ! -z "${FIXEDW}" ] && /system/sdcard/bin/setconf -k w -v ${FIXEDW} 2>/dev/null
[ ! -z "${SPACE}" ] && /system/sdcard/bin/setconf -k p -v ${SPACE} 2>/dev/null
[ ! -z "${FONTNAME}" ] && /system/sdcard/bin/setconf -k e -v ${FONTNAME} 2>/dev/null
else
/system/sdcard/bin/setconf -k o -v ""
/system/sdcard/bin/setconf -k o -v ""
fi

View File

@@ -6,19 +6,19 @@ status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
if [ -f ${PIDFILE} ]; then
echo "Debug on OSD already running";
echo "Debug on OSD already running";
else
echo "Starting debug on OSD"
/system/sdcard/scripts/debugInOsd.sh &>/dev/null &
# /system/sdcard/bin/busybox nohup /system/sdcard/scripts/debugInOsd.sh &>/dev/null
echo "$!" > "$PIDFILE"
echo "Starting debug on OSD"
/system/sdcard/scripts/debugInOsd.sh &>/dev/null &
# /system/sdcard/bin/busybox nohup /system/sdcard/scripts/debugInOsd.sh &>/dev/null
echo "$!" > "$PIDFILE"
fi
}
@@ -26,10 +26,10 @@ stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "${pid}" ]; then
kill "$pid" && rm "$PIDFILE"
if [ -f /system/sdcard/controlscripts/configureOsd ]; then
source /system/sdcard/controlscripts/configureOsd
fi
kill "$pid" && rm "$PIDFILE"
if [ -f /system/sdcard/controlscripts/configureOsd ]; then
source /system/sdcard/controlscripts/configureOsd
fi
fi
}
@@ -38,8 +38,8 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -4,52 +4,52 @@ PIDFILE="/var/run/bftpd.pid"
status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
echo "Starting bftpd server"
PID="$(pidof -o %PPID /system/sdcard/bin/bftpd)"
if [ -z "$PID" ]; then
/system/sdcard/bin/bftpd -d
if [ $? -gt 0 ]; then
echo "Failed to start bftpd Server"
else
# wait until it forks
sleep 2
echo $(pidof -o %PPID bftpd) > $PIDFILE
echo "bftpd server started"
fi
else
echo "Failed to start bftpd Server"
fi
echo "Starting bftpd server"
PID="$(pidof -o %PPID /system/sdcard/bin/bftpd)"
if [ -z "$PID" ]; then
/system/sdcard/bin/bftpd -d
if [ $? -gt 0 ]; then
echo "Failed to start bftpd Server"
else
# wait until it forks
sleep 2
echo $(pidof -o %PPID bftpd) > $PIDFILE
echo "bftpd server started"
fi
else
echo "Failed to start bftpd Server"
fi
}
stop()
{
echo "Stopping bftpd Server"
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
kill -15 $(cat $PIDFILE)
rm $PIDFILE
echo "bftpd server stopped"
else
echo "Failed to stop bftpd Server"
fi
echo "Stopping bftpd Server"
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
kill -15 $(cat $PIDFILE)
rm $PIDFILE
echo "bftpd server stopped"
else
echo "Failed to stop bftpd Server"
fi
}
restart()
{
$0 stop
sleep 1
$0 start
$0 stop
sleep 1
$0 start
}
if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|restart|status)
$1
;;
$1
;;
esac
fi

View File

@@ -9,25 +9,25 @@ status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
if [ -f $PIDFILE ]; then
echo "MQTT Control already running";
echo "MQTT Control already running";
else
. /system/sdcard/config/mqtt.conf
if [ -z ${AUTODISCOVERY_PREFIX+x} ];
then echo "MQTT autodiscovery is not enabled";
else
echo "MQTT autodiscovery is enabled - now publishing initial configurations";
/system/sdcard/scripts/mqtt-autodiscovery.sh
fi
echo "Starting MQTT - Control"
/system/sdcard/bin/busybox nohup /system/sdcard/scripts/mqtt-control.sh &>/dev/null &
echo "$!" > "$PIDFILE"
. /system/sdcard/config/mqtt.conf
if [ -z ${AUTODISCOVERY_PREFIX+x} ];
then echo "MQTT autodiscovery is not enabled";
else
echo "MQTT autodiscovery is enabled - now publishing initial configurations";
/system/sdcard/scripts/mqtt-autodiscovery.sh
fi
echo "Starting MQTT - Control"
/system/sdcard/bin/busybox nohup /system/sdcard/scripts/mqtt-control.sh &>/dev/null &
echo "$!" > "$PIDFILE"
fi
}
@@ -35,10 +35,10 @@ stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
killall mosquitto_sub 2>/dev/null
killall mosquitto_sub.bin 2>/dev/null
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
killall mosquitto_sub 2>/dev/null
killall mosquitto_sub.bin 2>/dev/null
fi
}
@@ -46,7 +46,7 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -9,18 +9,18 @@ status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
if [ -f $PIDFILE ]; then
echo "MQTT-Status already running";
echo "MQTT-Status already running";
else
echo "Starting MQTT-Status"
/system/sdcard/bin/busybox nohup /system/sdcard/scripts/mqtt-status-interval.sh &>/dev/null &
echo "$!" > "$PIDFILE"
echo "Starting MQTT-Status"
/system/sdcard/bin/busybox nohup /system/sdcard/scripts/mqtt-status-interval.sh &>/dev/null &
echo "$!" > "$PIDFILE"
fi
}
@@ -28,7 +28,7 @@ stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill "$pid" && rm "$PIDFILE"
kill "$pid" && rm "$PIDFILE"
fi
}
@@ -36,7 +36,7 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -2,11 +2,10 @@
. /system/sdcard/config/rtspserver.conf
PIDFILE="/run/recording.pid"
DCIM_PATH="/system/sdcard/DCIM/Recording"
## UserName and password
if [ "$USERNAME" != "" ]; then
CREDENTIALS="$USERNAME:$USERPASSWORD@"
CREDENTIALS="$USERNAME:$USERPASSWORD@"
fi
if [ ! -d "$DCIM_PATH" ]; then
@@ -17,32 +16,29 @@ status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
if [ -f $PIDFILE ]; then
echo "Recording already running.";
echo "Recording already running.";
else
echo "Started recording."
# Add sub directory to main dcim path seperated by date then by
# hour for faster loading over ftp
SUB_DIR="$(date +%Y-%m-%d)/$(date +%H)"
if [ ! -d "$DCIM_PATH/$SUB_DIR" ]; then
mkdir -p "$DCIM_PATH/$SUB_DIR"
fi
echo "Started recording."
if [ ! -d "$DCIM_PATH/$SUB_DIR" ]; then
mkdir -p "$DCIM_PATH/$SUB_DIR"
fi
# Create the recording with timestamp
FILE_NAME="REC_$(date +%H-%M-%S.h264)"
RECORDING_PATH="$DCIM_PATH/$SUB_DIR/$FILE_NAME"
# wait for rtspserver to become available
until pids=$(pidof v4l2rtspserver-master)
do
sleep 1
done
/system/sdcard/bin/busybox nohup /system/sdcard/bin/avconv -flags low_delay -fflags nobuffer -probesize 32 -i rtsp://"$CREDENTIALS"0.0.0.0:$PORT/unicast -strict experimental -y -vcodec copy -an $RECORDING_PATH &>/dev/null &
echo "$!" > "$PIDFILE"
RECORDING_PATH="$DCIM_PATH/$SUB_DIR/$FILE_NAME"
# wait for rtspserver to become available
until pids=$(pidof v4l2rtspserver-master)
do
sleep 1
done
/system/sdcard/bin/busybox nohup /system/sdcard/bin/avconv -flags low_delay -fflags nobuffer -probesize 32 -i rtsp://"$CREDENTIALS"0.0.0.0:$PORT/unicast -strict experimental -y -vcodec copy -an $RECORDING_PATH &>/dev/null &
echo "$!" > "$PIDFILE"
fi
}
@@ -50,11 +46,11 @@ stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
echo "Stopped recording."
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
echo "Stopped recording."
else
echo "Could not find a running recording to stop."
echo "Could not find a running recording to stop."
fi
}
@@ -62,7 +58,7 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -22,84 +22,84 @@ status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
# return current pid if pidfile exists and contained pid is alive
# return 1 if pidfile existed but the contained pid is dead
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
# return current pid if pidfile exists and contained pid is alive
# return 1 if pidfile existed but the contained pid is dead
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
else
# return 2 if pidfile did not exist
return 2
# return 2 if pidfile did not exist
return 2
fi
}
start()
{
if [ "$(status)" != "" ]; then
echo "A v4l2rtspserver is already running, please stop it or reboot"
echo "A v4l2rtspserver is already running, please stop it or reboot"
else
echo "Starting v4l2rtspserver-master"
/system/sdcard/controlscripts/rtsp-mjpeg stop
echo "Starting v4l2rtspserver-master"
/system/sdcard/controlscripts/rtsp-mjpeg stop
## Configure OSD
if [ -f /system/sdcard/controlscripts/configureOsd ]; then
. /system/sdcard/controlscripts/configureOsd 2>/dev/null
fi
## Configure OSD
if [ -f /system/sdcard/controlscripts/configureOsd ]; then
. /system/sdcard/controlscripts/configureOsd 2>/dev/null
fi
## Configure Motion
if [ -f /system/sdcard/controlscripts/configureMotion ]; then
. /system/sdcard/controlscripts/configureMotion 2>/dev/null
fi
## Bitrate
/system/sdcard/bin/setconf -k b -v ${BITRATE} 2>/dev/null
## Configure Motion
if [ -f /system/sdcard/controlscripts/configureMotion ]; then
. /system/sdcard/controlscripts/configureMotion 2>/dev/null
fi
## Bitrate
/system/sdcard/bin/setconf -k b -v ${BITRATE} 2>/dev/null
## Framerate
if [ "$FRAMERATE_DEN" != "" ] && [ "$FRAMERATE_NUM" != "" ]; then
/system/sdcard/bin/setconf -k d -v "$FRAMERATE_NUM,$FRAMERATE_DEN" 2>/dev/null
fi
## Framerate
if [ "$FRAMERATE_DEN" != "" ] && [ "$FRAMERATE_NUM" != "" ]; then
/system/sdcard/bin/setconf -k d -v "$FRAMERATE_NUM,$FRAMERATE_DEN" 2>/dev/null
fi
## Audio
if [ "$AUDIOFORMAT" != "OFF" ] ; then
AUDIOPARAM="-E $AUDIOFORMAT:$AUDIOINBR:$AUDIOOUTBR"
/system/sdcard/bin/setconf -k h -v "$HWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k i -v "$SWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k q -v "$FILTER" 2>/dev/null
/system/sdcard/bin/setconf -k l -v "$HIGHPASSFILTER" 2>/dev/null
/system/sdcard/bin/setconf -k a -v "$AECFILTER" 2>/dev/null
else
AUDIOPARAM="-A"
fi
## Audio
if [ "$AUDIOFORMAT" != "OFF" ] ; then
AUDIOPARAM="-E $AUDIOFORMAT:$AUDIOINBR:$AUDIOOUTBR"
/system/sdcard/bin/setconf -k h -v "$HWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k i -v "$SWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k q -v "$FILTER" 2>/dev/null
/system/sdcard/bin/setconf -k l -v "$HIGHPASSFILTER" 2>/dev/null
/system/sdcard/bin/setconf -k a -v "$AECFILTER" 2>/dev/null
else
AUDIOPARAM="-A"
fi
## Video format
if [ "$VIDEOFORMAT" != "" ]; then
VIDEOFORMAT="-r $VIDEOFORMAT -F $FRAMERATE_NUM"
fi
## Video format
if [ "$VIDEOFORMAT" != "" ]; then
VIDEOFORMAT="-r $VIDEOFORMAT -F $FRAMERATE_NUM"
fi
## UserName and password
if [ "$USERNAME" != "" ]; then
CREDENTIAL="-U $USERNAME:$USERPASSWORD"
fi
## UserName and password
if [ "$USERNAME" != "" ]; then
CREDENTIAL="-U $USERNAME:$USERPASSWORD"
fi
## Port
if [ "$PORT" != "" ]; then
PORT="-P $PORT"
fi
## Port
if [ "$PORT" != "" ]; then
PORT="-P $PORT"
fi
## Multicast
if [ "$MULTICASTDEST" != "" ]; then
MULTICASTDEST="-M $MULTICASTDEST"
fi
## Multicast
if [ "$MULTICASTDEST" != "" ]; then
MULTICASTDEST="-M $MULTICASTDEST"
fi
## FLIP
if [ "$FLIP" == "ON" ]; then
/system/sdcard/bin/setconf -k f -v 1
elif [ "$FLIP" == "OFF" ]; then
/system/sdcard/bin/setconf -k f -v 0
fi
## FLIP
if [ "$FLIP" == "ON" ]; then
/system/sdcard/bin/setconf -k f -v 1
elif [ "$FLIP" == "OFF" ]; then
/system/sdcard/bin/setconf -k f -v 0
fi
echo "================== START ===============" >> "$LOGPATH"
echo "/system/sdcard/bin/v4l2rtspserver-master $RTSPH264OPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST" >> "$LOGPATH"
cd /system/sdcard/hls
/system/sdcard/bin/v4l2rtspserver-master $RTSPH264OPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST 2>> "$LOGPATH" >> "$LOGPATH" &
echo "$!" > "$PIDFILE"
echo "================== START ===============" >> "$LOGPATH"
echo "/system/sdcard/bin/v4l2rtspserver-master $RTSPH264OPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST" >> "$LOGPATH"
cd /system/sdcard/hls
/system/sdcard/bin/v4l2rtspserver-master $RTSPH264OPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST 2>> "$LOGPATH" >> "$LOGPATH" &
echo "$!" > "$PIDFILE"
fi
}
@@ -107,8 +107,8 @@ stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
fi
}
@@ -116,7 +116,7 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -20,79 +20,79 @@ status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
# Prints PID: $pid if exists and returns 0(no error) else returns 1(error condition)
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
# Prints PID: $pid if exists and returns 0(no error) else returns 1(error condition)
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
if [ "$(status)" != "" ]; then
echo "A v4l2rtspserver is already running, please stop it or reboot"
echo "A v4l2rtspserver is already running, please stop it or reboot"
else
echo "Starting v4l2rtspserver-master with parameter -fMJPG"
/system/sdcard/controlscripts/rtsp-h264 stop
echo "Starting v4l2rtspserver-master with parameter -fMJPG"
/system/sdcard/controlscripts/rtsp-h264 stop
## Configure OSD
if [ -f /system/sdcard/controlscripts/configureOsd ]; then
. /system/sdcard/controlscripts/configureOsd 2>/dev/null
fi
## Configure OSD
if [ -f /system/sdcard/controlscripts/configureOsd ]; then
. /system/sdcard/controlscripts/configureOsd 2>/dev/null
fi
## Configure Motion
if [ -f /system/sdcard/controlscripts/configureMotion ]; then
. /system/sdcard/controlscripts/configureMotion 2>/dev/null
fi
## Bitrate
/system/sdcard/bin/setconf -k b -v ${BITRATE} 2>/dev/null
## Configure Motion
if [ -f /system/sdcard/controlscripts/configureMotion ]; then
. /system/sdcard/controlscripts/configureMotion 2>/dev/null
fi
## Bitrate
/system/sdcard/bin/setconf -k b -v ${BITRATE} 2>/dev/null
## Framerate
if [ "$FRAMERATE_DEN" != "" ] && [ "$FRAMERATE_NUM" != "" ]; then
/system/sdcard/bin/setconf -k d -v "$FRAMERATE_NUM,$FRAMERATE_DEN" 2>/dev/null
fi
## Framerate
if [ "$FRAMERATE_DEN" != "" ] && [ "$FRAMERATE_NUM" != "" ]; then
/system/sdcard/bin/setconf -k d -v "$FRAMERATE_NUM,$FRAMERATE_DEN" 2>/dev/null
fi
## Audio
if [ "$AUDIOFORMAT" != "OFF" ] ; then
AUDIOPARAM="-E $AUDIOFORMAT:$AUDIOINBR:$AUDIOOUTBR"
/system/sdcard/bin/setconf -k h -v "$HWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k i -v "$SWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k q -v "$FILTER" 2>/dev/null
/system/sdcard/bin/setconf -k l -v "$HIGHPASSFILTER" 2>/dev/null
/system/sdcard/bin/setconf -k a -v "$AECFILTER" 2>/dev/null
else
AUDIOPARAM="-A"
fi
## Audio
if [ "$AUDIOFORMAT" != "OFF" ] ; then
AUDIOPARAM="-E $AUDIOFORMAT:$AUDIOINBR:$AUDIOOUTBR"
/system/sdcard/bin/setconf -k h -v "$HWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k i -v "$SWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k q -v "$FILTER" 2>/dev/null
/system/sdcard/bin/setconf -k l -v "$HIGHPASSFILTER" 2>/dev/null
/system/sdcard/bin/setconf -k a -v "$AECFILTER" 2>/dev/null
else
AUDIOPARAM="-A"
fi
## Video format
if [ "$VIDEOFORMAT" != "" ]; then
VIDEOFORMAT="-r $VIDEOFORMAT -F $FRAMERATE_NUM"
fi
## Video format
if [ "$VIDEOFORMAT" != "" ]; then
VIDEOFORMAT="-r $VIDEOFORMAT -F $FRAMERATE_NUM"
fi
## UserName and password
if [ "$USERNAME" != "" ]; then
CREDENTIAL="-U $USERNAME:$USERPASSWORD"
fi
## UserName and password
if [ "$USERNAME" != "" ]; then
CREDENTIAL="-U $USERNAME:$USERPASSWORD"
fi
## Port
if [ "$PORT" != "" ]; then
PORT="-P $PORT"
fi
## Port
if [ "$PORT" != "" ]; then
PORT="-P $PORT"
fi
## Multicast
if [ "$MULTICASTDEST" != "" ]; then
MULTICASTDEST="-M $MULTICASTDEST"
fi
## Multicast
if [ "$MULTICASTDEST" != "" ]; then
MULTICASTDEST="-M $MULTICASTDEST"
fi
## FLIP
if [ "$FLIP" == "ON" ]; then
/system/sdcard/bin/setconf -k f -v 1
elif [ "$FLIP" == "OFF" ]; then
/system/sdcard/bin/setconf -k f -v 0
fi
## FLIP
if [ "$FLIP" == "ON" ]; then
/system/sdcard/bin/setconf -k f -v 1
elif [ "$FLIP" == "OFF" ]; then
/system/sdcard/bin/setconf -k f -v 0
fi
echo "================== START ===============" >> "$LOGPATH"
echo "/system/sdcard/bin/v4l2rtspserver-master -fMJPG $RTSPMJPEGOPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST" >> "$LOGPATH"
/system/sdcard/bin/v4l2rtspserver-master -fMJPG $RTSPMJPEGOPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST 2>> "$LOGPATH" >> "$LOGPATH" &
echo "$!" > "$PIDFILE"
echo "================== START ===============" >> "$LOGPATH"
echo "/system/sdcard/bin/v4l2rtspserver-master -fMJPG $RTSPMJPEGOPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST" >> "$LOGPATH"
/system/sdcard/bin/v4l2rtspserver-master -fMJPG $RTSPMJPEGOPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST 2>> "$LOGPATH" >> "$LOGPATH" &
echo "$!" > "$PIDFILE"
fi
}
@@ -100,8 +100,8 @@ stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
fi
}
@@ -109,7 +109,7 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -3,7 +3,7 @@
status()
{
if [ -f /system/sdcard/config/autostart/sound-on-startup ]; then
echo "enabled"
echo "enabled"
fi
}
@@ -12,15 +12,15 @@ start()
UPTIME=$( sed 's/\..*//g' < /proc/uptime )
if [ ! -f /system/sdcard/config/autostart/sound-on-startup ] && [ "${UPTIME}" -gt 60 ] ; then
echo "#!/bin/sh" > "/system/sdcard/config/autostart/sound-on-startup"
echo "/system/sdcard/controlscripts/sound-on-startup" >> "/system/sdcard/config/autostart/sound-on-startup"
echo "enabling sound on startup"
echo "#!/bin/sh" > "/system/sdcard/config/autostart/sound-on-startup"
echo "/system/sdcard/controlscripts/sound-on-startup" >> "/system/sdcard/config/autostart/sound-on-startup"
echo "enabling sound on startup"
fi
# Don't play sound on activation
if [ "${UPTIME}" -lt 60 ]; then
/system/sdcard/bin/audioplay /usr/share/notify/CN/speaker.wav &
echo "Please configure this option at least 1 minute after system startup"
/system/sdcard/bin/audioplay /usr/share/notify/CN/speaker.wav &
echo "Please configure this option at least 1 minute after system startup"
fi
}
@@ -34,8 +34,8 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -16,18 +16,18 @@ status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
if [ -f $PIDFILE ]; then
echo "Bot already running";
echo "Bot already running";
else
echo "Starting bot"
/system/sdcard/bin/busybox nohup /system/sdcard/scripts/telegram-bot-daemon.sh >/dev/null 2>&1 &
echo "$!" > "$PIDFILE"
echo "Starting bot"
/system/sdcard/bin/busybox nohup /system/sdcard/scripts/telegram-bot-daemon.sh >/dev/null 2>&1 &
echo "$!" > "$PIDFILE"
fi
}
@@ -35,11 +35,11 @@ stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -9 "$pid"
rm "$PIDFILE"
echo "Bot stopped"
kill -9 "$pid"
rm "$PIDFILE"
echo "Bot stopped"
else
echo "Could not find a bot to stop."
echo "Could not find a bot to stop."
fi
}
@@ -47,7 +47,7 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -4,52 +4,52 @@ PIDFILE="/var/run/telnetd.pid"
status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
echo "Starting telnetd"
PID="$(pidof -o %PPID /sbin/telnetd)"
if [ -z "$PID" ]; then
/sbin/telnetd
if [ $? -gt 0 ]; then
echo "Failed to start telnetd"
else
# wait until it forks
sleep 2
echo $(pidof -o %PPID telnetd) > $PIDFILE
echo "Telnetd started"
fi
else
echo "Failed to start telnetd"
fi
echo "Starting telnetd"
PID="$(pidof -o %PPID /sbin/telnetd)"
if [ -z "$PID" ]; then
/sbin/telnetd
if [ $? -gt 0 ]; then
echo "Failed to start telnetd"
else
# wait until it forks
sleep 2
echo $(pidof -o %PPID telnetd) > $PIDFILE
echo "Telnetd started"
fi
else
echo "Failed to start telnetd"
fi
}
stop()
{
echo "Stopping telnetd"
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
kill -15 $(cat $PIDFILE)
rm $PIDFILE
echo "Telnetd stopped"
else
echo "Failed to stop telnetd"
fi
echo "Stopping telnetd"
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
kill -15 $(cat $PIDFILE)
rm $PIDFILE
echo "Telnetd stopped"
else
echo "Failed to stop telnetd"
fi
}
restart()
{
$0 stop
sleep 1
$0 start
$0 stop
sleep 1
$0 start
}
if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|restart|status)
$1
;;
$1
;;
esac
fi

View File

@@ -29,7 +29,7 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -268,9 +268,12 @@ done
## Autostart startup userscripts
for i in /system/sdcard/config/userscripts/startup/*; do
if [ $i != *".dist" ]; then
if [[ ${i: -3} == ".sh" ]]; then
$i &
fi
done
echo "Startup finished!" >> $LOGPATH
echo "" >> $LOGPATH
echo "Contents of dmesg after startup:" >> $LOGPATH
dmesg >> $LOGPATH

View File

@@ -1,8 +1,8 @@
#!/bin/sh
#######################################################
# Accepts either presets or step coordinates #
# Created by slm4996 #
# Accepts either presets or step coordinates #
# Created by slm4996 #
# slm4996+github@gmail.com | 4-29-2020 | v0.0.1 Beta #
#######################################################
@@ -11,10 +11,10 @@ set -e
LOG=false
logger() {
echo "$1"
if $LOG; then
echo "$(date '+%Y-%m-%d-%H:%M:%S') $1" >> /system/sdcard/log/ptz.log
fi
echo "$1"
if $LOG; then
echo "$(date '+%Y-%m-%d-%H:%M:%S') $1" >> /system/sdcard/log/ptz.log
fi
}
PIDFILE="/var/run/PTZpresets.pid"
@@ -22,17 +22,17 @@ PIDFILE="/var/run/PTZpresets.pid"
# check pidfile
if [ -e "$PIDFILE" ] && [ -e "/proc/$(cat $PIDFILE)" ]
then
# A process exists with our saved PID
logger "PTZpresets.sh is already running with PID $PID_SAVED; exiting"
exit 1
# A process exists with our saved PID
logger "PTZpresets.sh is already running with PID $PID_SAVED; exiting"
exit 1
fi
# write pidfile
if ! echo $$ >"$PIDFILE"
then
# If we couldn't save the PID to the lockfile...
logger "Failed to create PID file for PID $$ in $PIDFILE; exiting"
exit 1
# If we couldn't save the PID to the lockfile...
logger "Failed to create PID file for PID $$ in $PIDFILE; exiting"
exit 1
fi
trap 'rm "$PIDFILE"' EXIT
@@ -49,119 +49,119 @@ FILEPRESETS=/system/sdcard/config/ptz_presets.conf
# Check for custom presets file, load examples if not present
if [ ! -f ${FILEPRESETS} ]; then
cp /system/sdcard/config/ptz_presets.conf.dist /system/sdcard/config/ptz_presets.conf
cp /system/sdcard/config/ptz_presets.conf.dist /system/sdcard/config/ptz_presets.conf
fi
# Print usage
print_usage() {
logger "Usage:"
logger "Presets: PTZpresets.sh preset [preset_name]"
logger "Example: PTZpresets.sh preset home"
logger "Presets are defined in /system/sdcard/config/ptz_presets.conf.dist."
logger ""
logger "Steps: PTZpresets.sh [X axis steps] [Y axis steps]"
logger "Example: PTZpresets.sh 1400 350"
logger "Usage:"
logger "Presets: PTZpresets.sh preset [preset_name]"
logger "Example: PTZpresets.sh preset home"
logger "Presets are defined in /system/sdcard/config/ptz_presets.conf.dist."
logger ""
logger "Steps: PTZpresets.sh [X axis steps] [Y axis steps]"
logger "Example: PTZpresets.sh 1400 350"
}
# Calculate relative steps for axis
calculate_relative_steps() {
case $1 in
x|X)
current_x_axis=$($MOTOR -d s | grep "$1" | awk '{print $2}')
relative_x_steps=$(echo $(($2 - current_x_axis)) | sed 's/-//')
;;
y|Y)
current_y_axis=$($MOTOR -d s | grep "$1" | awk '{print $2}')
relative_y_steps=$(echo $(($2 - current_y_axis)) | sed 's/-//')
;;
*)
exit 1
;;
esac
case $1 in
x|X)
current_x_axis=$($MOTOR -d s | grep "$1" | awk '{print $2}')
relative_x_steps=$(echo $(($2 - current_x_axis)) | sed 's/-//')
;;
y|Y)
current_y_axis=$($MOTOR -d s | grep "$1" | awk '{print $2}')
relative_y_steps=$(echo $(($2 - current_y_axis)) | sed 's/-//')
;;
*)
exit 1
;;
esac
}
# Handle preset arguments
preset() {
target_x_axis=$(/system/sdcard/bin/jq ".presets.$1.x" "$FILEPRESETS")
target_y_axis=$(/system/sdcard/bin/jq ".presets.$1.y" "$FILEPRESETS")
if [ "$target_y_axis" = 'null' ]; then
logger "Error: Preset \"$1\" is not defined!"
exit 1
else
logger "Loading preset $1: X=$target_x_axis, Y=$target_y_axis"
fi
target_x_axis=$(/system/sdcard/bin/jq ".presets.$1.x" "$FILEPRESETS")
target_y_axis=$(/system/sdcard/bin/jq ".presets.$1.y" "$FILEPRESETS")
if [ "$target_y_axis" = 'null' ]; then
logger "Error: Preset \"$1\" is not defined!"
exit 1
else
logger "Loading preset $1: X=$target_x_axis, Y=$target_y_axis"
fi
}
# Handle location arguments
location() {
case $2 in
[0-9]*)
target_x_axis=$1
target_y_axis=$2
logger "Location defined: X=$target_x_axis, Y=$target_y_axis"
;;
*)
print_usage
exit 1
;;
esac
case $2 in
[0-9]*)
target_x_axis=$1
target_y_axis=$2
logger "Location defined: X=$target_x_axis, Y=$target_y_axis"
;;
*)
print_usage
exit 1
;;
esac
}
# Main
case "$1" in
preset)
preset "$2"
;;
[0-9]*)
location "$1" "$2"
;;
*)
print_usage
exit 1
;;
preset)
preset "$2"
;;
[0-9]*)
location "$1" "$2"
;;
*)
print_usage
exit 1
;;
esac
calculate_relative_steps "x" "$target_x_axis"
calculate_relative_steps "y" "$target_y_axis"
if [ "$relative_x_steps" -ne 0 ]; then
if [ "$target_x_axis" -lt "$current_x_axis" ]; then
dir="l"
else
dir="r"
fi
if [ "$target_x_axis" -lt "$current_x_axis" ]; then
dir="l"
else
dir="r"
fi
CMD="$MOTOR -d $dir -s $relative_x_steps"
logger "$CMD"
$CMD > /dev/null 2>&1
CMD="$MOTOR -d $dir -s $relative_x_steps"
logger "$CMD"
$CMD > /dev/null 2>&1
# Motor runs 1.3 time as long as the number of steps.
SLEEP_NUM=$(awk -v a="$relative_x_steps" 'BEGIN{printf ("%f",a*1.3/1000)}')
# Motor runs 1.3 time as long as the number of steps.
SLEEP_NUM=$(awk -v a="$relative_x_steps" 'BEGIN{printf ("%f",a*1.3/1000)}')
# Wait for motor to run
sleep "$SLEEP_NUM"
# Wait for motor to run
sleep "$SLEEP_NUM"
else
logger "X axis is already at position: $current_x_axis"
logger "X axis is already at position: $current_x_axis"
fi
if [ "$relative_y_steps" -ne 0 ]; then
if [ "$target_y_axis" -lt "$current_y_axis" ]; then
dir="d"
else
dir="u"
fi
if [ "$target_y_axis" -lt "$current_y_axis" ]; then
dir="d"
else
dir="u"
fi
CMD="$MOTOR -d $dir -s $relative_y_steps"
logger "$CMD"
$CMD > /dev/null 2>&1
CMD="$MOTOR -d $dir -s $relative_y_steps"
logger "$CMD"
$CMD > /dev/null 2>&1
# Motor runs 1.3 time as long as the number of steps.
SLEEP_NUM=$(awk -v a="$relative_y_steps" 'BEGIN{printf ("%f",a*1.3/1000)}')
# Motor runs 1.3 time as long as the number of steps.
SLEEP_NUM=$(awk -v a="$relative_y_steps" 'BEGIN{printf ("%f",a*1.3/1000)}')
# Wait for motor to run
sleep "$SLEEP_NUM"
# Wait for motor to run
sleep "$SLEEP_NUM"
else
logger "Y axis is already at position: $current_y_axis"
logger "Y axis is already at position: $current_y_axis"
fi
# Update OSD_AXIS

File diff suppressed because it is too large Load Diff

View File

@@ -3,22 +3,22 @@ IF=wlan0
while true
do
R1=`cat /sys/class/net/${IF}/statistics/rx_bytes`
T1=`cat /sys/class/net/${IF}/statistics/tx_bytes`
sleep 1
R2=`cat /sys/class/net/${IF}/statistics/rx_bytes`
T2=`cat /sys/class/net/${IF}/statistics/tx_bytes`
TBPS=$(($T2-$T1))
RBPS=$(($R2-$R1))
TKBPS=$(($TBPS/1024))
RKBPS=$(($RBPS/1024))
IP=`ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'`
# CPU=`grep 'cpu ' /proc/stat | awk '{ printf("%.0f", ($2+$4)*100/($2+$4+$5)) }'`
CPU=`top -n 1 | grep CPU: | grep -v grep| awk '{ print $2}'`
freemem=`free | grep Mem |grep -v grep | awk '{ printf("%.0f", $4/$2 * 100.0) }'`
memtop=`top -n 1 | grep Mem: |grep -v grep | awk '{ printf("Used=%.0fk Free=%.0fk",$2,$4)}'`
string="`hostname` ${IP} tx:$TKBPS kb/s rx:$RKBPS kb/s CPU=${CPU}% FreeMem=${freemem}% ${memtop}"
# echo ".$string." >> /var/log/osd
/system/sdcard/bin/setconf -k o -v "${string}"
R1=`cat /sys/class/net/${IF}/statistics/rx_bytes`
T1=`cat /sys/class/net/${IF}/statistics/tx_bytes`
sleep 1
R2=`cat /sys/class/net/${IF}/statistics/rx_bytes`
T2=`cat /sys/class/net/${IF}/statistics/tx_bytes`
TBPS=$(($T2-$T1))
RBPS=$(($R2-$R1))
TKBPS=$(($TBPS/1024))
RKBPS=$(($RBPS/1024))
IP=`ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'`
# CPU=`grep 'cpu ' /proc/stat | awk '{ printf("%.0f", ($2+$4)*100/($2+$4+$5)) }'`
CPU=`top -n 1 | grep CPU: | grep -v grep| awk '{ print $2}'`
freemem=`free | grep Mem |grep -v grep | awk '{ printf("%.0f", $4/$2 * 100.0) }'`
memtop=`top -n 1 | grep Mem: |grep -v grep | awk '{ printf("Used=%.0fk Free=%.0fk",$2,$4)}'`
string="`hostname` ${IP} tx:$TKBPS kb/s rx:$RKBPS kb/s CPU=${CPU}% FreeMem=${freemem}% ${memtop}"
# echo ".$string." >> /var/log/osd
/system/sdcard/bin/setconf -k o -v "${string}"
done

View File

@@ -17,8 +17,8 @@ fi
# Run any user scripts.
for i in /system/sdcard/config/userscripts/motiondetection/*; do
if [ -x $i ]; then
echo "Running: $i off"
$i off
fi
if [ -x $i ]; then
echo "Running: $i off"
$i off
fi
done

View File

@@ -23,7 +23,7 @@ record_video () {
# Got the lock
debug_msg "Begin recording to $video_tempfile for $video_duration seconds"
if [ "$video_use_rtsp" = true ]; then
if [ "$video_use_rtsp" = true ]; then
output_buffer_size="$((($BITRATE*100)+150000))"
if [ -z "$USERNAME" ]; then
/system/sdcard/bin/openRTSP -4 -w "$video_rtsp_w" -h "$video_rtsp_h" -f "$video_rtsp_f" -d "$video_duration" -b "$output_buffer_size" rtsp://127.0.0.1:$PORT/unicast > "$video_tempfile"
@@ -31,19 +31,19 @@ record_video () {
/system/sdcard/bin/openRTSP -4 -w "$video_rtsp_w" -h "$video_rtsp_h" -f "$video_rtsp_f" -d "$video_duration" -b "$output_buffer_size" rtsp://$USERNAME:$USERPASSWORD@127.0.0.1:$PORT/unicast > "$video_tempfile"
fi
else
# Use avconv to stitch multiple JPEGs into 1fps video.
# I couldn't get it working another way.
# /dev/videoX inputs fail.
# Localhost rtsp takes very long (10+ seconds) to start streaming and gets flaky when when memory or cpu are pegged.
# This is a clungy method, but works well even at high res, fps, cpu, and memory load!
( while [ "$(/system/sdcard/bin/busybox date "+%s")" -le "$(/system/sdcard/bin/busybox expr "$(/system/sdcard/bin/busybox stat -c "%X" /run/recording_video.flock)" + "$video_duration")" ]; do
/system/sdcard/bin/getimage
sleep 1
done ) | /system/sdcard/bin/avconv -analyzeduration 0 -f image2pipe -r 1 -c:v mjpeg -c:a none -i - -c:v copy -c:a none -f mp4 -y "$video_tempfile"
fi
else
# Use avconv to stitch multiple JPEGs into 1fps video.
# I couldn't get it working another way.
# /dev/videoX inputs fail.
# Localhost rtsp takes very long (10+ seconds) to start streaming and gets flaky when when memory or cpu are pegged.
# This is a clungy method, but works well even at high res, fps, cpu, and memory load!
( while [ "$(/system/sdcard/bin/busybox date "+%s")" -le "$(/system/sdcard/bin/busybox expr "$(/system/sdcard/bin/busybox stat -c "%X" /run/recording_video.flock)" + "$video_duration")" ]; do
/system/sdcard/bin/getimage
sleep 1
done ) | /system/sdcard/bin/avconv -analyzeduration 0 -f image2pipe -r 1 -c:v mjpeg -c:a none -i - -c:v copy -c:a none -f mp4 -y "$video_tempfile"
fi
debug_msg "Finished recording"
debug_msg "Finished recording"
fi
}
@@ -171,30 +171,30 @@ fi
# SMB snapshot and video
if [ "$smb_snapshot" = true -o "$smb_video" = true ]; then
(
smbclient_cmd="/system/bin/smbclient $smb_share"
if [ "$smb_password" != "" ]; then
smbclient_cmd="$smbclient_cmd $smb_password"
else
smbclient_cmd="$smbclient_cmd -N"
fi
if [ "$smb_username" != "" ]; then
smbclient_cmd="$smbclient_cmd -U $smb_username"
fi
(
smbclient_cmd="/system/bin/smbclient $smb_share"
if [ "$smb_password" != "" ]; then
smbclient_cmd="$smbclient_cmd $smb_password"
else
smbclient_cmd="$smbclient_cmd -N"
fi
if [ "$smb_username" != "" ]; then
smbclient_cmd="$smbclient_cmd -U $smb_username"
fi
# Save snapshot
if [ "$smb_snapshot" = true ]; then
debug_msg "Saving SMB snapshot to $smb_share/$smb_stills_path"
snapshot_tempfilename=${snapshot_tempfile:5}
$smbclient_cmd -D "$smb_stills_path" -c "lcd /tmp; mkdir $groupname; cd $groupname; put $snapshot_tempfilename; rename $snapshot_tempfilename $filename.jpg"
fi
# Save video
if [ "$smb_video" = true ]; then
debug_msg "Saving SMB video to $smb_share/$smb_videos_path"
video_tempfilename=${video_tempfile:5}
# Save snapshot
if [ "$smb_snapshot" = true ]; then
debug_msg "Saving SMB snapshot to $smb_share/$smb_stills_path"
snapshot_tempfilename=${snapshot_tempfile:5}
$smbclient_cmd -D "$smb_stills_path" -c "lcd /tmp; mkdir $groupname; cd $groupname; put $snapshot_tempfilename; rename $snapshot_tempfilename $filename.jpg"
fi
# Save video
if [ "$smb_video" = true ]; then
debug_msg "Saving SMB video to $smb_share/$smb_videos_path"
video_tempfilename=${video_tempfile:5}
$smbclient_cmd -D "$smb_videos_path" -c "lcd /tmp; mkdir $groupname; cd $groupname; put $video_tempfilename; rename $video_tempfilename $filename.mp4"
fi
) &
fi
) &
fi
# Publish a mqtt message
@@ -243,7 +243,7 @@ if [ "$send_telegram" = true ]; then
debug_msg "Send telegram video"
if [ "$video_use_rtsp" = true ]; then
/system/sdcard/bin/telegram v "$video_tempfile"
else
else
/system/sdcard/bin/avconv -i "$video_tempfile" "$video_tempfile-lo.mp4"
/system/sdcard/bin/telegram v "$video_tempfile-lo.mp4"
rm "$video_tempfile-lo.mp4"
@@ -263,10 +263,10 @@ fi
# Run any user scripts.
for i in /system/sdcard/config/userscripts/motiondetection/*; do
if [ -x "$i" ]; then
debug_msg "Running: $i on $snapshot_tempfile"
$i on "$snapshot_tempfile" &
fi
if [ -x "$i" ]; then
debug_msg "Running: $i on $snapshot_tempfile"
$i on "$snapshot_tempfile" &
fi
done
# Wait for all background jobs to finish before existing and deleting tempfile

View File

@@ -4,15 +4,15 @@
# The screen is split as shown below
# (1,2,3,4 are the arguments of the script)
#
# +--------------------------------------+
# | | |
# | 1 | 2 |
# | | |
# +--------------------------------------+
# | | |
# | 3 | 4 |
# | | |
# +--------------------------------------+
# +--------------------------------------+
# | | |
# | 1 | 2 |
# | | |
# +--------------------------------------+
# | | |
# | 3 | 4 |
# | | |
# +--------------------------------------+
. /system/sdcard/scripts/common_functions.sh
@@ -21,25 +21,25 @@ FILECAMERAPOS=/system/sdcard/config/cameraposition
backtoOrigin() {
if [ -f ${FILECAMERAPOS} ]; then
# Get values in saved config file
origin_x_axis=`grep "x:" ${FILECAMERAPOS} | sed "s/x: //"`
origin_y_axis=`grep "y:" ${FILECAMERAPOS} | sed "s/y: //"`
else
# No such file exists: create it with the current values
/system/sdcard/bin/motor -d s > ${FILECAMERAPOS}
fi
if [ -f ${FILECAMERAPOS} ]; then
# Get values in saved config file
origin_x_axis=`grep "x:" ${FILECAMERAPOS} | sed "s/x: //"`
origin_y_axis=`grep "y:" ${FILECAMERAPOS} | sed "s/y: //"`
else
# No such file exists: create it with the current values
/system/sdcard/bin/motor -d s > ${FILECAMERAPOS}
fi
# return to origin for both axis
/system/sdcard/scripts/PTZpresets.sh $origin_x_axis $origin_y_axis
# return to origin for both axis
/system/sdcard/scripts/PTZpresets.sh $origin_x_axis $origin_y_axis
}
#################### Start ###
# If no argument that's mean the camera need to return to its original position
if [ $# -eq 0 ]; then
backtoOrigin
return 0
backtoOrigin
return 0
fi
# Display the areas ...
@@ -49,8 +49,8 @@ echo $3 $4
# Sum all the parameters, that gives the number of region detected
# Only 2 are supported
if [ $((${1} + ${2} + ${3} +${4})) -gt 2 ]; then
echo "no move: more than 2 detected regions"
return 0
echo "no move: more than 2 detected regions"
return 0
fi
UP=0
@@ -60,49 +60,49 @@ LEFT=0
# Calculate the movement
if [ "${1}" == "1" ] || [ "${2}" == "1" ]; then
UP=1
UP=1
fi
if [ "${3}" == "1" ] || [ "${4}" == "1" ]; then
DOWN=1
DOWN=1
fi
if [ "${2}" == "1" ] || [ "${4}" == "1" ]; then
RIGHT=1
RIGHT=1
fi
if [ "${1}" == "1" ] || [ "${3}" == "1" ]; then
LEFT=1
LEFT=1
fi
# Sanity checks
if [ ${UP} != 0 ] && [ ${DOWN} != 0 ]; then
echo "no move vertically: up and down at the same time"
UP=0
DOWN=0
echo "no move vertically: up and down at the same time"
UP=0
DOWN=0
fi
if [ ${RIGHT} != 0 ] && [ ${LEFT} != 0 ]; then
echo "no move horizontally: right and left at the same time"
RIGHT=0
LEFT=0
echo "no move horizontally: right and left at the same time"
RIGHT=0
LEFT=0
fi
# Do the actual movement in the background
(
if [ ${UP} == 1 ]; then
motor up ${STEPS}
fi
if [ ${UP} == 1 ]; then
motor up ${STEPS}
fi
if [ ${DOWN} == 1 ]; then
motor down ${STEPS}
fi
if [ ${DOWN} == 1 ]; then
motor down ${STEPS}
fi
if [ ${RIGHT} == 1 ]; then
motor right ${STEPS}
fi
if [ ${RIGHT} == 1 ]; then
motor right ${STEPS}
fi
if [ ${LEFT} == 1 ]; then
motor left $STEPS
fi
if [ ${LEFT} == 1 ]; then
motor left $STEPS
fi
) &>/dev/null

View File

@@ -5,34 +5,34 @@ awk '
BEGIN { OFS = "\t"; }
/\<Cell/ {
# Print previous AP
if (wpa) {
security = "WPA"
} else if (wep) {
security = "WEP"
} else {
security = "None"
}
if (essid) print essid, address, security, quality;
# Reset security flags.
wep = 0; wpa = 0;
# Print previous AP
if (wpa) {
security = "WPA"
} else if (wep) {
security = "WEP"
} else {
security = "None"
}
if (essid) print essid, address, security, quality;
# Reset security flags.
wep = 0; wpa = 0;
address = $5
address = $5
}
/\<ESSID:/ {
essid = substr($0, index($0, ":") + 1);
essid = substr(essid, 2, length(essid) - 2) # discard quotes
essid = substr($0, index($0, ":") + 1);
essid = substr(essid, 2, length(essid) - 2) # discard quotes
}
/\<Quality/ {
split($1, q, "[:=]"); # q[1] -> "Quality", q[2] -> value
split(q[2], qvalues, "/");
if (qvalues[2]) {
quality = int(qvalues[1] / qvalues[2] * 100); # we have both parts, divide
} else {
quality = qvalues[1]; # we have only one part, use it as-is
}
split($1, q, "[:=]"); # q[1] -> "Quality", q[2] -> value
split(q[2], qvalues, "/");
if (qvalues[2]) {
quality = int(qvalues[1] / qvalues[2] * 100); # we have both parts, divide
} else {
quality = qvalues[1]; # we have only one part, use it as-is
}
}
/\<Encryption key:(o|O)n/ { wep = 1 }
@@ -40,7 +40,7 @@ BEGIN { OFS = "\t"; }
/\<IE:.*WPA.*/ { wpa = 1 }
END {
# Print last AP
if (wpa) { security = "WPA" } else { if (wep) { security = "WEP" } else { security = "None" }}
if (essid) print essid, address, security, quality;
# Print last AP
if (wpa) { security = "WPA" } else { if (wep) { security = "WEP" } else { security = "None" }}
if (essid) print essid, address, security, quality;
}'

View File

@@ -4,8 +4,8 @@
while true; do
if [ -f /system/sdcard/config/ldr-average.conf ]; then
. /system/sdcard/config/ldr-average.conf 2>/dev/null
#read config in every iteration, so we can change the average online
. /system/sdcard/config/ldr-average.conf 2>/dev/null
#read config in every iteration, so we can change the average online
fi
if [ -z "$AVG" ]; then AVG=1; fi
@@ -28,9 +28,9 @@ while true; do
if [ "$AVGMEASUREMENT" -lt 50 ]; then # Light detected
night_mode off
night_mode off
else # nothing in Buffer -> no light
night_mode on
night_mode on
fi
sleep 10
done

View File

@@ -47,7 +47,7 @@
# Light Sensor
if [ "$LIGHT_SENSOR" != "false" ]; then
$MQTT_COMMAND "$AUTODISCOVERY_PREFIX/sensor/$DEVICE_NAME/light_sensor/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME light sensor\", \"unique_id\": \"$MAC_SIMPLE-light-sensor\", $DEVICE_INFO, \"icon\": \"mdi:brightness-5\", \"unit_of_measurement\": \"%\", \"state_topic\": \"$TOPIC/brightness\"}"
$MQTT_COMMAND "$AUTODISCOVERY_PREFIX/sensor/$DEVICE_NAME/light_sensor/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME light sensor\", \"unique_id\": \"$MAC_SIMPLE-light-sensor\", $DEVICE_INFO, \"icon\": \"mdi:brightness-5\", \"unit_of_measurement\": \"%\", \"state_topic\": \"$TOPIC/brightness\"}"
fi
# Night mode

View File

@@ -27,418 +27,418 @@ done
/system/sdcard/bin/mosquitto_sub.bin -v -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/# -t "${LOCATION}/set" ${MOSQUITTOOPTS} | while read -r line ; do
case $line in
"${LOCATION}/set announce")
/system/sdcard/scripts/mqtt-autodiscovery.sh
;;
"${TOPIC}/set help")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/help ${MOSQUITTOOPTS} -m "possible commands: configured topic + Yellow_LED/set on/off, configured topic + Blue_LED/set on/off, configured topic + set with the following commands: status, $(grep \)$ /system/sdcard/www/cgi-bin/action.cgi | grep -v '[=*]' | sed -e "s/ //g" | grep -v -E '(osd|setldr|settz|showlog)' | sed -e "s/)//g")"
;;
"${LOCATION}/set announce")
/system/sdcard/scripts/mqtt-autodiscovery.sh
;;
"${TOPIC}/set help")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/help ${MOSQUITTOOPTS} -m "possible commands: configured topic + Yellow_LED/set on/off, configured topic + Blue_LED/set on/off, configured topic + set with the following commands: status, $(grep \)$ /system/sdcard/www/cgi-bin/action.cgi | grep -v '[=*]' | sed -e "s/ //g" | grep -v -E '(osd|setldr|settz|showlog)' | sed -e "s/)//g")"
;;
"${TOPIC}/set status")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/ ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(/system/sdcard/scripts/mqtt-status.sh)"
;;
"${TOPIC}/set status")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/ ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(/system/sdcard/scripts/mqtt-status.sh)"
;;
"${TOPIC}/play "*)
AUDIOFILE=$(echo "$line" | awk '{print $2}')
VOLUME=$(echo "$line" | awk '{print $3}')
VOLUME=${VOLUME:-50}
/system/sdcard/bin/audioplay "/system/sdcard/media/$AUDIOFILE" "$VOLUME" $
;;
"${TOPIC}/play "*)
AUDIOFILE=$(echo "$line" | awk '{print $2}')
VOLUME=$(echo "$line" | awk '{print $3}')
VOLUME=${VOLUME:-50}
/system/sdcard/bin/audioplay "/system/sdcard/media/$AUDIOFILE" "$VOLUME" $
;;
"${TOPIC}/leds/blue")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/blue ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(blue_led status)"
;;
"${TOPIC}/leds/blue")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/blue ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(blue_led status)"
;;
"${TOPIC}/leds/blue/set ON")
blue_led on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/blue ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(blue_led status)"
;;
"${TOPIC}/leds/blue/set ON")
blue_led on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/blue ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(blue_led status)"
;;
"${TOPIC}/leds/blue/set OFF")
blue_led off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/blue ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(blue_led status)"
;;
"${TOPIC}/leds/blue/set OFF")
blue_led off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/blue ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(blue_led status)"
;;
"${TOPIC}/leds/yellow")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/yellow ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(yellow_led status)"
;;
"${TOPIC}/leds/yellow")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/yellow ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(yellow_led status)"
;;
"${TOPIC}/leds/yellow/set ON")
yellow_led on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/yellow ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(yellow_led status)"
;;
"${TOPIC}/leds/yellow/set ON")
yellow_led on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/yellow ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(yellow_led status)"
;;
"${TOPIC}/leds/yellow/set OFF")
yellow_led off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/yellow ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(yellow_led status)"
;;
"${TOPIC}/leds/yellow/set OFF")
yellow_led off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/yellow ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(yellow_led status)"
;;
"${TOPIC}/leds/ir")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/ir ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_led status)"
;;
"${TOPIC}/leds/ir")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/ir ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_led status)"
;;
"${TOPIC}/leds/ir/set ON")
ir_led on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/ir ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_led status)"
;;
"${TOPIC}/leds/ir/set ON")
ir_led on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/ir ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_led status)"
;;
"${TOPIC}/leds/ir/set OFF")
ir_led off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/ir ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_led status)"
;;
"${TOPIC}/leds/ir/set OFF")
ir_led off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/ir ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_led status)"
;;
"${TOPIC}/ir_cut")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/ir_cut ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_cut status)"
;;
"${TOPIC}/ir_cut")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/ir_cut ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_cut status)"
;;
"${TOPIC}/ir_cut/set ON")
ir_cut on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/ir_cut ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_cut status)"
;;
"${TOPIC}/ir_cut/set ON")
ir_cut on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/ir_cut ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_cut status)"
;;
"${TOPIC}/ir_cut/set OFF")
ir_cut off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/ir_cut ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_cut status)"
;;
"${TOPIC}/ir_cut/set OFF")
ir_cut off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/ir_cut ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_cut status)"
;;
"${TOPIC}/brightness")
if [ $LIGHT_SENSOR == 'hw' ]
then
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/brightness ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ldr status)"
elif [ $LIGHT_SENSOR == 'virtual' ]
then
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/brightness ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(exposure status)"
fi
;;
"${TOPIC}/brightness")
if [ $LIGHT_SENSOR == 'hw' ]
then
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/brightness ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ldr status)"
elif [ $LIGHT_SENSOR == 'virtual' ]
then
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/brightness ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(exposure status)"
fi
;;
"${TOPIC}/rtsp_h264_server")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_h264_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_h264_server status)"
;;
"${TOPIC}/rtsp_h264_server")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_h264_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_h264_server status)"
;;
"${TOPIC}/rtsp_h264_server/set ON")
rtsp_h264_server on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_h264_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_h264_server status)"
;;
"${TOPIC}/rtsp_h264_server/set ON")
rtsp_h264_server on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_h264_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_h264_server status)"
;;
"${TOPIC}/rtsp_h264_server/set OFF")
rtsp_h264_server off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_h264_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_h264_server status)"
;;
"${TOPIC}/rtsp_h264_server/set OFF")
rtsp_h264_server off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_h264_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_h264_server status)"
;;
"${TOPIC}/rtsp_mjpeg_server")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_mjpeg_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_mjpeg_server status)"
;;
"${TOPIC}/rtsp_mjpeg_server")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_mjpeg_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_mjpeg_server status)"
;;
"${TOPIC}/rtsp_mjpeg_server/set ON")
rtsp_mjpeg_server on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_mjpeg_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_mjpeg_server status)"
;;
"${TOPIC}/rtsp_mjpeg_server/set ON")
rtsp_mjpeg_server on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_mjpeg_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_mjpeg_server status)"
;;
"${TOPIC}/rtsp_mjpeg_server/set OFF")
rtsp_mjpeg_server off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_mjpeg_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_mjpeg_server status)"
;;
"${TOPIC}/rtsp_mjpeg_server/set OFF")
rtsp_mjpeg_server off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_mjpeg_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_mjpeg_server status)"
;;
"${TOPIC}/night_mode")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(night_mode status)"
;;
"${TOPIC}/night_mode")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(night_mode status)"
;;
"${TOPIC}/night_mode/set ON")
night_mode on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(night_mode status)"
;;
"${TOPIC}/night_mode/set ON")
night_mode on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(night_mode status)"
;;
"${TOPIC}/night_mode/set OFF")
night_mode off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(night_mode status)"
;;
"${TOPIC}/night_mode/set OFF")
night_mode off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(night_mode status)"
;;
"${TOPIC}/night_mode/auto")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode/auto ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(auto_night_mode status)"
;;
"${TOPIC}/night_mode/auto")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode/auto ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(auto_night_mode status)"
;;
"${TOPIC}/night_mode/auto/set ON")
auto_night_mode on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode/auto ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(auto_night_mode status)"
;;
"${TOPIC}/night_mode/auto/set ON")
auto_night_mode on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode/auto ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(auto_night_mode status)"
;;
"${TOPIC}/night_mode/auto/set OFF")
auto_night_mode off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode/auto ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(auto_night_mode status)"
;;
"${TOPIC}/night_mode/auto/set OFF")
auto_night_mode off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode/auto ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(auto_night_mode status)"
;;
"${TOPIC}/motion/detection")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/detection ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_detection status)"
;;
"${TOPIC}/motion/detection")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/detection ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_detection status)"
;;
"${TOPIC}/motion/detection/set ON")
motion_detection on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/detection ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_detection status)"
;;
"${TOPIC}/motion/detection/set ON")
motion_detection on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/detection ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_detection status)"
;;
"${TOPIC}/motion/detection/set OFF")
motion_detection off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/detection ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_detection status)"
;;
"${TOPIC}/motion/detection/set OFF")
motion_detection off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/detection ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_detection status)"
;;
"${TOPIC}/motion/led")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/led ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_led status)"
;;
"${TOPIC}/motion/led")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/led ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_led status)"
;;
"${TOPIC}/motion/led/set ON")
motion_led on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/led ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_led status)"
;;
"${TOPIC}/motion/led/set ON")
motion_led on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/led ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_led status)"
;;
"${TOPIC}/motion/led/set OFF")
motion_led off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/led ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_led status)"
;;
"${TOPIC}/motion/led/set OFF")
motion_led off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/led ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_led status)"
;;
"${TOPIC}/motion/snapshot")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_snapshot status)"
;;
"${TOPIC}/motion/snapshot")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_snapshot status)"
;;
"${TOPIC}/motion/snapshot/set ON")
motion_snapshot on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_snapshot status)"
;;
"${TOPIC}/motion/snapshot/set ON")
motion_snapshot on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_snapshot status)"
;;
"${TOPIC}/motion/snapshot/set OFF")
motion_snapshot off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_snapshot status)"
;;
"${TOPIC}/motion/snapshot/set OFF")
motion_snapshot off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_snapshot status)"
;;
"${TOPIC}/motion/video")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/video ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_video status)"
;;
"${TOPIC}/motion/video")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/video ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_video status)"
;;
"${TOPIC}/motion/video/set ON")
motion_video on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/video ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_video status)"
;;
"${TOPIC}/motion/video/set ON")
motion_video on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/video ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_video status)"
;;
"${TOPIC}/motion/video/set OFF")
motion_video off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/video ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_video status)"
;;
"${TOPIC}/motion/video/set OFF")
motion_video off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/video ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_video status)"
;;
"${TOPIC}/motion/mqtt_publish")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_publish ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_publish status)"
;;
"${TOPIC}/motion/mqtt_publish")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_publish ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_publish status)"
;;
"${TOPIC}/motion/mqtt_publish/set ON")
motion_mqtt_publish on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_publish ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_publish status)"
;;
"${TOPIC}/motion/mqtt_publish/set ON")
motion_mqtt_publish on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_publish ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_publish status)"
;;
"${TOPIC}/motion/mqtt_publish/set OFF")
motion_mqtt_publish off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_publish ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_publish status)"
;;
"${TOPIC}/motion/mqtt_publish/set OFF")
motion_mqtt_publish off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_publish ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_publish status)"
;;
"${TOPIC}/motion/mqtt_snapshot")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_snapshot status)"
;;
"${TOPIC}/snapshot/image GET")
/system/sdcard/bin/getimage > "/tmp/mqtt_snapshot"
/system/sdcard/bin/jpegoptim -S 25k "/tmp/mqtt_snapshot"
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/snapshot/image ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -f "/tmp/mqtt_snapshot"
rm "/tmp/mqtt_snapshot"
;;
"${TOPIC}/motion/mqtt_snapshot")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_snapshot status)"
;;
"${TOPIC}/snapshot/image GET")
/system/sdcard/bin/getimage > "/tmp/mqtt_snapshot"
/system/sdcard/bin/jpegoptim -S 25k "/tmp/mqtt_snapshot"
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/snapshot/image ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -f "/tmp/mqtt_snapshot"
rm "/tmp/mqtt_snapshot"
;;
"${TOPIC}/motion/mqtt_snapshot/set ON")
motion_mqtt_snapshot on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_snapshot status)"
;;
"${TOPIC}/motion/mqtt_snapshot/set ON")
motion_mqtt_snapshot on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_snapshot status)"
;;
"${TOPIC}/motion/mqtt_snapshot/set OFF")
motion_mqtt_snapshot off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_snapshot status)"
;;
"${TOPIC}/motion/mqtt_snapshot/set OFF")
motion_mqtt_snapshot off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_snapshot status)"
;;
"${TOPIC}/motion/send_mail")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_mail status)"
;;
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_mail status)"
;;
"${TOPIC}/motion/send_mail/set ON")
motion_send_mail on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_mail status)"
;;
"${TOPIC}/motion/send_mail/set ON")
motion_send_mail on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_mail status)"
;;
"${TOPIC}/motion/send_mail/set OFF")
motion_send_mail off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_mail status)"
;;
"${TOPIC}/motion/send_mail/set OFF")
motion_send_mail off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_mail status)"
;;
"${TOPIC}/motion/send_telegram")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_telegram ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_telegram status)"
;;
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_telegram ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_telegram status)"
;;
"${TOPIC}/motion/send_telegram/set ON")
motion_send_telegram on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_telegram ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_telegram status)"
;;
"${TOPIC}/motion/send_telegram/set ON")
motion_send_telegram on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_telegram ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_telegram status)"
;;
"${TOPIC}/motion/send_telegram/set OFF")
motion_send_telegram off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_telegram ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_telegram status)"
;;
"${TOPIC}/motion/send_telegram/set OFF")
motion_send_telegram off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_telegram ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_telegram status)"
;;
"${TOPIC}/motion/tracking")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/tracking ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_tracking status)"
;;
"${TOPIC}/motion/tracking")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/tracking ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_tracking status)"
;;
"${TOPIC}/motion/tracking/set ON")
motion_tracking on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/tracking ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_tracking status)"
;;
"${TOPIC}/motion/tracking/set ON")
motion_tracking on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/tracking ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_tracking status)"
;;
"${TOPIC}/motion/tracking/set OFF")
motion_tracking off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/tracking ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_tracking status)"
;;
"${TOPIC}/motion/tracking/set OFF")
motion_tracking off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/tracking ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_tracking status)"
;;
"${TOPIC}/motors/vertical/set up")
motor up
"${TOPIC}/motors/vertical/set up")
motor up
MOTORSTATE=$(motor status vertical)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_Y - $MOTORSTATE)
else
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;
"${TOPIC}/motors/vertical/set down")
motor down
"${TOPIC}/motors/vertical/set down")
motor down
MOTORSTATE=$(motor status vertical)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_Y - $MOTORSTATE)
else
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;
"${TOPIC}/motors/vertical/set "*)
COMMAND=$(echo "$line" | awk '{print $2}')
MOTORSTATE=$(motor status vertical)
if [ -n "$COMMAND" ] && [ "$COMMAND" -eq "$COMMAND" ] 2>/dev/null; then
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
echo Changing motor from $COMMAND to $MOTORSTATE
TARGET=$(busybox expr $MOTORSTATE + $COMMAND - $MAX_Y)
else
echo Changing motor from $MOTORSTATE to $COMMAND
TARGET=$(busybox expr $COMMAND - $MOTORSTATE)
fi
echo Moving $TARGET
if [ "$TARGET" -lt 0 ]; then
motor down $(busybox expr $TARGET \* -1)
else
motor up $TARGET
fi
else
echo Requested $COMMAND is not a number
fi
;;
"${TOPIC}/motors/vertical/set "*)
COMMAND=$(echo "$line" | awk '{print $2}')
MOTORSTATE=$(motor status vertical)
if [ -n "$COMMAND" ] && [ "$COMMAND" -eq "$COMMAND" ] 2>/dev/null; then
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
echo Changing motor from $COMMAND to $MOTORSTATE
TARGET=$(busybox expr $MOTORSTATE + $COMMAND - $MAX_Y)
else
echo Changing motor from $MOTORSTATE to $COMMAND
TARGET=$(busybox expr $COMMAND - $MOTORSTATE)
fi
echo Moving $TARGET
if [ "$TARGET" -lt 0 ]; then
motor down $(busybox expr $TARGET \* -1)
else
motor up $TARGET
fi
else
echo Requested $COMMAND is not a number
fi
;;
"${TOPIC}/motors/horizontal/set left")
motor left
"${TOPIC}/motors/horizontal/set left")
motor left
MOTORSTATE=$(motor status horizontal)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_X - $MOTORSTATE)
else
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;
"${TOPIC}/motors/horizontal/set right")
motor right
"${TOPIC}/motors/horizontal/set right")
motor right
MOTORSTATE=$(motor status horizontal)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_X - $MOTORSTATE)
else
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;
"${TOPIC}/motors/horizontal/set "*)
COMMAND=$(echo "$line" | awk '{print $2}')
MOTORSTATE=$(motor status horizontal)
if [ -n "$COMMAND" ] && [ "$COMMAND" -eq "$COMMAND" ] 2>/dev/null; then
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
echo Changing motor from $COMMAND to $MOTORSTATE
TARGET=$(busybox expr $MOTORSTATE + $COMMAND - $MAX_X)
else
echo Changing motor from $MOTORSTATE to $COMMAND
TARGET=$(busybox expr $COMMAND - $MOTORSTATE)
fi
echo Moving $TARGET
if [ "$TARGET" -lt 0 ]; then
motor left $(busybox expr $TARGET \* -1)
else
motor right $TARGET
fi
else
echo Requested $COMMAND is not a number
fi
;;
"${TOPIC}/motors/horizontal/set "*)
COMMAND=$(echo "$line" | awk '{print $2}')
MOTORSTATE=$(motor status horizontal)
if [ -n "$COMMAND" ] && [ "$COMMAND" -eq "$COMMAND" ] 2>/dev/null; then
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
echo Changing motor from $COMMAND to $MOTORSTATE
TARGET=$(busybox expr $MOTORSTATE + $COMMAND - $MAX_X)
else
echo Changing motor from $MOTORSTATE to $COMMAND
TARGET=$(busybox expr $COMMAND - $MOTORSTATE)
fi
echo Moving $TARGET
if [ "$TARGET" -lt 0 ]; then
motor left $(busybox expr $TARGET \* -1)
else
motor right $TARGET
fi
else
echo Requested $COMMAND is not a number
fi
;;
"${TOPIC}/motors/set calibrate")
motor reset_pos_count
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motor status horizontal)"
;;
"${TOPIC}/motors/set calibrate")
motor reset_pos_count
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motor status horizontal)"
;;
"${TOPIC}/remount_sdcard/set ON")
remount_sdcard
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/remount_sdcard ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "Remounting the SD Card"
;;
"${TOPIC}/remount_sdcard/set ON")
remount_sdcard
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/remount_sdcard ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "Remounting the SD Card"
;;
"${TOPIC}/reboot/set ON")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/reboot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "Rebooting the System"
reboot_system
;;
"${TOPIC}/reboot/set ON")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/reboot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "Rebooting the System"
reboot_system
;;
"${TOPIC}/recording")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/recording ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(recording status)"
;;
"${TOPIC}/recording")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/recording ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(recording status)"
;;
"${TOPIC}/recording/set ON")
recording on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/recording ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(recording status)"
;;
"${TOPIC}/recording/set ON")
recording on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/recording ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(recording status)"
;;
"${TOPIC}/recording/set OFF")
recording off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/recording ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(recording status)"
;;
"${TOPIC}/recording/set OFF")
recording off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/recording ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(recording status)"
;;
"${TOPIC}/snapshot/set ON")
snapshot
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/snapshot ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -f "$filename"
;;
"${TOPIC}/snapshot/set ON")
snapshot
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/snapshot ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -f "$filename"
;;
"${TOPIC}/update/set update")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/update ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -m "Upgrade started"
result=$(/bin/sh /system/sdcard/autoupdate.sh -s -v -f)
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/update ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -m "Upgrade finish: ${result}"
;;
"${TOPIC}/update/set update")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/update ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -m "Upgrade started"
result=$(/bin/sh /system/sdcard/autoupdate.sh -s -v -f)
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/update ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -m "Upgrade finish: ${result}"
;;
"${TOPIC}/set "*)
COMMAND=$(echo "$line" | awk '{print $2}')
#echo "$COMMAND"
F_cmd="${COMMAND}" /system/sdcard/www/cgi-bin/action.cgi -o /dev/null 2>/dev/null
if [ $? -eq 0 ]; then
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}/${COMMAND}" ${MOSQUITTOOPTS} -m "OK (this means: action.cgi invoke with parameter ${COMMAND}, nothing more, nothing less)"
else
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}/error" ${MOSQUITTOOPTS} -m "An error occured when executing ${line}"
fi
# Publish updated states
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(/system/sdcard/scripts/mqtt-status.sh)"
;;
"${TOPIC}/set "*)
COMMAND=$(echo "$line" | awk '{print $2}')
#echo "$COMMAND"
F_cmd="${COMMAND}" /system/sdcard/www/cgi-bin/action.cgi -o /dev/null 2>/dev/null
if [ $? -eq 0 ]; then
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}/${COMMAND}" ${MOSQUITTOOPTS} -m "OK (this means: action.cgi invoke with parameter ${COMMAND}, nothing more, nothing less)"
else
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}/error" ${MOSQUITTOOPTS} -m "An error occured when executing ${line}"
fi
# Publish updated states
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(/system/sdcard/scripts/mqtt-status.sh)"
;;
esac
done

View File

@@ -15,10 +15,10 @@ do
if [ $LIGHT_SENSOR == 'hw' ]
then
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/brightness ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(ldr status)"
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/brightness ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(ldr status)"
elif [ $LIGHT_SENSOR == 'virtual' ]
then
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/brightness ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(exposure status)"
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/brightness ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(exposure status)"
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_h264_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(rtsp_h264_server status)"
@@ -37,16 +37,16 @@ do
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/recording ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(recording status)"
MOTORSTATE=$(motor status vertical)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_Y - $MOTORSTATE)
TARGET=$(busybox expr $MAX_Y - $MOTORSTATE)
else
TARGET=$MOTORSTATE
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$TARGET"
MOTORSTATE=$(motor status horizontal)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_X - $MOTORSTATE)
TARGET=$(busybox expr $MAX_X - $MOTORSTATE)
else
TARGET=$MOTORSTATE
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$TARGET"
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}" ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -r -m "$(/system/sdcard/scripts/mqtt-status.sh)"

View File

@@ -38,28 +38,28 @@ Content-Disposition: inline
${BODY}
"
for i in $(seq 1 ${NUMBEROFPICTURES}); do
# using sleep and wait so each step takes the specified amount of time
# instead of the loop-time + the time between snapshots
if [ ${i} -lt ${NUMBEROFPICTURES} ]; then
sleep ${TIMEBETWEENSNAPSHOT} &
fi
# using sleep and wait so each step takes the specified amount of time
# instead of the loop-time + the time between snapshots
if [ ${i} -lt ${NUMBEROFPICTURES} ]; then
sleep ${TIMEBETWEENSNAPSHOT} &
fi
printf '%s\n' "--${boundary}
printf '%s\n' "--${boundary}
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"${FILENAME}${i}.jpg\"
"
if [ ${QUALITY} -eq -1 ]; then
/system/sdcard/bin/getimage | /system/sdcard/bin/openssl enc -base64
else
/system/sdcard/bin/getimage | /system/sdcard/bin/jpegoptim -m${QUALITY} --stdin --stdout --quiet | /system/sdcard/bin/openssl enc -base64
fi
if [ ${QUALITY} -eq -1 ]; then
/system/sdcard/bin/getimage | /system/sdcard/bin/openssl enc -base64
else
/system/sdcard/bin/getimage | /system/sdcard/bin/jpegoptim -m${QUALITY} --stdin --stdout --quiet | /system/sdcard/bin/openssl enc -base64
fi
echo
echo
# wait for our sleep to finish
wait
# wait for our sleep to finish
wait
done
# print last boundary with closing --

View File

@@ -56,17 +56,17 @@ respond() {
cmd=$1
[ $chatId -lt 0 ] && cmd=${1%%@*}
case $cmd in
/mem) sendMem;;
/shot) sendShot;;
/on) detectionOn;;
/off) detectionOff;;
/nighton) nightOn;;
/nightoff) nightOff;;
/textalerts) textAlerts;;
/imagealerts) imageAlerts;;
/videoalerts) videoAlerts;;
/help | /start) $TELEGRAM m "######### Bot commands #########\n# /mem - show memory information\n# /shot - take a snapshot\n# /on - motion detection on\n# /off - motion detection off\n# /nighton - night mode on\n# /nightoff - night mode off\n# /textalerts - Text alerts on motion detection\n# /imagealerts - Image alerts on motion detection\n# /videoalerts - Video alerts on motion detection";;
*) $TELEGRAM m "I can't respond to '$cmd' command"
/mem) sendMem;;
/shot) sendShot;;
/on) detectionOn;;
/off) detectionOff;;
/nighton) nightOn;;
/nightoff) nightOff;;
/textalerts) textAlerts;;
/imagealerts) imageAlerts;;
/videoalerts) videoAlerts;;
/help | /start) $TELEGRAM m "######### Bot commands #########\n# /mem - show memory information\n# /shot - take a snapshot\n# /on - motion detection on\n# /off - motion detection off\n# /nighton - night mode on\n# /nightoff - night mode off\n# /textalerts - Text alerts on motion detection\n# /imagealerts - Image alerts on motion detection\n# /videoalerts - Video alerts on motion detection";;
*) $TELEGRAM m "I can't respond to '$cmd' command"
esac
}
@@ -86,9 +86,9 @@ main() {
[ -z "$json" ] && return 0
if [ "$(echo "$json" | $JQ -r '.ok')" != "true" ]; then
echo "$(date '+%F %T') Bot error: $json" >> /tmp/telegram.log
[ "$(echo "$json" | $JQ -r '.error_code')" == "401" ] && return 1
return 0
echo "$(date '+%F %T') Bot error: $json" >> /tmp/telegram.log
[ "$(echo "$json" | $JQ -r '.error_code')" == "401" ] && return 1
return 0
fi;
messageAttr="message"
@@ -96,9 +96,9 @@ main() {
[ -z "$messageVal" ] && messageAttr="edited_message"
chatId=$(echo "$json" | $JQ -r ".result[0].$messageAttr.chat.id // \"\"")
updateId=$(echo "$json" | $JQ -r '.result[0].update_id // ""')
if [ "$updateId" != "" ] && [ -z "$chatId" ]; then
markAsRead $updateId
return 0
if [ "$updateId" != "" ] && [ -z "$chatId" ]; then
markAsRead $updateId
return 0
fi;
[ -z "$chatId" ] && return 0 # no new messages
@@ -106,11 +106,11 @@ main() {
cmd=$(echo "$json" | $JQ -r ".result[0].$messageAttr.text // \"\"")
if [ "$chatId" != "$userChatId" ]; then
username=$(echo "$json" | $JQ -r ".result[0].$messageAttr.from.username // \"\"")
firstName=$(echo "$json" | $JQ -r ".result[0].$messageAttr.from.first_name // \"\"")
$TELEGRAM m "Received message from unauthorized chat id: $chatId\nUser: $username($firstName)\nMessage: $cmd"
username=$(echo "$json" | $JQ -r ".result[0].$messageAttr.from.username // \"\"")
firstName=$(echo "$json" | $JQ -r ".result[0].$messageAttr.from.first_name // \"\"")
$TELEGRAM m "Received message from unauthorized chat id: $chatId\nUser: $username($firstName)\nMessage: $cmd"
else
respond $cmd
respond $cmd
fi;
markAsRead $updateId

View File

@@ -5,10 +5,9 @@
PIDFILE='/run/timelapse.pid'
TIMELAPSE_CONF='/system/sdcard/config/timelapse.conf'
DCIM_PATH='/system/sdcard/DCIM/Timelapse'
if [ -f "$TIMELAPSE_CONF" ]; then
. "$TIMELAPSE_CONF" 2>/dev/null
. "$TIMELAPSE_CONF" 2>/dev/null
fi
if [ -z "$TIMELAPSE_INTERVAL" ]; then TIMELAPSE_INTERVAL=2.0; fi
@@ -21,36 +20,36 @@ last_prefix=''
ts_started=$(date +%s)
while true; do
SAVE_DIR=$DCIM_PATH
if [ $SAVE_DIR_PER_DAY -eq 1 ]; then
SAVE_DIR="$DCIM_PATH/$(date +%Y-%m-%d)/$(date +%H)"
fi
if [ ! -d "$SAVE_DIR" ]; then
mkdir -p $SAVE_DIR
fi
filename_prefix="$(date +%Y-%m-%d_%H-%M-%S)"
if [ "$filename_prefix" = "$last_prefix" ]; then
counter=$(($counter + 1))
else
counter=1
last_prefix="$filename_prefix"
fi
counter_formatted=$(printf '%03d' $counter)
filename="${filename_prefix}_${counter_formatted}.jpg"
if [ -z "$COMPRESSION_QUALITY" ]; then
/system/sdcard/bin/getimage > "$SAVE_DIR/$filename" &
else
/system/sdcard/bin/getimage | /system/sdcard/bin/jpegoptim -m"$COMPRESSION_QUALITY" --stdin --stdout > "$SAVE_DIR/$filename" &
fi
sleep $TIMELAPSE_INTERVAL
SAVE_DIR=$DCIM_PATH
if [ $SAVE_DIR_PER_DAY -eq 1 ]; then
SAVE_DIR="$DCIM_PATH/$(date +%Y-%m-%d)/$(date +%H)"
fi
if [ ! -d "$SAVE_DIR" ]; then
mkdir -p $SAVE_DIR
fi
filename_prefix="$(date +%Y-%m-%d_%H-%M-%S)"
if [ "$filename_prefix" = "$last_prefix" ]; then
counter=$(($counter + 1))
else
counter=1
last_prefix="$filename_prefix"
fi
counter_formatted=$(printf '%03d' $counter)
filename="${filename_prefix}_${counter_formatted}.jpg"
if [ -z "$COMPRESSION_QUALITY" ]; then
/system/sdcard/bin/getimage > "$SAVE_DIR/$filename" &
else
/system/sdcard/bin/getimage | /system/sdcard/bin/jpegoptim -m"$COMPRESSION_QUALITY" --stdin --stdout > "$SAVE_DIR/$filename" &
fi
sleep $TIMELAPSE_INTERVAL
if [ $TIMELAPSE_DURATION -gt 0 ]; then
ts_now=$(date +%s)
elapsed=$(($ts_now - $ts_started))
if [ $(($TIMELAPSE_DURATION * 60)) -le $elapsed ]; then
break
fi
fi
if [ $TIMELAPSE_DURATION -gt 0 ]; then
ts_now=$(date +%s)
elapsed=$(($ts_now - $ts_started))
if [ $(($TIMELAPSE_DURATION * 60)) -le $elapsed ]; then
break
fi
fi
done
# loop completed so let's purge pid file

View File

@@ -0,0 +1,54 @@
//Function save config
function saveConfig(elements) {
//Open modal window
document.getElementById('save_confirm').style.display='block'
$('#save_result').html("Waiting for save result...");
var postData = { cmd: "save_config" }
$("#"+elements+" input, #"+elements+" select").each(function(){
var input = $(this);
postData[input.attr('id')] = input.val();
});
$.post("cgi-bin/camera.cgi",postData,function(result){
if ( result != "")
$('#save_result').html(result);
else
$('#save_result').html("Nothing to update");
});
}
//Function get config
function getConfig() {
// get config and put to hmtl elements
$.get("cgi-bin/camera.cgi", {cmd: "get_config"}, function(config){
var config_all = config.split("\n");
for (var i = 0; i < config_all.length-1; i++) {
var config_info = config_all[i].split("#:#");
// If element is a select, selected good value
if (config_info[0] == "osdFonts") {
$('#'+config_info[0]).html(config_info[1]);
}
else if ($('#'+config_info[0]).is('select'))
$('#'+config_info[0]+' > option').each(function() {
if($(this).val() == config_info[1])
$(this).attr('selected','selected');
});
else
$('#'+config_info[0]).attr("value",config_info[1]);
}
});
}
//Function loaded when script load
function onLoad() {
//Activate accordion
accordion();
//Get configuration
getConfig();
}
onLoad();

View File

@@ -28,7 +28,7 @@ function update(onStart) {
$('#progressValue').html(log+'%');
// This is the end, start the reboot count down
if (log >= 100) {
timedRefresh(45);
timedRefresh(30);
} else {
setTimeout(update, 500);
}

View File

@@ -5,7 +5,7 @@
function timedRefresh(timeoutPeriod) {
timeoutPeriod -= 1;
$('#message').text("Rebooting ... wait..." + timeoutPeriod);
$('#message').text("Rebooting ... please wait..." + timeoutPeriod);
if (timeoutPeriod == 0) {
window.location.href = window.location.href;
@@ -35,7 +35,7 @@
$('#progress').val(log);
// This is the end, start the reboot count down
if (log >= 100) {
timedRefresh(45);
timedRefresh(30);
} else {
setTimeout(update, 500);
}