-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Merge] Merge branch 'dev' - WebUI updates
- Loading branch information
Showing
17 changed files
with
1,016 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ CHECK_UPDATES=yes | |
DISABLE_CLOUD=no | ||
REC_WITHOUT_CLOUD=no | ||
MQTT=no | ||
RTSP=no | ||
NTPD=no | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/sh | ||
|
||
if [ -d "/usr/yi-hack-v4" ]; then | ||
YI_HACK_PREFIX="/usr/yi-hack-v4" | ||
elif [ -d "/home/yi-hack-v4" ]; then | ||
YI_HACK_PREFIX="/home/yi-hack-v4" | ||
fi | ||
|
||
get_action_type() | ||
{ | ||
CONF="$(echo $QUERY_STRING | cut -d'=' -f1)" | ||
VAL="$(echo $QUERY_STRING | cut -d'=' -f2)" | ||
|
||
if [ $CONF == "action" ] ; then | ||
echo $VAL | ||
fi | ||
} | ||
|
||
ACTION_TYPE="$(get_action_type)" | ||
CONF_FILE="$YI_HACK_PREFIX/etc/viewd.conf" | ||
|
||
printf "Content-type: application/json\r\n\r\n" | ||
|
||
printf "{\n" | ||
|
||
if [ $ACTION_TYPE == "getconf" ] ; then | ||
|
||
while IFS= read -r LINE ; do | ||
if [ ! -z $LINE ] ; then | ||
if [ "$LINE" == "${LINE#\#}" ] ; then # skip comments | ||
printf "\"%s\",\n" $(echo "$LINE" | sed -r 's/=/":"/g') # Format to json and replace = with ":" | ||
fi | ||
fi | ||
done < "$CONF_FILE" | ||
|
||
printf "\"%s\":\"%s\",\n" "VIEWD_FILE" $(ls $YI_HACK_PREFIX/bin/viewd) | ||
printf "\"%s\":\"%s\",\n" "RTSP_FILE" $(ls $YI_HACK_PREFIX/bin/rtspv4) | ||
printf "\"%s\":\"%s\",\n" "LIC_FILE" $(ls $YI_HACK_PREFIX/etc/viewd_*.lic) | ||
printf "\"%s\":\"%s\",\n" "CAMHASH" $(camhash) | ||
printf "\"%s\":\"%s\",\n" "REMOTE_ADDR" $HTTP_HOST | ||
|
||
fi | ||
|
||
# Empty values to "close" the json | ||
printf "\"%s\":\"%s\"\n" "NULL" "NULL" | ||
|
||
printf "}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
|
||
if [ -d "/usr/yi-hack-v4" ]; then | ||
YI_HACK_PREFIX="/usr/yi-hack-v4" | ||
elif [ -d "/home/yi-hack-v4" ]; then | ||
YI_HACK_PREFIX="/home/yi-hack-v4" | ||
fi | ||
|
||
REMOTE_VERSION_FILE=/tmp/.hackremotever | ||
REMOTE_NEWVERSION_FILE=/tmp/.hacknewver | ||
|
||
LOCAL_VERSION_FILE=/home/yi-hack-v4/version | ||
|
||
IS_SD_PRESENT="NO" | ||
|
||
if grep -qs '/tmp/sd ' /proc/mounts; then | ||
IS_SD_PRESENT="YES" | ||
fi | ||
|
||
printf "Content-type: application/json\r\n\r\n" | ||
|
||
printf "{\n" | ||
|
||
printf "\"%s\":\"%s\",\n" "LOCAL_VERSION" "$(cat $LOCAL_VERSION_FILE)" | ||
printf "\"%s\":\"%s\",\n" "REMOTE_VERSION" "$(cat $REMOTE_VERSION_FILE)" | ||
printf "\"%s\":\"%s\",\n" "NEEDS_UPDATE" "$(cat $REMOTE_NEWVERSION_FILE)" | ||
printf "\"%s\":\"%s\",\n" "IS_SD_PRESENT" "$IS_SD_PRESENT" | ||
|
||
# Empty values to "close" the json | ||
printf "\"%s\":\"%s\"\n" "NULL" "NULL" | ||
|
||
printf "}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/bin/sh | ||
|
||
if [ -d "/usr/yi-hack-v4" ]; then | ||
YI_HACK_PREFIX="/usr/yi-hack-v4" | ||
elif [ -d "/home/yi-hack-v4" ]; then | ||
YI_HACK_PREFIX="/home/yi-hack-v4" | ||
fi | ||
|
||
get_file_type() | ||
{ | ||
CONF="$(echo $QUERY_STRING | cut -d'=' -f1)" | ||
VAL="$(echo $QUERY_STRING | cut -d'=' -f2)" | ||
|
||
if [ $CONF == "file" ] ; then | ||
echo $VAL | ||
fi | ||
} | ||
|
||
get_random_tmp_file() | ||
{ | ||
local CNT=5 | ||
local RND="" | ||
local TMP_FILE="" | ||
|
||
while : ; do | ||
RND=$(</dev/urandom tr -dc 0-9 | dd bs=$CNT count=1 2>/dev/null | sed -e 's/^0\+//' ) | ||
TMP_FILE="/tmp/.tmpupload.$RND" | ||
|
||
[ -f $TMP_FILE ] || break | ||
done | ||
|
||
echo $TMP_FILE | ||
} | ||
|
||
get_file_from_post() | ||
{ | ||
local FILE=$1 | ||
|
||
local CR=`printf '\r'` | ||
|
||
IFS="$CR" | ||
read -r delim_line | ||
IFS="" | ||
|
||
while read -r line; do | ||
test x"$line" = x"" && break | ||
test x"$line" = x"$CR" && break | ||
done | ||
|
||
cat > "$FILE" | ||
|
||
# We need to delete the tail of "\r\ndelim_line--\r\n" | ||
tail_len=$((${#delim_line} + 6)) | ||
|
||
# Get and check file size | ||
filesize=`ls -l "$FILE" | awk '{print $5}'` | ||
|
||
# Truncate the file | ||
dd of="$FILE" seek=$((filesize - tail_len)) bs=1 count=0 >/dev/null 2>/dev/null | ||
} | ||
|
||
printf "Content-type: application/json\r\n\r\n" | ||
|
||
FILE_TYPE="$(get_file_type)" | ||
TMP_FILE=$(get_random_tmp_file) | ||
|
||
CUT_FILE_TYPE=$(echo $FILE_TYPE | cut -d'_' -f1) | ||
|
||
if [[ "$CUT_FILE_TYPE" == "home" || "$CUT_FILE_TYPE" == "rootfs" ]] ; then | ||
# If home or rootfs image, place directly on sd card | ||
get_file_from_post "/tmp/sd/$FILE_TYPE" | ||
else | ||
get_file_from_post $TMP_FILE | ||
|
||
if [ "$FILE_TYPE" == "rtspv4__upload" ] ; then | ||
7za x "$TMP_FILE" -y -o. &>/dev/null | ||
cp -rf rtspv4__*/* $YI_HACK_PREFIX/ | ||
rm -rf rtspv4__* | ||
|
||
chmod +x $YI_HACK_PREFIX/bin/viewd | ||
chmod +x $YI_HACK_PREFIX/bin/rtspv4 | ||
else | ||
cp -f "$TMP_FILE" "$YI_HACK_PREFIX/$FILE_TYPE" | ||
fi | ||
fi | ||
|
||
rm -f $TMP_FILE | ||
|
||
printf "{\n" | ||
|
||
printf "\"%s\":\"%s\"\n" "error" "false" | ||
|
||
printf "}" | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.