-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ALARM: Fix tabs, spaces and used function files.
- Loading branch information
Frank van der Stad
committed
Jan 15, 2018
1 parent
176fba2
commit 8c7149d
Showing
5 changed files
with
79 additions
and
76 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 |
---|---|---|
@@ -1,51 +1,24 @@ | ||
#!/bin/sh | ||
|
||
# Copyright 2018 Vladimir Dronnikov | ||
# Additional enhancements: Frank van der Stad | ||
# Copyright 2018 Vladimir Dronnokov & Frank van der Stad | ||
This comment has been minimized.
Sorry, something went wrong. |
||
# GPL | ||
source ./include_functions.sh | ||
|
||
CONF_FILE="/yi-hack-v3/etc/system.conf" | ||
|
||
if [ -d "/usr/yi-hack-v3" ]; then | ||
YI_HACK_V3_PREFIX="/usr" | ||
elif [ -d "/home/yi-hack-v3" ]; then | ||
YI_HACK_V3_PREFIX="/home" | ||
fi | ||
|
||
get_config() | ||
{ | ||
key=$1 | ||
grep $1 $YI_HACK_V3_PREFIX$CONF_FILE | cut -d "=" -f2 | ||
} | ||
CAMERA_NAME=`more $YI_HACK_V3_PREFIX/yi-hack-v3/etc/hostname`; | ||
|
||
TELEGRAM_BOT_TOKEN=$(get_config TELEGRAM_BOT_TOKEN) | ||
TELEGRAM_CHAT_ID=$(get_config TELEGRAM_CHAT_ID) | ||
TELEGRAM_SILENT=0 | ||
|
||
CAMERA_NAME=`more $YI_HACK_V3_PREFIX/yi-hack-v3/etc/hostname`; | ||
|
||
curl() { | ||
LD_LIBRARY_PATH=/tmp/sd /tmp/sd/curl -k -q $@ | ||
} | ||
|
||
photo() { | ||
cp $1 /tmp/sd/record/last.jpg | ||
curl -F photo="@$1" "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendPhoto?chat_id=${TELEGRAM_CHAT_ID}&caption=$2&disable_notification=${TELEGRAM_SILENT}" | ||
} | ||
|
||
video() { | ||
cp $1 /tmp/sd/record/last.mp4 | ||
curl -F video="@$1" "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendVideo?chat_id=${TELEGRAM_CHAT_ID}&caption=$2&disable_notification=${TELEGRAM_SILENT}" | ||
} | ||
|
||
# This part is copyright 2018 Vladimir Dronnikov | ||
# GPL | ||
ALARM=0 | ||
while true; do | ||
test -r /tmp/sd/record/tmp.mp4.tmp && REC=1 || REC=0 | ||
if [ "$REC" != "$ALARM" ]; then | ||
ALARM="$REC" | ||
[ "n$ALARM" == "n0" ] && rm /tmp/temp.jpg /tmp/temp.mp4 | ||
fi | ||
[ -r /tmp/motion.jpg -a ! -r /tmp/temp.jpg ] && cp /tmp/motion.jpg /tmp/temp.jpg && echo JPG ready && photo /tmp/temp.jpg "Photo from $CAMERA_NAME" | ||
[ -r /tmp/motion.mp4 -a ! -r /tmp/temp.mp4 ] && cp /tmp/motion.mp4 /tmp/temp.mp4 && echo MP4 ready && video /tmp/temp.mp4 "Video from $CAMERA_NAME" | ||
sleep 1 | ||
test -r /tmp/sd/record/tmp.mp4.tmp && REC=1 || REC=0 | ||
if [ "$REC" != "$ALARM" ]; then | ||
ALARM="$REC" | ||
[ "n$ALARM" == "n0" ] && rm /tmp/temp.jpg /tmp/temp.mp4 | ||
fi | ||
[ -r /tmp/motion.jpg -a ! -r /tmp/temp.jpg ] && cp /tmp/motion.jpg /tmp/temp.jpg && echo JPG ready && photo /tmp/temp.jpg "Photo from $CAMERA_NAME" | ||
[ -r /tmp/motion.mp4 -a ! -r /tmp/temp.mp4 ] && cp /tmp/motion.mp4 /tmp/temp.mp4 && echo MP4 ready && video /tmp/temp.mp4 "Video from $CAMERA_NAME" | ||
sleep 1 | ||
done |
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,45 @@ | ||
#!/bin/sh | ||
# Copyright 2018 Frank van der Stad | ||
# GPL | ||
CONF_FILE="/yi-hack-v3/etc/system.conf" | ||
|
||
if [ -d "/usr/yi-hack-v3" ]; then | ||
YI_HACK_V3_PREFIX="/usr" | ||
elif [ -d "/home/yi-hack-v3" ]; then | ||
YI_HACK_V3_PREFIX="/home" | ||
fi | ||
|
||
get_config() { | ||
key=$1 | ||
grep $1 $YI_HACK_V3_PREFIX$CONF_FILE | cut -d "=" -f2 | ||
} | ||
|
||
curl() { | ||
LD_LIBRARY_PATH=/tmp/sd /tmp/sd/curl -k -q $@ | ||
} | ||
|
||
photo() { | ||
message=$(urlencode $2) | ||
cp $1 /tmp/sd/record/last.jpg | ||
if [ ! -z "$TELEGRAM_BOT_TOKEN" ] | ||
then | ||
curl -F photo="@$1" "https://api.telegram.org/bot${TELEGRAM_BOT_ | ||
fi | ||
} | ||
video() { | ||
message=$(urlencode $2) | ||
cp $1 /tmp/sd/record/last.mp4 | ||
if [ ! -z "$TELEGRAM_BOT_TOKEN" ] | ||
then | ||
curl -F video="@$1" "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/s | ||
fi | ||
} | ||
|
||
|
||
|
||
|
||
urlencode() { | ||
url=$(echo "$*" | sed -e 's/%/%25/g' -e 's/ /%20/g' -e 's/!/%21/g' -e 's/"/%22/g' -e 's/#/%23/g' -e 's/\$/%24/g' -e 's/\&/%26/g' -e 's/'\''/%27/g' -e 's/(/%28/g' -e 's/)/%29/g' -e 's/\*/%2a/g' -e 's/+/%2b/g' -e 's/,/%2c/g' -e 's/-/%2d/g' -e 's/\./%2e/g' -e 's/\//%2f/g' -e 's/:/%3a/g' -e 's/;/%3b/g' -e 's//%3e/g' -e 's/?/%3f/g' -e 's/@/%40/g' -e 's/\[/%5b/g' -e 's/\\/%5c/g' -e 's/\]/%5d/g' -e 's/\^/%5e/g' -e 's/_/%5f/g' -e 's/`/%60/g' -e 's/{/%7b/g' -e 's/|/%7c/g' -e 's/}/%7d/g' -e 's/~/%7e/g') | ||
echo $url | ||
} |
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 |
---|---|---|
@@ -1,35 +1,20 @@ | ||
#!/bin/sh | ||
|
||
# Copyright 2018 Vladimir Dronnikov | ||
# Additional enhancements: Frank van der Stad | ||
# Copyright 2018 Vladimir Dronnokov & Frank van der Stad | ||
# GPL | ||
|
||
CONF_FILE="/yi-hack-v3/etc/system.conf" | ||
|
||
if [ -d "/usr/yi-hack-v3" ]; then | ||
YI_HACK_V3_PREFIX="/usr" | ||
elif [ -d "/home/yi-hack-v3" ]; then | ||
YI_HACK_V3_PREFIX="/home" | ||
fi | ||
source ./include_functions.sh | ||
|
||
CAMERA_NAME=`more $YI_HACK_V3_PREFIX/yi-hack-v3/etc/hostname`; | ||
|
||
photo() { | ||
cp $1 /tmp/sd/record/last.jpg | ||
} | ||
|
||
video() { | ||
cp $1 /tmp/sd/record/last.mp4 | ||
} | ||
|
||
# This part is copyright 2018 Vladimir Dronnikov | ||
# GPL | ||
ALARM=0 | ||
while true; do | ||
test -r /tmp/sd/record/tmp.mp4.tmp && REC=1 || REC=0 | ||
if [ "$REC" != "$ALARM" ]; then | ||
ALARM="$REC" | ||
[ "n$ALARM" == "n0" ] && rm /tmp/temp.jpg /tmp/temp.mp4 | ||
fi | ||
[ -r /tmp/motion.jpg -a ! -r /tmp/temp.jpg ] && cp /tmp/motion.jpg /tmp/temp.jpg && echo JPG ready && photo /tmp/temp.jpg "Photo from $CAMERA_NAME" | ||
[ -r /tmp/motion.mp4 -a ! -r /tmp/temp.mp4 ] && cp /tmp/motion.mp4 /tmp/temp.mp4 && echo MP4 ready && video /tmp/temp.mp4 "Video from $CAMERA_NAME" | ||
sleep 1 | ||
test -r /tmp/sd/record/tmp.mp4.tmp && REC=1 || REC=0 | ||
if [ "$REC" != "$ALARM" ]; then | ||
ALARM="$REC" | ||
[ "n$ALARM" == "n0" ] && rm /tmp/temp.jpg /tmp/temp.mp4 | ||
fi | ||
[ -r /tmp/motion.jpg -a ! -r /tmp/temp.jpg ] && cp /tmp/motion.jpg /tmp/temp.jpg && echo JPG ready && photo /tmp/temp.jpg "Photo from $CAMERA_NAME" | ||
[ -r /tmp/motion.mp4 -a ! -r /tmp/temp.mp4 ] && cp /tmp/motion.mp4 /tmp/temp.mp4 && echo MP4 ready && video /tmp/temp.mp4 "Video from $CAMERA_NAME" | ||
sleep 1 | ||
done |
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
Dronnikov