diff --git a/firmware_mod/autoupdate.sh b/firmware_mod/autoupdate.sh
index b826a8e..555cfac 100755
--- a/firmware_mod/autoupdate.sh
+++ b/firmware_mod/autoupdate.sh
@@ -12,7 +12,7 @@ BRANCH="master"
# Initial remote folder
REMOTEFOLDER="firmware_mod"
# Default destination foler
-DESTFOLDER="./"
+DESTFOLDER="/system/sdcard/"
DESTOVERRIDE="/tmp/Update"
# The list of exclude, can have multple filter with "*.conf|*.sh"
EXCLUDEFILTER="*.conf|*.user"
@@ -22,6 +22,7 @@ CURL="/system/sdcard/bin/curl -k"
JQ="/system/sdcard/bin/jq"
SHA="/system/sdcard/bin/openssl dgst -sha256"
BASENAME="/system/sdcard/bin/busybox basename"
+FIND="/system/sdcard/bin/busybox find"
TMPFILE=/tmp/udpate.tmp
BACKUPEXT=.backup
@@ -30,6 +31,10 @@ _V=0
_FORCE=0
_FORCEREBOOT=0
_BACKUP=0
+
+_PROGRESS=0
+_NBFILES=0
+_NBTOTALFILES=0
##########################################################################
usage()
@@ -42,6 +47,7 @@ usage()
echo "-f (--force) force update"
echo "-d (--dest) set the destination folder (default is ${DESTFOLDER})"
echo "-p (--print) print action only, do nothing"
+ echo "-s (--steps) add progress in file /tmp/progress"
echo "-v (--verbose) for verbose"
echo "-u (--user) githup login/password (not mandatory, but sometime anonymous account get banned)"
@@ -80,6 +86,17 @@ logerror ()
echo "$@" 1>&2
}
+##########################################################################
+# Log string on std error
+progress()
+{
+ if [ ${_PROGRESS} -eq 1 ]; then
+ _NBFILES=$((${_NBFILES} + 1))
+ echo -n $((${_NBFILES} *100 / ${_NBTOTALFILES} )) > /tmp/progress
+# echo "file = ${_NBFILES}, total=${_NBTOTALFILES} = $((${_NBFILES} *100 / ${_NBTOTALFILES} ))"
+ fi
+}
+
##########################################################################
# If "printonly" action is selected print the action to do (but don't do it
# If not execute it
@@ -107,6 +124,13 @@ ismatch()
echo notmatch
}
+##########################################################################
+# Return the current (last) commit from the specified repo and branch
+getCurrentCommitDateFromRemote()
+{
+ LASTCOMMITDATE=$(${CURL} -s ${GITHUBURL}/${REPO}/commits/${BRANCH} | grep date | head -1 | cut -d'"' -f 4)
+ echo ${LASTCOMMITDATE}
+}
##########################################################################
# Print the files from repo of the folder $1
@@ -140,6 +164,8 @@ countdownreboot()
i=$((${i} - 1))
sleep 1;
done
+ action sync
+ action sync
action reboot
}
##########################################################################
@@ -178,6 +204,10 @@ do
shift
shift
;;
+ -s | --steps)
+ _PROGRESS=1;
+ shift
+ ;;
*|-h |\? | --help)
usage $0
exit 1
@@ -201,12 +231,22 @@ fi
action "rm -rf ${DESTOVERRIDE} 2>/dev/null"
+
+
log "Getting list of remote files."
FIRST=$(${CURL} -s ${GITHUBURL}/${REPO}/contents/${REMOTEFOLDER}?ref=${BRANCH})
FILES=$(getfiles "${FIRST}")
+
+if [ $_PROGRESS = 1 ]; then
+ _NBTOTALFILES=$(echo $FILES | wc -w)
+ log Number of file to update $_NBTOTALFILES
+ echo -n 0 > /tmp/progress
+fi
+
# For all the repository files
for i in ${FILES}
do
+ progress
# String to remove to get the local path
REMOVE="${GITHUBURLRAW}/${REPO}/${BRANCH}/${REMOTEFOLDER}/"
LOCALFILE="${DESTFOLDER}${i#$REMOVE}"
@@ -242,7 +282,7 @@ do
action mv ${TMPFILE} ${DESTOVERRIDE}/${LOCALFILE}
else
echo "${LOCALFILE} needs to be updated. Overwrite?"
- echo "[Y]es or [N]o or [A]ll?"
+ echo "[Y]es or [N]o or [A]ll?"
rep=$(ask_yes_or_no )
if [ "${rep}" = "no" ]; then
echo "${LOCALFILE} not updated"
@@ -283,6 +323,11 @@ do
fi
done
+if [ $_PROGRESS = 1 ]; then
+ echo -n 100 > /tmp/progress
+fi
+
+
if [ -d ${DESTOVERRIDE} ] && [ $(ls -l ${DESTOVERRIDE}/* | wc -l 2>/dev/null) > 1 ]; then
echo "--------------- Stopping services ---------"
for i in /system/sdcard/controlscripts/*; do
@@ -296,6 +341,8 @@ if [ -d ${DESTOVERRIDE} ] && [ $(ls -l ${DESTOVERRIDE}/* | wc -l 2>/dev/null) >
action "cp -Rf ${DESTOVERRIDE}/* ${DESTFOLDER} 2>/dev/null"
action "rm -Rf ${DESTOVERRIDE}/* 2>/dev/null"
+ # Everythings was OK, save the date
+ echo $(getCurrentCommitDateFromRemote) > /system/sdcard/.lastCommitDate
echo "--------------- Reboot ------------"
if [ ${_FORCEREBOOT} = 1 ]; then
countdownreboot
@@ -308,5 +355,6 @@ if [ -d ${DESTOVERRIDE} ] && [ $(ls -l ${DESTOVERRIDE}/* | wc -l 2>/dev/null) >
fi
fi
else
+ echo $(getCurrentCommitDateFromRemote) > /system/sdcard/.lastCommitDate
echo "No files to update."
fi
diff --git a/firmware_mod/bin/v4l2rtspserver-master b/firmware_mod/bin/v4l2rtspserver-master
index 9409c05..5fd2f57 100755
Binary files a/firmware_mod/bin/v4l2rtspserver-master and b/firmware_mod/bin/v4l2rtspserver-master differ
diff --git a/firmware_mod/www/cgi-bin/action.cgi b/firmware_mod/www/cgi-bin/action.cgi
index f00c6a0..16b5673 100755
--- a/firmware_mod/www/cgi-bin/action.cgi
+++ b/firmware_mod/www/cgi-bin/action.cgi
@@ -35,6 +35,10 @@ if [ -n "$F_cmd" ]; then
echo "Contents of v4l2rtspserver-master.log
"
cat /system/sdcard/log/v4l2rtspserver-master.log
;;
+ 5)
+ echo "Contents of update.log
"
+ cat /var/log/update.log
+ ;;
esac
echo ""
@@ -62,6 +66,10 @@ if [ -n "$F_cmd" ]; then
echo "Contents of v4l2rtspserver-master.log cleared
"
echo -n "" > /system/sdcard/log/v4l2rtspserver-master.log
;;
+ 5)
+ echo "Contents of update.log cleared
"
+ echo -n "" > /var/log/update.log
+ ;;
esac
echo ""
return
@@ -387,10 +395,6 @@ if [ -n "$F_cmd" ]; then
/system/sdcard/bin/setconf -k t -v on
fi
- # echo "region_of_interest=${F_x0},${F_y0},${F_x1},${F_y1}" > /system/sdcard/config/motion.conf
- # echo "motion_sensitivity=${F_motion_sensitivity}" >> /system/sdcard/config/motion.conf
- # echo "motion_indicator_color=${F_motion_indicator_color}" >> /system/sdcard/config/motion.conf
-
/system/sdcard/bin/setconf -k r -v ${F_x0},${F_y0},${F_x1},${F_y1}
/system/sdcard/bin/setconf -k m -v ${F_motion_sensitivity}
/system/sdcard/bin/setconf -k z -v ${F_motion_indicator_color}
@@ -399,26 +403,13 @@ if [ -n "$F_cmd" ]; then
# Changed the detection region, need to restart the server
if [ ${F_restart_server} == "1" ]
then
-
- processName="v4l2rtspserver-master"
- #get the process pid
- processId=`ps | grep ${processName} | grep -v grep | awk '{ printf $1 }'`
- if [ "${processId}X" != "X" ]
- then
- #found the process, now get the full path and the parameters in order to restart it
- executable=`ls -l /proc/${processId}/exe | awk '{print $NF}'`
- cmdLine=`tr '\0' ' ' < /proc/${processId}/cmdline | awk '{$1=""}1'`
- kill ${processId} 2>/dev/null
-
- # Set the socket option in order to restart easily the server (socket in use)
- echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
-
- sleep 2
- cmdLine="/system/sdcard/bin/busybox nohup "${executable}${cmdLine} 2>/dev/null
- ${cmdLine} 2>/dev/null >/dev/null &
-
- else
- echo "
process v4l2rtspserver-master was not found
" + if [ "$(rtsp_h264_server status)" = "ON" ]; then + rtsp_h264_server off + rtsp_h264_server on + fi + if [ "$(rtsp_mjpeg_server status)" = "ON" ]; then + rtsp_mjpeg_server off + rtsp_mjpeg_server on fi fi @@ -480,7 +471,37 @@ if [ -n "$F_cmd" ]; then /system/sdcard/bin/setconf -k l -v "$F_HFEnabled" 2>/dev/null /system/sdcard/bin/setconf -k h -v "$F_audioinVol" 2>/dev/null return - ;; + ;; + update) + processId=$(ps | grep autoupdate.sh | grep -v grep) + if [ "$processId" == "" ] + then + echo "===============" >> /var/log/update.log + date >> /var/log/update.log + if [ "$F_login" != "" ]; then + /system/sdcard/bin/busybox nohup /system/sdcard/autoupdate.sh -s -v -f -u $F_login >> "/var/log/update.log" & + else + /system/sdcard/bin/busybox nohup /system/sdcard/autoupdate.sh -s -v -f >> "/var/log/update.log" & + fi + processId=$(ps | grep autoupdate.sh | grep -v grep) + fi + echo $processId + return + ;; + show_updateProgress) + processId=$(ps | grep autoupdate.sh | grep -v grep) + if [ "$processId" == "" ] + then + echo -n -1 + else + if [ -f /tmp/progress ] ; then + cat /tmp/progress + else + echo -n 0 + fi + fi + return + ;; *) echo "Unsupported command '$F_cmd'" ;; diff --git a/firmware_mod/www/cgi-bin/status.cgi b/firmware_mod/www/cgi-bin/status.cgi index 795bb7a..3afae3b 100755 --- a/firmware_mod/www/cgi-bin/status.cgi +++ b/firmware_mod/www/cgi-bin/status.cgi @@ -100,9 +100,9 @@ cat << EOFVersion
Version (last commit date from GitHub/autoupdate script)
$(cut -d'=' -f2 /etc/os-release)
+$(cat /system/sdcard/.lastCommitDate)
- +
+
GitHub login and password (not mandatory)
+++ +Please note that at the end of the process the camera will reboot without notice
+ + +