diff --git a/timelapse/tl-control b/timelapse/tl-control index 682f665..2a0bdaa 100644 --- a/timelapse/tl-control +++ b/timelapse/tl-control @@ -4,15 +4,14 @@ # Configuration Variables INSTALL_DIR="/usr/local/bin" FILE_LIST=("tl-capture" "tl-clean" "tl-control") +SYNC_SRC_PATH="/tmp/TL/to-sync" +SYNC_DES_PATH="/mnt/media/TL/to-process" # Cron CRON_DIR="/etc/cron.d" CRON_FILE="$CRON_DIR/timelapse" -CRON_FREQUENCY="*/15 * * * *" # Every 15 minutes +CRON_FREQUENCY="*/15 * * * *" # Set by prompt CRON_LOG_PATH="/var/log/${FILE_LIST[0]}.log" -CRON_JOB="$CRON_FREQUENCY root $INSTALL_DIR/${FILE_LIST[0]} >> $CRON_LOG_PATH 2>&1" -# Paths -SYNC_SRC_PATH="/tmp/TL/to-sync" -SYNC_DES_PATH="/mnt/media/TL/to-process" +CRON_JOB="root $INSTALL_DIR/${FILE_LIST[0]} >> $CRON_LOG_PATH 2>&1" # Check for root/sudo if [ "$EUID" -ne 0 ]; then @@ -26,6 +25,14 @@ fi # Start Time Lapse start_tl() { + read -p "Image interval in minutes (1-59): " interval + # Make sure the interval is valid 1-59 + if [[ "$interval" =~ ^[1-9]$|^[1-5][0-9]$ ]]; then + CRON_FREQUENCY="*/$interval * * * *" + else + echo "Invalid interval!" + return 1 + fi echo "Creating cron file: $CRON_FILE" touch "$CRON_FILE" if [[ $? -eq 0 ]]; then @@ -37,7 +44,7 @@ start_tl() { echo -e "Writing job to file: $CRON_FILE\n$CRON_JOB" cat < $CRON_FILE # Take an image every 15 minutes and save it for a time lapse -$CRON_JOB +$CRON_FREQUENCY $CRON_JOB EOF if [[ $? -eq 0 ]]; then echo "Success"