Files
carputer/templates/timelapse_service.sh.j2

30 lines
908 B
Django/Jinja

#!/bin/bash
# initialize all the variables
# basic things
BEGIN=$(date +%Y%m%d-%H%M%S)
WORKING_DIR="/opt/carputer/timelapse/storage/$BEGIN"
# be greedy about API calls
WHERES_GALI=$(curl -s http://10.18.1.1:8184/wheres_gali?api_key={{ tesla_api_key }})
# parse the one API call
CITY=$(echo $WHERES_GALI | jq .city)
STATE=$(echo $WHERES_GALI | jq .state)
ZIPCODE=$(echo $WHERES_GALI | jq .postcode)
DISPLAY_NAME=$(echo $WHERES_GALI | jq .display_name)
# Generate Status Report
mkdir -p $WORKING_DIR
echo Timelapse Initiated at $BEGIN >> $WORKING_DIR/info.txt
echo Shuttlecraft Galileo located at $CITY, $STATE $ZIPCODE >> $WORKING_DIR/info.txt
echo $DISPLAY_NAME >> $WORKING_DIR/info.txt
# Set the run file and fork the loop
touch $WORKING_DIR/run
source ./record_snapshots.sh &
# set the trap and wait
trap "source ./record_timelapse" SIGINT SIGTERM
while true; do
echo "Running..."
sleep 1
done