|
90 | 90 | NEEDS_REBOOT="false" |
91 | 91 | fi |
92 | 92 |
|
93 | | -# Make sure the settings have been configured after an installation or upgrade. |
94 | 93 | # If the "lastchanged" setting is missing, the user needs to review/change the settings. |
| 94 | +# This will happen after an installation or upgrade, which also sets the Allsky status. |
95 | 95 | LAST_CHANGED="$( settings ".lastchanged" )" |
96 | 96 | if [[ -z ${LAST_CHANGED} ]]; then |
97 | | - set_allsky_status "${ALLSKY_STATUS_NEEDS_CONFIGURATION}" |
98 | | - echo "*** ===== Allsky needs to be configured before it can be used. See the WebUI." >&2 |
| 97 | + STATUS="$( get_allsky_status )" |
| 98 | + if [[ ${STATUS} == "${ALLSKY_STATUS_NEEDS_REVIEW}" ]] then |
| 99 | + IMAGE_NAME="ReviewNeeded" |
| 100 | + MSG="Please review the settings on the WebUI's 'Allsky Settings' page" |
| 101 | + MSG+=" and make any necessary changes." |
| 102 | + WEBUI_MSG="Allsky settings need review" |
| 103 | + |
| 104 | + elif [[ ${STATUS} == "${ALLSKY_STATUS_NEEDS_CONFIGURATION}" ]]; then |
| 105 | + IMAGE_NAME="ConfigurationNeeded" |
| 106 | + MSG="Allsky needs to be configured before it can be used. See the WebUI." |
| 107 | + WEBUI_MSG="Allsky needs to be configured" |
| 108 | + |
| 109 | + else |
| 110 | + IMAGE_NAME="" |
| 111 | + fi |
99 | 112 | if [[ ${NEEDS_REBOOT} == "true" ]]; then |
100 | | - echo "*** ===== The Pi also needs to be rebooted." >&2 |
101 | | - doExit "${EXIT_ERROR_STOP}" "ConfigurationNeeded" \ |
102 | | - "Allsky needs\nconfiguration\nand the Pi needs\na reboot" \ |
103 | | - "Allsky needs to be configured and then the Pi rebooted." |
| 113 | + MSG+=" The Pi also needs to be rebooted." >&2 |
| 114 | + doExit "${EXIT_ERROR_STOP}" "${IMAGE_NAME}" \ |
| 115 | + "" "${WEBUI_MSG} and then the Pi rebooted." |
104 | 116 | else |
105 | | - doExit "${EXIT_ERROR_STOP}" "ConfigurationNeeded" "" "Allsky needs to be configured." |
| 117 | + doExit "${EXIT_ERROR_STOP}" "${IMAGE}" "" "${WEBUI_MSG}." |
106 | 118 | fi |
| 119 | + echo "*** ===== ${MSG}" >&2 # to the log |
| 120 | + |
107 | 121 | elif [[ ${NEEDS_REBOOT} == "true" ]]; then |
108 | 122 | set_allsky_status "${ALLSKY_STATUS_REBOOT_NEEDED}" |
109 | 123 | doExit "${EXIT_ERROR_STOP}" "RebootNeeded" "" "The Pi needs to be rebooted." |
@@ -222,9 +236,24 @@ if [[ ${CAMERA_TYPE} == "ZWO" ]]; then |
222 | 236 | "WARNING:\n\nResetting USB bus\n${REASON}.\nAttempt ${NUM_USB_RESETS}." |
223 | 237 |
|
224 | 238 | SEARCH="${ZWO_VENDOR}:${ZWO_CAMERA_ID}" |
225 | | - sudo "${ALLSKY_BIN}/uhubctl" --action off --exact --search "${SEARCH}" |
| 239 | + # Get the hub number the camera is on. |
| 240 | + local HUB="$( sudo "${ALLSKY_BIN}/uhubctl" --exact --search "${SEARCH}" | |
| 241 | + gawk -v Z="${SEARCH}" ' |
| 242 | + BEGIN {hub = ""; } |
| 243 | + { |
| 244 | + if ($4 == "hub") { |
| 245 | + hub = $5; |
| 246 | + next; |
| 247 | + } |
| 248 | + if (index($0, Z) > 0) { |
| 249 | + print hub; |
| 250 | + exit(0); |
| 251 | + } |
| 252 | + }' |
| 253 | + )" |
| 254 | + sudo "${ALLSKY_BIN}/uhubctl" --action off --exact --search "${SEARCH}" --location "${HUB}" |
226 | 255 | sleep 3 # give it a few seconds, plus, allow the notification images to be seen |
227 | | - sudo "${ALLSKY_BIN}/uhubctl" --action on --exact --search "${SEARCH}" |
| 256 | + sudo "${ALLSKY_BIN}/uhubctl" --action on --exact --search "${SEARCH}" --location "${HUB}" |
228 | 257 | } |
229 | 258 |
|
230 | 259 | else # RPi |
|
0 commit comments