puh current config pre departure
This commit is contained in:
@ -1,54 +1,60 @@
|
||||
#!/bin/bash
|
||||
trap "source {{ working_folder }}/create_timelapse.sh" SIGINT SIGTERM
|
||||
|
||||
echo "Start"
|
||||
# initialize all the variables
|
||||
# basic things
|
||||
BEGIN=$(date +%Y%m%d-%H%M%S)
|
||||
echo $BEGIN
|
||||
WORKING_DIR="{{ working_folder }}/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)
|
||||
mkdir -p $WORKING_DIR
|
||||
|
||||
if ( nc -w 3 -z 10.18.1.1 8184 2>&1 >/dev/null ); then
|
||||
# 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
|
||||
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
|
||||
else
|
||||
echo "No Gali API Data Available"
|
||||
fi
|
||||
|
||||
RUN_FILE={{ working_folder }}/run
|
||||
|
||||
# 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
|
||||
|
||||
# timelapse creation helpers
|
||||
echo "To create timelapse, here's the ffpmeg script" >> $WORKING_DIR/info.txt
|
||||
echo "/bin/ffmpeg -r 30 -pattern_type glob -i "$WORKING_DIR/*.jpg" \\" >> $WORKING_DIR/info.txt
|
||||
echo "-vf "scale=1920x1080" -vcodec libx264 /$WORKING_DIR/00-timelapse.mp4" >> $WORKING_DIR/info.txt
|
||||
#echo "To create timelapse, here's the ffpmeg script" >> $WORKING_DIR/info.txt
|
||||
#echo "/bin/ffmpeg -r 30 -pattern_type glob -i "$WORKING_DIR/*.jpg" \\" >> $WORKING_DIR/info.txt
|
||||
#echo "-vf "scale=1920x1080" -vcodec libx264 /$WORKING_DIR/00-timelapse.mp4" >> $WORKING_DIR/info.txt
|
||||
# there should be a script that can do them all
|
||||
echo "/bin/ffmpeg -r 30 -pattern_type glob -i "$WORKING_DIR/*.jpg" \\" >> {{ working_folder }}/generate_timelapses.sh
|
||||
echo "-vf "scale=1920x1080" -vcodec libx264 /$WORKING_DIR/00-timelapse.mp4" >> {{ working_folder }}/generate_timelapses.sh
|
||||
#echo "/bin/ffmpeg -r 30 -pattern_type glob -i "$WORKING_DIR/*.jpg" \\" >> {{ working_folder }}/generate_timelapses.sh
|
||||
#echo "-vf "scale=1920x1080" -vcodec libx264 /$WORKING_DIR/00-timelapse.mp4" >> {{ working_folder }}/generate_timelapses.sh
|
||||
|
||||
# capture time
|
||||
touch $RUN_FILE
|
||||
echo $RUN_FILE
|
||||
i=1
|
||||
|
||||
|
||||
while [ -e $RUN_FILE ]
|
||||
do
|
||||
FILENAME=$(printf "img-%05d" "$i")
|
||||
# old API based latlon
|
||||
#LATLON=$(curl -s http://10.18.1.1:8184/where_is?api_key={{ tesla_api_key }} )
|
||||
#LON=$(echo $LATLON | jq .lon)
|
||||
#LAT=$(echo $LATLON | jq .lat)
|
||||
LAT=$(cat {{ gps_service_directory }}/gps_data | grep lat | cut -d ":" -f 2 | awk '{printf("%.5f\n", $1)}')
|
||||
LON=$(cat {{ gps_service_directory }}/gps_data | grep lon | cut -d ":" -f 2 | awk '{printf("%.5f\n", $1)}')
|
||||
SPEED_KPH=$(cat {{ gps_service_directory }}/gps_data | grep speed | cut -d ":" -f 2)
|
||||
if [ $SPEED_KPH -lt 1 ]; then
|
||||
if [ $SPEED_KPH > 1 ]; then
|
||||
SPEED_MPH=$(echo "scale=3; $SPEEK_KPH * 0.62" | bc)
|
||||
else
|
||||
SPEED_MPH=0
|
||||
fi
|
||||
COORDINATES="$LAT, $LON, $SPEED_MPH mph"
|
||||
curl http://127.0.0.1:7123/snapshot --output $WORKING_DIR/$FILENAME.jpg
|
||||
|
||||
echo $FILENAME
|
||||
echo $COORDINATES
|
||||
# This variable is for the timestamp
|
||||
TIME=$(date +%c)
|
||||
|
||||
@ -67,17 +73,14 @@ do
|
||||
rm $WORKING_DIR/$FILENAME-temp1.jpg $WORKING_DIR/$FILENAME-temp2.jpg
|
||||
|
||||
# This is for the tiny pic
|
||||
# I'll make one every 5 seconds
|
||||
# I have 1340x580. i think i will truncate the top
|
||||
# Calculate the height to trim based on the aspect ratios of the input and output images
|
||||
if (( $i % 5 == 0 )); then
|
||||
NOW=$(date +%Y%m%d%H%M%S)
|
||||
convert $WORKING_DIR/$FILENAME.jpg -gravity North -crop 1920x830+0+260 +repage -resize 1340x580 {{ working_folder }}/small_thumbs/$NOW.jpg
|
||||
fi
|
||||
NOW=$(date +%Y%m%d%H%M%S)
|
||||
convert $WORKING_DIR/$FILENAME.jpg -gravity North -crop 1920x830+0+260 +repage -resize 1340x580 {{ working_folder }}/small_thumbs/$NOW.jpg
|
||||
|
||||
sleep 1
|
||||
|
||||
((i++))
|
||||
|
||||
done
|
||||
|
||||
# end the loop
|
||||
|
||||
Reference in New Issue
Block a user