Add prompt to set interval when starting timelapse
This commit is contained in:
parent
ec3112cfed
commit
f75026dbcb
@ -4,15 +4,14 @@
|
|||||||
# Configuration Variables
|
# Configuration Variables
|
||||||
INSTALL_DIR="/usr/local/bin"
|
INSTALL_DIR="/usr/local/bin"
|
||||||
FILE_LIST=("tl-capture" "tl-clean" "tl-control")
|
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
|
||||||
CRON_DIR="/etc/cron.d"
|
CRON_DIR="/etc/cron.d"
|
||||||
CRON_FILE="$CRON_DIR/timelapse"
|
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_LOG_PATH="/var/log/${FILE_LIST[0]}.log"
|
||||||
CRON_JOB="$CRON_FREQUENCY root $INSTALL_DIR/${FILE_LIST[0]} >> $CRON_LOG_PATH 2>&1"
|
CRON_JOB="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"
|
|
||||||
|
|
||||||
# Check for root/sudo
|
# Check for root/sudo
|
||||||
if [ "$EUID" -ne 0 ]; then
|
if [ "$EUID" -ne 0 ]; then
|
||||||
@ -26,6 +25,14 @@ fi
|
|||||||
|
|
||||||
# Start Time Lapse
|
# Start Time Lapse
|
||||||
start_tl() {
|
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"
|
echo "Creating cron file: $CRON_FILE"
|
||||||
touch "$CRON_FILE"
|
touch "$CRON_FILE"
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
@ -37,7 +44,7 @@ start_tl() {
|
|||||||
echo -e "Writing job to file: $CRON_FILE\n$CRON_JOB"
|
echo -e "Writing job to file: $CRON_FILE\n$CRON_JOB"
|
||||||
cat <<EOF > $CRON_FILE
|
cat <<EOF > $CRON_FILE
|
||||||
# Take an image every 15 minutes and save it for a time lapse
|
# Take an image every 15 minutes and save it for a time lapse
|
||||||
$CRON_JOB
|
$CRON_FREQUENCY $CRON_JOB
|
||||||
EOF
|
EOF
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
echo "Success"
|
echo "Success"
|
||||||
|
Loading…
Reference in New Issue
Block a user