From 4220bc9cda6beecf194ba4bb2de7e6971f5b64d1 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Fri, 11 Feb 2022 19:31:29 -0600 Subject: [PATCH 01/18] allsky.sh: improvements 1 Stop the allsky service on fatal errors since the next execution of allsky will also fail, getting us into an infinite loop. Exit with 100 on fatal errors for a future change where systemctl will not restart the service for error codes >= 100. Add color to some error messages --- allsky.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/allsky.sh b/allsky.sh index 7ef0cbe20..30ad3996e 100755 --- a/allsky.sh +++ b/allsky.sh @@ -1,5 +1,6 @@ #!/bin/bash +# Exit code 100 will cause the service to be stopped so the user can fix the problem. # Make it easy to find the beginning of this run in the log file. echo " ***** Starting AllSky *****" @@ -13,7 +14,9 @@ cd "${ALLSKY_HOME}" source "${ALLSKY_HOME}/variables.sh" if [ -z "${ALLSKY_CONFIG}" ]; then echo "${RED}*** ERROR: variables not set, can't continue!${NC}" - exit 1 + "${ALLSKY_SCRIPTS}/copy_notification_image.sh" "Error" 2>&1 + sudo systemctl stop allsky + exit 100 fi # Reset auto camera selection, so config.sh does not pick up old camera selection. @@ -31,7 +34,7 @@ if [ -f "${ALLSKY_CONFIG}/config.sh" ]; then "${ALLSKY_SCRIPTS}/copy_notification_image.sh" "Error" 2>&1 sudo systemctl stop allsky - exit 1 + exit 100 fi else echo "${RED}*** ERROR: config.sh not in ${ALLSKY_CONFIG}.${NC}" @@ -42,7 +45,7 @@ else "${ALLSKY_SCRIPTS}/copy_notification_image.sh" "Error" 2>&1 sudo systemctl stop allsky - exit 1 + exit 100 fi # Make sure allsky.sh is not already running. @@ -66,9 +69,9 @@ else RPiHQIsPresent=0 fi if [[ $CAMERA == "RPiHQ" && $RPiHQIsPresent -eq 0 ]]; then - echo "RPiHQ Camera not found. Exiting." >&2 + echo "${RED}*** ERROR: RPiHQ Camera not found. Exiting.${NC}" >&2 sudo systemctl stop allsky - exit 1 + exit 100 fi if [[ $CAMERA != "RPiHQ" ]]; then @@ -88,7 +91,7 @@ if [[ $CAMERA != "RPiHQ" ]]; then ZWOdev=$(lsusb | awk '/ 03c3:/ { bus=$2; dev=$4; gsub(/[^0-9]/,"",dev); print "/dev/bus/usb/"bus"/"dev;}') ZWOIsPresent=$(lsusb -D ${ZWOdev} 2>/dev/null | grep -c 'iProduct .*ASI[0-9]') if [[ $CAMERA == "ZWO" && $ZWOIsPresent -eq 0 ]]; then - echo "ZWO Camera not found..." >&2 + echo "${RED}*** ERROR: ZWO Camera not found...${NC}" >&2 if [[ $ZWOdev == "" ]]; then echo " and no USB entry found for it." >&2 else @@ -96,13 +99,13 @@ if [[ $CAMERA != "RPiHQ" ]]; then fi if [ "$UHUBCTL_PATH" != "" ] ; then reset_usb - exit 1 + exit 0 # exit with 0 so the service is restarted else echo " Exiting." >&2 echo " If you have the 'uhubctl' command installed, add it to config.sh." >&2 echo " In the meantime, try running it to reset the USB bus." >&2 sudo systemctl stop allsky - exit 1 + exit 100 fi fi fi @@ -115,9 +118,9 @@ if [[ $CAMERA == "auto" ]]; then WAS_AUTO=1 echo "Trying to automatically determine camera type" if [[ $ZWOIsPresent -eq 0 && $RPiHQIsPresent -eq 0 ]]; then - echo "None of RPI or ZWO Cameras were found. Exiting." >&2 + echo "${RED}*** ERROR: None of RPI or ZWO Cameras were found. Exiting.${NC}" >&2 sudo systemctl stop allsky - exit 1 + exit 100 fi # Prioritize ZWO camera if exists, otherwise use RPI camera. if [[ $ZWOIsPresent -eq 0 ]]; then @@ -260,3 +263,4 @@ if [ "${USE_NOTIFICATION_IMAGES}" = "1" -a "${RETCODE}" -ne 0 ] ; then fi exit $RETCODE + From 2dbc536ba19488767b64ee5f7f737e652c12ef95 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Fri, 11 Feb 2022 19:37:11 -0600 Subject: [PATCH 02/18] allsky.sh: improvements 2 Handle exit codes 98 and 99 from the capture programs (which will be added via a separate PR). Add initial code for trying to determine if the service is restarting, versus stopping. On a restart we can display a message "Allsky software is restarting" and skip the "Allsky software is not running" message that appears when the service stops. I'm pretty sure there's a way with systemctl that allows it to send a different signal on stop versus restart. allsky.sh and the capture programs could then check which signal was sent. --- allsky.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/allsky.sh b/allsky.sh index 30ad3996e..772d911e0 100755 --- a/allsky.sh +++ b/allsky.sh @@ -227,6 +227,11 @@ ARGUMENTS+=(-daytime $DAYTIME_CAPTURE) echo "${ARGUMENTS[@]}" > ${ALLSKY_TMP}/capture_args.txt +GOT_SIGTERM="false" +GOT_SIGUSR1="false" +# trap "GOT_SIGTERM=true" SIGTERM +# trap "GOT_SIGUSR1=true" SIGUSR1 + if [[ $CAMERA == "ZWO" ]]; then CAPTURE="capture" elif [[ $CAMERA == "RPiHQ" ]]; then @@ -234,7 +239,18 @@ elif [[ $CAMERA == "RPiHQ" ]]; then fi "${ALLSKY_HOME}/${CAPTURE}" "${ARGUMENTS[@]}" RETCODE=$? -[ $RETCODE -ne 0 ] && echo "'${CAPTURE}' exited with RETCODE=${RETCODE}" +[ $RETCODE -ne 0 ] && echo "'${CAPTURE}' exited with RETCODE=${RETCODE}, GOT_SIGTERM=$GOT_SIGTERM, GOT_SIGUSR1=$GOT_SIGUSR1" + +# 98 return code means we are restarting. The capture program dealt with notification images. +if [ "${RETCODE}" -eq 98 ] ; then + exit 0 # use 0 so the service is restarted +fi + +# 99 is a special return code which means to reset usb bus if possible. +if [ "${RETCODE}" -eq 99 -a "$UHUBCTL_PATH" != "" ] ; then + reset_usb + exit 0 # use 0 so the service is restarted +fi if [ "${USE_NOTIFICATION_IMAGES}" = "1" -a "${RETCODE}" -ne 0 ] ; then @@ -263,4 +279,3 @@ if [ "${USE_NOTIFICATION_IMAGES}" = "1" -a "${RETCODE}" -ne 0 ] ; then fi exit $RETCODE - From 2691b7a0ec7cf418706877b519f0bc25fad92ec4 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Fri, 11 Feb 2022 20:00:41 -0600 Subject: [PATCH 03/18] allsky,sh: remove legacy code # 1 First pass at removing the legacy / compatibility code. --- allsky.sh | 62 ++++++++----------------------------------------------- 1 file changed, 9 insertions(+), 53 deletions(-) diff --git a/allsky.sh b/allsky.sh index 772d911e0..c0cc715c7 100755 --- a/allsky.sh +++ b/allsky.sh @@ -19,37 +19,23 @@ if [ -z "${ALLSKY_CONFIG}" ]; then exit 100 fi -# Reset auto camera selection, so config.sh does not pick up old camera selection. -> "${ALLSKY_CONFIG}/autocam.sh" - # COMPATIBILITY CHECKS -# config.sh moved to a new location in version 0.8.1. Check for it. # Check for a new variable in config.sh that wasn't in prior versions. -# If not found, force the user to upgrade config.sh -if [ -f "${ALLSKY_CONFIG}/config.sh" ]; then - source "${ALLSKY_CONFIG}/config.sh" - if [ -z "${CAPTURE_SAVE_DIR}" ]; then - echo "${RED}*** ERROR: old version of config.sh detected.${NC}" - echo "See https://github.com/thomasjacquin/allsky/wiki/Upgrade-from-0.8.2-or-prior-versions" +# If not set to something (even "") then it wasn't found and force the user to upgrade config.sh +source "${ALLSKY_CONFIG}/config.sh" +if [ ! -v FAN_DATA_FILE ]; then # FAN_DATA_FILE added post version 0.8.3. + echo "${RED}*** ERROR: old version of ${ALLSKY_CONFIG}/config.sh detected.${NC}" + echo "Please move your current config.sh file to config.sh-OLD, then place the newest one" + echo "from https://github.com/thomasjacquin/allsky in ${ALLSKY_CONFIG} and" + echo "manually copy your data from the old file to the new one.". - "${ALLSKY_SCRIPTS}/copy_notification_image.sh" "Error" 2>&1 - sudo systemctl stop allsky - exit 100 - fi -else - echo "${RED}*** ERROR: config.sh not in ${ALLSKY_CONFIG}.${NC}" - echo "Please make a backup of your config.sh, ftp-settings.sh, and settings_*.json files," - echo "then do a full re-install of AllSky." - echo "After the re-install, copy your settings from the backup files to the new files." - echo "Do NOT simply copy the old files over the new ones since several variables have been added or changed names." - "${ALLSKY_SCRIPTS}/copy_notification_image.sh" "Error" 2>&1 sudo systemctl stop allsky exit 100 fi # Make sure allsky.sh is not already running. -ps -ef | grep allsky.sh | grep -v $$ | xargs "sudo kill -9" 2>/dev/null +pgrep allsky.sh | grep -v $$ | xargs "sudo kill -9" 2>/dev/null # old/regular manual camera selection mode => exit if no requested camera was found # Buster and Bullseye have different output so only check the part they have in common. @@ -110,41 +96,11 @@ if [[ $CAMERA != "RPiHQ" ]]; then fi fi -# CAMERA AUTOSELECT -# Exit if no camera found. -WAS_AUTO=0 - -if [[ $CAMERA == "auto" ]]; then - WAS_AUTO=1 - echo "Trying to automatically determine camera type" - if [[ $ZWOIsPresent -eq 0 && $RPiHQIsPresent -eq 0 ]]; then - echo "${RED}*** ERROR: None of RPI or ZWO Cameras were found. Exiting.${NC}" >&2 - sudo systemctl stop allsky - exit 100 - fi - # Prioritize ZWO camera if exists, otherwise use RPI camera. - if [[ $ZWOIsPresent -eq 0 ]]; then - CAMERA="RPiHQ" - else - CAMERA="ZWO" - fi - - # redefine the settings variable - CAMERA_SETTINGS="${CAMERA_SETTINGS_DIR}/settings_${CAMERA}.json" -fi - -if [ $WAS_AUTO -eq 1 ]; then # Get the proper debug level since earlier config.sh run couldn't. - ALLSKY_DEBUG_LEVEL=$(jq -r '.debuglevel' "${CAMERA_SETTINGS}") -fi - echo "CAMERA: ${CAMERA}" if [ "${ALLSKY_DEBUG_LEVEL}" -gt 0 ]; then echo "CAMERA_SETTINGS: ${CAMERA_SETTINGS}" fi -# Save auto camera selection for the current session, will be read in config.sh file. -echo "export CAMERA=${CAMERA}" > "${ALLSKY_CONFIG}/autocam.sh" - # This must be called after CAMERA AUTOSELECT above to refresh the file name. source "${ALLSKY_SCRIPTS}/filename.sh" @@ -156,7 +112,7 @@ else mkdir -p "${ALLSKY_TMP}" fi -# Optionally display a notification image. This must come after the creation of "autocam.sh" above. +# Optionally display a notification image. USE_NOTIFICATION_IMAGES=$(jq -r '.notificationimages' "$CAMERA_SETTINGS") if [ "$USE_NOTIFICATION_IMAGES" = "1" ] ; then # Can do this in the background to speed up startup From 131a538afb431c056f7fe04e157e0c586743e564 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Sat, 12 Feb 2022 02:17:54 -0600 Subject: [PATCH 04/18] config.sh.repo: remove compatibility code Assume this file is used with version 0.8.3 or later, so remove the code that made it compatible with older releases. Move the functionality of the scripts/filename.sh file here, since almost every time config.sh is sourced in, so is filename.sh. --- config_repo/config.sh.repo | 55 +++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/config_repo/config.sh.repo b/config_repo/config.sh.repo index 5e27e3e8e..5eff7f550 100644 --- a/config_repo/config.sh.repo +++ b/config_repo/config.sh.repo @@ -6,7 +6,7 @@ # - Values can optionally be quoted with double quotes, NOT single quotes. # - If a variable occurs multiple times, only the last value is used. -# Choose between "ZWO" or "RPiHQ". Note that "auto" is no longer allowed. +# Choose between "ZWO" or "RPiHQ". CAMERA="" @@ -69,6 +69,15 @@ REMOVE_BAD_IMAGES_THRESHOLD_HIGH=90 # e.g. activate autoexposure algorithm "mean" for RPiHQ: "-mean-value 0.3 -autoexposure 1" CAPTURE_EXTRA_PARAMETERS="" +# Set to "false" to disable daytime capture. +DAYTIME_CAPTURE="true" + +# Night images are always taken and saved to disk. +# Setting DAYTIME_SAVE to "true" also saves daytime images to disk. +# Will only save daytime images if DAYTIME_CAPTURE="true". +DAYTIME_SAVE="false" + + ########## Timelapse # Set to "true" to generate a timelapse video at the end of each night. TIMELAPSE="true" @@ -149,13 +158,10 @@ POST_END_OF_NIGHT_DATA="false" # You must first create dark frames - see the README.md file for instructions. DARK_FRAME_SUBTRACTION="false" -# Set to "false" to disable daytime capture. -DAYTIME_CAPTURE="true" - -# Night images are always taken and saved to disk. -# Setting DAYTIME_SAVE to "true" also saves daytime images to disk. -# Will only save daytime images if DAYTIME_CAPTURE="true". -DAYTIME_SAVE="false" +# If you have a fan in your Allsky camera enclosure that reports its speed, +# set this to the full pathname of that file. +# The file should include two numbers: the fan speed in RPM and the percent of maximum speed. +FAN_DATA_FILE="" # The uhubctl command can reset the USB bus if the camera isn't found and you know it's there. # Allsky.sh uses this to try and fix "missing" cameras. @@ -168,12 +174,12 @@ UHUBCTL_PORT=2 # Do not change unless you know what you are doing. CAMERA_SETTINGS_DIR="${ALLSKY_CONFIG}" + +# ================ Do not change anything below this line. if [ "${CAMERA}" = "" ]; then echo "${RED}ERROR: Please set CAMERA in config/config.sh${NC}" - exit 1 -elif [ "${CAMERA}" = "auto" ]; then - echo "${RED}ERROR: 'auto' is no longer a valid CAMERA type. Please reset CAMERA in config/config.sh${NC}" - exit 1 + sudo systemctl stop allsky + exit 100 fi # This is needed in case the user changed the default location the current image is saved to. @@ -183,23 +189,12 @@ else CAPTURE_SAVE_DIR="${IMG_DIR}" fi -# !!! The next few lines are for backwards compatibility and will be removed in the future - do not change !!! -UPLOAD_IMG="${IMG_UPLOAD}" # UPLOAD_IMG is th eold name for IMG_UPLOAD -if [ "${DAYTIME_CAPTURE}" = "true" ]; then - DAYTIME=1 # DAYTIME is the old name for DAYTIME_CAPTURE -else - DAYTIME=0 -fi -CAPTURE_24HR=${DAYTIME_SAVE} # CAPTURE_24HR is the old name for DAYTIME_SAVE +CAMERA_SETTINGS="${CAMERA_SETTINGS_DIR}/settings_${CAMERA}.json" -if [[ ${CAMERA} == "auto" ]]; then - # Restore currently saved autodiscovered camera type, if any. - source "${ALLSKY_CONFIG}/autocam.sh" # May reset ${CAMERA} -fi -if [[ ${CAMERA} != "auto" ]]; then - CAMERA_SETTINGS="${CAMERA_SETTINGS_DIR}/settings_${CAMERA}.json" +# Get the name of the file the websites will look for, and split into name and extension. +FULL_FILENAME=$(jq -r '.filename' "$CAMERA_SETTINGS") +EXTENSION="${FULL_FILENAME##*.}" +FILENAME="${FULL_FILENAME%.*}" - # So scripts can conditionally ouput messages; DO NOT CHANGE NEXT LINES. - ALLSKY_DEBUG_LEVEL=$(jq -r '.debuglevel' "${CAMERA_SETTINGS}") -fi -ALLSKY_DEBUG_LEVEL=${ALLSKY_DEBUG_LEVEL:-0} +# So scripts can conditionally ouput messages; DO NOT CHANGE NEXT LINES. +ALLSKY_DEBUG_LEVEL=$(jq -r '.debuglevel' "${CAMERA_SETTINGS}") From 3c1a8aa3ddb4d035c542b5ccec00bd0dda971f86 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Sat, 12 Feb 2022 02:23:19 -0600 Subject: [PATCH 05/18] config.sh.repo: prepare for update code In preparation for an Allsky update script, add a variable that will tell the script when to stop looking for user-settable variables. The script will use the new config.sh file but will copy the user's settings from the old config.sh to the new file, stopping at END_OF_USER_SETTINGS. --- config_repo/config.sh.repo | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config_repo/config.sh.repo b/config_repo/config.sh.repo index 5eff7f550..220ddec8d 100644 --- a/config_repo/config.sh.repo +++ b/config_repo/config.sh.repo @@ -176,6 +176,8 @@ CAMERA_SETTINGS_DIR="${ALLSKY_CONFIG}" # ================ Do not change anything below this line. +END_OF_USER_SETTINGS="true" # During upgrades, stop looking for variables here. + if [ "${CAMERA}" = "" ]; then echo "${RED}ERROR: Please set CAMERA in config/config.sh${NC}" sudo systemctl stop allsky From 19a4d53019b8237834530bb3bcce155c31db184e Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Sat, 12 Feb 2022 02:28:28 -0600 Subject: [PATCH 06/18] config.sh.repo: remove unneeded keogram stuff --rotate 0 is the default --- config_repo/config.sh.repo | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/config_repo/config.sh.repo b/config_repo/config.sh.repo index 220ddec8d..0682d9fc3 100644 --- a/config_repo/config.sh.repo +++ b/config_repo/config.sh.repo @@ -115,10 +115,7 @@ UPLOAD_VIDEO="false" KEOGRAM="true" # Additional Keogram parameters. Run "keogram --help" to see the options. -# Keograms work best if North is at the top of the image. If this is not the case you can -# rotate the image; for example, if North is straight down in your image, rotate it 180 degrees. -# Rotation is anticlockwise. 0 disables rotation. -KEOGRAM_EXTRA_PARAMETERS="--rotate 0 --font-size 1.0 --font-line 1 --font-color '255 255 255'" +KEOGRAM_EXTRA_PARAMETERS="--font-size 1.0 --font-line 1 --font-color '255 255 255'" # Set to "true" to upload the keogram to your website at the end of each night. UPLOAD_KEOGRAM="false" From 1097c0871fa8e97b7a57fc70141e7e6b8c3d6c79 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Sat, 12 Feb 2022 02:33:22 -0600 Subject: [PATCH 07/18] allsky.sh: remove legacy code Assume this version runs with 0.8.3 so there's no need for legacy code to handle CAMERA=auto or to check for obsolete variables. This simplifies the code somewhat. Remove duplicate check for reset_usb. The functionality of scripts/filename.sh was moved to config/config.sh so no need to source in filename.sh --- allsky.sh | 76 ++++++++++++++++++++++++------------------------------- 1 file changed, 33 insertions(+), 43 deletions(-) diff --git a/allsky.sh b/allsky.sh index c0cc715c7..a07f1b109 100755 --- a/allsky.sh +++ b/allsky.sh @@ -1,6 +1,7 @@ #!/bin/bash # Exit code 100 will cause the service to be stopped so the user can fix the problem. + # Make it easy to find the beginning of this run in the log file. echo " ***** Starting AllSky *****" @@ -23,7 +24,7 @@ fi # Check for a new variable in config.sh that wasn't in prior versions. # If not set to something (even "") then it wasn't found and force the user to upgrade config.sh source "${ALLSKY_CONFIG}/config.sh" -if [ ! -v FAN_DATA_FILE ]; then # FAN_DATA_FILE added post version 0.8.3. +if [ ! -v FAN_DATA_FILE ]; then # FAN_DATA_FILE added after version 0.8.3. echo "${RED}*** ERROR: old version of ${ALLSKY_CONFIG}/config.sh detected.${NC}" echo "Please move your current config.sh file to config.sh-OLD, then place the newest one" echo "from https://github.com/thomasjacquin/allsky in ${ALLSKY_CONFIG} and" @@ -34,33 +35,34 @@ if [ ! -v FAN_DATA_FILE ]; then # FAN_DATA_FILE added post version 0.8.3. exit 100 fi -# Make sure allsky.sh is not already running. -pgrep allsky.sh | grep -v $$ | xargs "sudo kill -9" 2>/dev/null - -# old/regular manual camera selection mode => exit if no requested camera was found -# Buster and Bullseye have different output so only check the part they have in common. -# TODO: this check only needs to be done if CAMERA = RPiHQ -# Bullseye has problems detecting RPiHQ cameras - workaround -which libcamera-still > /dev/null -if [ $? -eq 0 ]; then - LIBCAMERA_LOG_LEVELS="ERROR,FATAL" libcamera-still -t 1 --nopreview - RET=$? -else - vcgencmd get_camera | grep --silent "supported=1" - RET=$? -fi -if [ $RET -eq 0 ]; then - RPiHQIsPresent=1 -else - RPiHQIsPresent=0 -fi -if [[ $CAMERA == "RPiHQ" && $RPiHQIsPresent -eq 0 ]]; then - echo "${RED}*** ERROR: RPiHQ Camera not found. Exiting.${NC}" >&2 +if [ -z "${CAMERA}" ]; then + echo "${RED}*** ERROR: CAMERA not set, can't continue!${NC}" + "${ALLSKY_SCRIPTS}/copy_notification_image.sh" "Error" 2>&1 sudo systemctl stop allsky exit 100 fi -if [[ $CAMERA != "RPiHQ" ]]; then +# Make sure allsky.sh is not already running. +pgrep allsky.sh | grep -v $$ | xargs "sudo kill -9" 2>/dev/null + +if [ "${CAMERA}" = "RPiHQ" ]; then + # See if we should use libcamera-still or raspistill. + which libcamera-still > /dev/null + if [ $? -eq 0 ]; then + LIBCAMERA_LOG_LEVELS="ERROR,FATAL" libcamera-still --timeout 1 --nopreview > /dev/null 2>&1 + RET=$? + else + # Buster and Bullseye have different output so only check the part they have in common. + vcgencmd get_camera | grep --silent "supported=1" + RET=$? + fi + if [ $RET -ne 0 ]; then + echo "${RED}*** ERROR: RPiHQ Camera not found. Exiting.${NC}" >&2 + sudo systemctl stop allsky + exit 100 + fi + +else # ZWO CAMERA reset_usb() # resets the USB bus { if [ "${ON_TTY}" = "1" ]; then @@ -73,10 +75,9 @@ if [[ $CAMERA != "RPiHQ" ]]; then } # Use two commands to better aid debugging when camera isn't found. - # xxxxx This doesn't catch cases where CAMERA is "auto" and we should use ZWO. ZWOdev=$(lsusb | awk '/ 03c3:/ { bus=$2; dev=$4; gsub(/[^0-9]/,"",dev); print "/dev/bus/usb/"bus"/"dev;}') ZWOIsPresent=$(lsusb -D ${ZWOdev} 2>/dev/null | grep -c 'iProduct .*ASI[0-9]') - if [[ $CAMERA == "ZWO" && $ZWOIsPresent -eq 0 ]]; then + if [ $ZWOIsPresent -eq 0 ]; then echo "${RED}*** ERROR: ZWO Camera not found...${NC}" >&2 if [[ $ZWOdev == "" ]]; then echo " and no USB entry found for it." >&2 @@ -101,12 +102,9 @@ if [ "${ALLSKY_DEBUG_LEVEL}" -gt 0 ]; then echo "CAMERA_SETTINGS: ${CAMERA_SETTINGS}" fi -# This must be called after CAMERA AUTOSELECT above to refresh the file name. -source "${ALLSKY_SCRIPTS}/filename.sh" - if [ -d "${ALLSKY_TMP}" ]; then # remove any lingering old image files. - rm -f "${ALLSKY_TMP}/${FILENAME}"-202*.${EXTENSION} # "202" for 2021 and later + rm -f "${ALLSKY_TMP}/${FILENAME}"-202*.${EXTENSION} # "202" for 2020 and later else # Re-create in case it's on a memory filesystem that gets wiped out at reboot mkdir -p "${ALLSKY_TMP}" @@ -169,19 +167,16 @@ else rm -f "${FREQUENCY_FILE}" fi -# "capture" expects 0 or 1; newer versions of config.sh use "true" and "false". -# DAYTIME is the old name for DAYTIME_CAPTURE. -# TODO: These checks will go away in the future. -if [ "${DAYTIME_CAPTURE}" = "true" -o "${DAYTIME}" = "1" ] ; then +if [ "${DAYTIME_CAPTURE}" = "true" ] ; then DAYTIME_CAPTURE=1 -elif [ "${DAYTIME_CAPTURE}" = "false" -o "${DAYTIME}" = "0" ] ; then +else DAYTIME_CAPTURE=0 fi ARGUMENTS+=(-daytime $DAYTIME_CAPTURE) [ "$CAPTURE_EXTRA_PARAMETERS" != "" ] && ARGUMENTS+=(${CAPTURE_EXTRA_PARAMETERS}) # Any additional parameters -echo "${ARGUMENTS[@]}" > ${ALLSKY_TMP}/capture_args.txt +echo "${ARGUMENTS[@]}" > ${ALLSKY_TMP}/capture_args.txt # for debugging GOT_SIGTERM="false" GOT_SIGUSR1="false" @@ -195,7 +190,8 @@ elif [[ $CAMERA == "RPiHQ" ]]; then fi "${ALLSKY_HOME}/${CAPTURE}" "${ARGUMENTS[@]}" RETCODE=$? -[ $RETCODE -ne 0 ] && echo "'${CAPTURE}' exited with RETCODE=${RETCODE}, GOT_SIGTERM=$GOT_SIGTERM, GOT_SIGUSR1=$GOT_SIGUSR1" +if [ $RETCODE -ne 0 ]; then + echo -e "${RED}'${CAPTURE}' exited with RETCODE=${RETCODE}, GOT_SIGTERM=$GOT_SIGTERM, GOT_SIGUSR1=$GOT_SIGUSR1${NC}" # 98 return code means we are restarting. The capture program dealt with notification images. if [ "${RETCODE}" -eq 98 ] ; then @@ -209,12 +205,6 @@ if [ "${RETCODE}" -eq 99 -a "$UHUBCTL_PATH" != "" ] ; then fi if [ "${USE_NOTIFICATION_IMAGES}" = "1" -a "${RETCODE}" -ne 0 ] ; then - - # 99 is a special return code which means to reset usb bus if possible. - if [ "${RETCODE}" -eq 99 -a "$UHUBCTL_PATH" != "" ] ; then - reset_usb - fi - # RETCODE -ge 100 means the we should not restart until the user fixes the error. if [ "$RETCODE" -ge 100 ]; then echo "***" From af361ca53abfdfc1a49be717aa7d86f33e29a8af Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Sat, 12 Feb 2022 02:34:39 -0600 Subject: [PATCH 08/18] copy_notification_image.sh: remove filename.sh --- scripts/copy_notification_image.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/copy_notification_image.sh b/scripts/copy_notification_image.sh index b19afe880..3693f98cf 100755 --- a/scripts/copy_notification_image.sh +++ b/scripts/copy_notification_image.sh @@ -4,7 +4,6 @@ ME="$(basename "${BASH_ARGV0}")" source "${ALLSKY_HOME}/variables.sh" source "${ALLSKY_CONFIG}/config.sh" -source "${ALLSKY_SCRIPTS}/filename.sh" source "${ALLSKY_CONFIG}/ftp-settings.sh" NOTIFICATIONFILE="$1" # filename, minus the extension, since the extension may vary From 42fc438c1019181b3bb09bc9f13e0186f0ced8ad Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Sat, 12 Feb 2022 02:35:07 -0600 Subject: [PATCH 09/18] endOfNight.sh: remove filename.sh --- scripts/endOfNight.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/endOfNight.sh b/scripts/endOfNight.sh index 402d4834d..74ee7ed10 100755 --- a/scripts/endOfNight.sh +++ b/scripts/endOfNight.sh @@ -9,7 +9,6 @@ fi source "${ALLSKY_HOME}/variables.sh" source "${ALLSKY_CONFIG}/config.sh" -source "${ALLSKY_SCRIPTS}/filename.sh" source "${ALLSKY_CONFIG}/ftp-settings.sh" if [ $# -eq 1 ] ; then From a830085afffeea603a233e8cfa65d634789ac263 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Sat, 12 Feb 2022 02:35:47 -0600 Subject: [PATCH 10/18] generateForDay.sh: remove filename.sh --- scripts/generateForDay.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/generateForDay.sh b/scripts/generateForDay.sh index 82a455348..1f8382ee2 100755 --- a/scripts/generateForDay.sh +++ b/scripts/generateForDay.sh @@ -23,7 +23,6 @@ fi source "${ALLSKY_HOME}/variables.sh" source "${ALLSKY_CONFIG}/config.sh" -source "${ALLSKY_SCRIPTS}/filename.sh" [ "${TYPE}" = "UPLOAD" ] && source "${ALLSKY_CONFIG}/ftp-settings.sh" # If we're on a tty we are being invoked manually so no need to display ${ME} in error messages. From 15675fc028be17b842ecb2ac01cfcd6679268764 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Sat, 12 Feb 2022 02:36:25 -0600 Subject: [PATCH 11/18] removeBadImages.sh: remove filename.sh --- scripts/removeBadImages.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/removeBadImages.sh b/scripts/removeBadImages.sh index 84e522944..1102eeb99 100755 --- a/scripts/removeBadImages.sh +++ b/scripts/removeBadImages.sh @@ -4,7 +4,6 @@ ME="$(basename "${BASH_ARGV0}")" source "${ALLSKY_HOME}/variables.sh" source "${ALLSKY_CONFIG}/config.sh" -source "${ALLSKY_SCRIPTS}/filename.sh" usage() { From 1404afaf026e60dc9b42fe2ecd2b23c92456d6f6 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Sat, 12 Feb 2022 02:36:51 -0600 Subject: [PATCH 12/18] saveImage.sh: remove filename.sh --- scripts/saveImage.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/saveImage.sh b/scripts/saveImage.sh index 8e1f5d944..6db6edb90 100755 --- a/scripts/saveImage.sh +++ b/scripts/saveImage.sh @@ -8,7 +8,6 @@ ME="$(basename "${BASH_ARGV0}")" source "${ALLSKY_HOME}/variables.sh" source "${ALLSKY_CONFIG}/config.sh" -source "${ALLSKY_SCRIPTS}/filename.sh" usage_and_exit() { From 7fd6634a78bfba25f88af85890f7828deca04f94 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Sat, 12 Feb 2022 02:37:44 -0600 Subject: [PATCH 13/18] timelapse.sh: remove filename.sh Also remove unneeded compatibility code --- scripts/timelapse.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/scripts/timelapse.sh b/scripts/timelapse.sh index 09d194a59..6d7d68e8d 100755 --- a/scripts/timelapse.sh +++ b/scripts/timelapse.sh @@ -1,14 +1,5 @@ #!/bin/bash -# TODO: remove these lines once we know they are in the new unified configuration file. -TIMELAPSEWIDTH=${TIMELAPSEWIDTH:-0} -TIMELAPSEHEIGHT=${TIMELAPSEHEIGHT:-0} -FFLOG=${FFLOG:-warning} -FPS=${FPS:-25} -VCODEC=${VCODEC:-libx264} -TIMELAPSE_BITRATE=${TIMELAPSE_BITRATE:-2000k} -PIX_FMT=${PIX_FMT:-yuv420p} - # Allow this script to be executed manually, which requires ALLSKY_HOME to be set. if [ -z "${ALLSKY_HOME}" ] ; then export ALLSKY_HOME="$(realpath $(dirname "${BASH_ARGV0}")/..)" @@ -16,7 +7,6 @@ fi source "${ALLSKY_HOME}/variables.sh" source "${ALLSKY_CONFIG}/config.sh" -source "${ALLSKY_SCRIPTS}/filename.sh" # If we're on a tty that means we're being manually run and $RED != "". # In that case, don't display $ME. From 7d43bb9e9276384651789a16b3038e03588f3587 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Sat, 12 Feb 2022 02:38:33 -0600 Subject: [PATCH 14/18] upload.sh: remove filename.sh --- scripts/upload.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/upload.sh b/scripts/upload.sh index a6b76a960..da2502130 100755 --- a/scripts/upload.sh +++ b/scripts/upload.sh @@ -10,7 +10,6 @@ fi source "${ALLSKY_HOME}/variables.sh" source "${ALLSKY_CONFIG}/config.sh" -source "${ALLSKY_SCRIPTS}/filename.sh" source "${ALLSKY_CONFIG}/ftp-settings.sh" if [ "${1}" = "--silent" ] ; then From 2c1cc62a0c7079cdb07ed633a879335495d5903f Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Sat, 12 Feb 2022 02:54:07 -0600 Subject: [PATCH 15/18] filename.sh: remove Its functionality was moved to config.sh --- scripts/filename.sh | 7 ------- 1 file changed, 7 deletions(-) delete mode 100755 scripts/filename.sh diff --git a/scripts/filename.sh b/scripts/filename.sh deleted file mode 100755 index fd8d036eb..000000000 --- a/scripts/filename.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -# We get the filename from settings.json -FULL_FILENAME=$(jq -r '.filename' "$CAMERA_SETTINGS") -EXTENSION="${FULL_FILENAME##*.}" -FILENAME="${FULL_FILENAME%.*}" - From c095e28ec12e43857eb1057d97e5651c779ad5aa Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Sat, 12 Feb 2022 02:55:56 -0600 Subject: [PATCH 16/18] allsky.sh: add ending newline to keep workflow checker happy --- allsky.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/allsky.sh b/allsky.sh index a07f1b109..85ed62f02 100755 --- a/allsky.sh +++ b/allsky.sh @@ -225,3 +225,4 @@ if [ "${USE_NOTIFICATION_IMAGES}" = "1" -a "${RETCODE}" -ne 0 ] ; then fi exit $RETCODE + From db304454b9256fcd0cc0504713d1e7cfeea38bb0 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Sat, 12 Feb 2022 03:03:07 -0600 Subject: [PATCH 17/18] allsky.sh: add missing "fi" --- allsky.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/allsky.sh b/allsky.sh index 85ed62f02..f460346c0 100755 --- a/allsky.sh +++ b/allsky.sh @@ -192,6 +192,7 @@ fi RETCODE=$? if [ $RETCODE -ne 0 ]; then echo -e "${RED}'${CAPTURE}' exited with RETCODE=${RETCODE}, GOT_SIGTERM=$GOT_SIGTERM, GOT_SIGUSR1=$GOT_SIGUSR1${NC}" +fi # 98 return code means we are restarting. The capture program dealt with notification images. if [ "${RETCODE}" -eq 98 ] ; then @@ -225,4 +226,3 @@ if [ "${USE_NOTIFICATION_IMAGES}" = "1" -a "${RETCODE}" -ne 0 ] ; then fi exit $RETCODE - From ae9fc331bf1b8bce652c40162c5fb20bb5c1f320 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Sat, 12 Feb 2022 08:35:21 -0600 Subject: [PATCH 18/18] ftp-settings.sh.repo: remove legacy code --- config_repo/ftp-settings.sh.repo | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config_repo/ftp-settings.sh.repo b/config_repo/ftp-settings.sh.repo index f67fd4151..bd41d77c3 100755 --- a/config_repo/ftp-settings.sh.repo +++ b/config_repo/ftp-settings.sh.repo @@ -64,10 +64,6 @@ STARTRAILS_DIR="" STARTRAILS_DESTINATION_NAME="" WEB_STARTRAILS_DIR="" -# These are for for backwards compatibility and will be removed in the future. DO NOT CHANGE! -IMGDIR="${IMAGE_DIR}" -MP4DIR="${VIDEOS_DIR}" - ############### ftp, ftps, sftp, and scp PROTOCOLS only: # Enter the name of the remote server. If you don't know it, ask your service provider.