initial commit, carputer ansible role
This commit is contained in:
30
templates/timelapse_service.sh.j2
Normal file
30
templates/timelapse_service.sh.j2
Normal file
@ -0,0 +1,30 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user