mirror of
https://github.com/cimryan/teslausb.git
synced 2026-02-28 20:20:32 +00:00
Initial commit for pushover testing
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.DS_Store
|
||||||
12
README.md
12
README.md
@@ -128,6 +128,18 @@ Now that you have a shell on the Pi you can turn the Pi into a smart USB drive.
|
|||||||
export sharepassword=pa$$w0rd
|
export sharepassword=pa$$w0rd
|
||||||
export campercent=100
|
export campercent=100
|
||||||
```
|
```
|
||||||
|
1. OPTIONAL: You can choose to integrate with [Pushover](https://pushover.net) to get a push notification to your phone when the copy process is done. Depending on your wireless network speed/connection, copying files may take some time, so a push notification can help confirm that the process finished. If no files were copied (i.e. all manually saved dashcam files were already copied, no notification will be sent.). The Pushover service is free for up to 7,500 messages per month, but the [iOS](https://pushover.net/clients/ios)/[Android](https://pushover.net/clients/android) apps do have a one time cost, after a free trial period. *This also assumes your Pi is connected to a network with internet access.*
|
||||||
|
|
||||||
|
* Create a free account at Pushover.net, and install and log into the mobile Pushover app.
|
||||||
|
* On the Pushover dashboard on the web, copy your **User key**.
|
||||||
|
* [Create a new Application](https://pushover.net/apps/build) at Pushover.net. The description and icon don't matter, choose what you prefer.
|
||||||
|
* Copy the **Application Key** for the application you just created. The User key + Application Key are basically a username/password combination to needed to send the push.
|
||||||
|
* Run these commands, substituting your user key and app key in the appropriate places. No `"` are needed.
|
||||||
|
```
|
||||||
|
export pushover_enabled=true
|
||||||
|
export pushover_user_key=put_your_userkey_here
|
||||||
|
export pushover_app_key=put_your_appkey_here
|
||||||
|
```
|
||||||
1. Run these commands:
|
1. Run these commands:
|
||||||
```
|
```
|
||||||
wget https://raw.githubusercontent.com/cimryan/teslausb/master/windows_archive/setup-teslausb
|
wget https://raw.githubusercontent.com/cimryan/teslausb/master/windows_archive/setup-teslausb
|
||||||
|
|||||||
@@ -71,12 +71,18 @@ function ensure_mountpoint_is_mounted_with_retry () {
|
|||||||
|
|
||||||
function move_clips_to_archive () {
|
function move_clips_to_archive () {
|
||||||
log "Moving clips to archive..."
|
log "Moving clips to archive..."
|
||||||
|
local move_count=0
|
||||||
for file_name in "$CAM_MOUNT"/TeslaCam/saved*; do
|
for file_name in "$CAM_MOUNT"/TeslaCam/saved*; do
|
||||||
[ -e "$file_name" ] || continue
|
[ -e "$file_name" ] || continue
|
||||||
log "Moving $file_name ..."
|
log "Moving $file_name ..."
|
||||||
mv -- "$file_name" "$ARCHIVE_MOUNT" >> "$LOG_FILE" 2>&1 || echo ""
|
mv -- "$file_name" "$ARCHIVE_MOUNT" >> "$LOG_FILE" 2>&1 || echo ""
|
||||||
log "Moved $file_name."
|
log "Moved $file_name."
|
||||||
|
move_count=$((move_count + 1))
|
||||||
|
|
||||||
done
|
done
|
||||||
|
log "Moved $move_count file(s)."
|
||||||
|
log "Sending Pushover message"
|
||||||
|
/root/bin/send-pushover.sh $move_count
|
||||||
log "Finished moving clips to archive."
|
log "Finished moving clips to archive."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
9
windows_archive/send-pushover
Normal file
9
windows_archive/send-pushover
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash -eu
|
||||||
|
|
||||||
|
source /root/.teslaCamPushoverCredentials
|
||||||
|
|
||||||
|
curl -F "token=$pushover_app_key" \
|
||||||
|
-F "user=$pushover_user_key" \
|
||||||
|
-F "title=Dashcam Copy Complete" \
|
||||||
|
-F "message=$1 file(s) were copied." \
|
||||||
|
https://api.pushover.net/1/messages
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
#!/bin/bash -eu
|
#!/bin/bash -eu
|
||||||
|
|
||||||
|
TESLAUSB_REPO=rtgoodwin
|
||||||
|
TESLAUSB_BRANCH=master
|
||||||
|
|
||||||
if [ "$(whoami)" != "root" ]
|
if [ "$(whoami)" != "root" ]
|
||||||
then
|
then
|
||||||
echo "STOP: Run sudo -i."
|
echo "STOP: Run sudo -i."
|
||||||
@@ -21,6 +24,32 @@ check_variable "shareuser"
|
|||||||
check_variable "sharepassword"
|
check_variable "sharepassword"
|
||||||
check_variable "campercent"
|
check_variable "campercent"
|
||||||
|
|
||||||
|
function check_pushover_enabled () {
|
||||||
|
if [ -n "${pushover_enabled+x}" ]
|
||||||
|
then
|
||||||
|
if [[ -z "${pushover_user_key+x}" ]] || [[ -z "${pushover_app_key+x}" ]]
|
||||||
|
then
|
||||||
|
echo "STOP: You're trying to setup Pushover but didn't provide your User and/or App key."
|
||||||
|
echo "Define the variables like this:"
|
||||||
|
echo "export pushover_user_key=your_user_key_here"
|
||||||
|
echo "export pushover_app_key=your_app_key_here"
|
||||||
|
exit 1
|
||||||
|
elif [[ "${pushover_user_key}" = "put_your_user_key_here" ]] || [[ "${pushover_app_key}" = "put_your_app_key_here" ]]
|
||||||
|
then
|
||||||
|
echo "STOP: You're trying to setup Pushover but didn't replace the default User and App key values."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "export pushover_enabled=true" > /root/.teslaCamPushoverCredentials
|
||||||
|
echo "export pushover_user_key=$pushover_user_key" >> /root/.teslaCamPushoverCredentials
|
||||||
|
echo "export pushover_app_key=$pushover_app_key" >> /root/.teslaCamPushoverCredentials
|
||||||
|
pushd /root/bin
|
||||||
|
wget https://raw.githubusercontent.com/"$TESLAUSB_REPO"/teslausb/"$TESLAUSB_BRANCH"/windows_archive/send-pushover
|
||||||
|
chmod +x send-pushover
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
serverunreachable=false
|
serverunreachable=false
|
||||||
ping -c 1 -w 1 "$archiveserver" 1>/dev/null 2>&1 || serverunreachable=true
|
ping -c 1 -w 1 "$archiveserver" 1>/dev/null 2>&1 || serverunreachable=true
|
||||||
|
|
||||||
@@ -71,16 +100,18 @@ echo "password=$sharepassword" >> /root/.teslaCamArchiveCredentials
|
|||||||
|
|
||||||
mkdir /root/bin
|
mkdir /root/bin
|
||||||
|
|
||||||
wget https://raw.githubusercontent.com/cimryan/teslausb/master/windows_archive/archiveloop
|
wget https://raw.githubusercontent.com/"$TESLAUSB_REPO"/teslausb/"$TESLAUSB_BRANCH"/windows_archive/archiveloop
|
||||||
sed s/ARCHIVE_HOST_NAME=archiveserver/ARCHIVE_HOST_NAME=$archiveserver/ ~/archiveloop > /root/bin/archiveloop
|
sed s/ARCHIVE_HOST_NAME=archiveserver/ARCHIVE_HOST_NAME=$archiveserver/ ~/archiveloop > /root/bin/archiveloop
|
||||||
rm ~/archiveloop
|
rm ~/archiveloop
|
||||||
chmod +x /root/bin/archiveloop
|
chmod +x /root/bin/archiveloop
|
||||||
|
|
||||||
pushd /root/bin
|
pushd /root/bin
|
||||||
wget https://raw.githubusercontent.com/cimryan/teslausb/master/windows_archive/archive-teslacam-clips
|
wget https://raw.githubusercontent.com/"$TESLAUSB_REPO"/teslausb/"$TESLAUSB_BRANCH"/windows_archive/archive-teslacam-clips
|
||||||
chmod +x archive-teslacam-clips
|
chmod +x archive-teslacam-clips
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
check_pushover_enabled
|
||||||
|
|
||||||
echo "#!/bin/bash -eu" > ~/rc.local
|
echo "#!/bin/bash -eu" > ~/rc.local
|
||||||
tail -n +2 /etc/rc.local | sed '$d' >> ~/rc.local
|
tail -n +2 /etc/rc.local | sed '$d' >> ~/rc.local
|
||||||
cat << 'EOF' >> ~/rc.local
|
cat << 'EOF' >> ~/rc.local
|
||||||
|
|||||||
Reference in New Issue
Block a user