41 lines
1015 B
Bash
41 lines
1015 B
Bash
#!/bin/bash
|
|
|
|
# Customizable variables
|
|
# Paths
|
|
IMG_DIR="/tmp/TL"
|
|
NAS_MOUNT_DIR="/mnt/media"
|
|
SYNC_DES_PATH="/TL/synced"
|
|
# Command variables
|
|
RESOLUTION="1920x1080"
|
|
DEVICE="/dev/video0"
|
|
FRAMES="1"
|
|
SKIPS="5"
|
|
|
|
# Pre-script configurations
|
|
# Generate the date for the filename
|
|
DATE=$(date +"%Y-%m-%d_%H-%M")
|
|
# Form the filename
|
|
FILENAME="TL-$DATE.jpg"
|
|
|
|
# Functions
|
|
# Capture an image and save it locally
|
|
capture() {
|
|
# Capture an image for the timelapse and save it to /tmp/TL-YYYY-MM-DD_HH-MM.jpg
|
|
echo "Capturing image and saving it to $IMG_DIR/$FILENAME"
|
|
fswebcam -r "$RESOLUTION" -d "#DEVICE" "$IMG_DIR/$FILENAME" -F 1 -S 5
|
|
}
|
|
# Sync images from local to a remote mounted storage device
|
|
sync() {
|
|
echo "Syncing $IMG_DIR to $SYNC_DES_PATH..."
|
|
rsync -av --progress --remove-source-files "$IMG_DIR/" "$NAS_MOUNT_DIR$SYNC_DES_PATH/" $1
|
|
if [[ $? -eq 0 ]]; then
|
|
echo "Success"
|
|
else
|
|
echo "Unable to complete sync. Exiting"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Actually run everything
|
|
capture
|
|
sync |