Skip to content

Commit c64db6e

Browse files
authored
Update allsky-config.sh: Allow commands whose name begins with "HTML"
Also, need to use whiptail in some cases - not sure why.
1 parent ba01a5a commit c64db6e

1 file changed

Lines changed: 38 additions & 10 deletions

File tree

scripts/utilities/allsky-config.sh

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,13 @@ function show_supported_cameras()
116116
OPTS+=("--ZWO" "ZWO (very long list)")
117117
OPTS+=("--RPi --ZWO" "both")
118118

119+
#XXX FIX: when using the dialog command the prompt below doesn't include
120+
# the choices.
121+
local SAVED_USE_DIALOG="${USE_DIALOG}"
122+
USE_DIALOG="false"
119123
# If the user selects "Cancel" prompt() returns 1 and we exit the loop.
120124
ARGS="$( prompt "${PROMPT}" "${OPTS[@]}" )"
125+
USE_DIALOG="${SAVED_USE_DIALOG}"
121126
else
122127
# shellcheck disable=SC2124
123128
ARGS="${@}"
@@ -278,13 +283,17 @@ function website_server_cmd()
278283

279284
if [[ $# -eq 0 && -z ${FUNCTION_TO_EXECUTE} ]]; then
280285
OPTS=()
281-
OPTS+=("--website" \
282-
"${MSG1}")
283-
OPTS+=("--server" \
284-
"${MSG2}")
286+
OPTS+=("--website" "${MSG1}")
287+
OPTS+=("--server" "${MSG2}")
288+
289+
#XXX FIX: when using the dialog command the prompt below doesn't include
290+
# the choices.
291+
local SAVED_USE_DIALOG="${USE_DIALOG}"
292+
USE_DIALOG="false"
285293

286294
# If the user selects "Cancel" prompt() returns 1 and we exit the loop.
287295
ARGS="$( prompt "\n${PROMPT}" "${OPTS[@]}" )"
296+
USE_DIALOG="${SAVED_USE_DIALOG}"
288297

289298
# TODO: Remove this check once "remoteserverurl" is implemented.
290299
if [[ ${ARGS} == "--server" ]]; then
@@ -351,7 +360,7 @@ function test_upload()
351360

352361
#####
353362
# Display brightness information from the startrails command.
354-
get_startrails_info()
363+
function get_startrails_info()
355364
{
356365
# shellcheck disable=SC2068
357366
getStartrailsInfo.sh "${@}"
@@ -360,7 +369,7 @@ get_startrails_info()
360369

361370
#####
362371
# Create multiple startrails with different thresholds.
363-
compare_startrails()
372+
function compare_startrails()
364373
{
365374
# shellcheck disable=SC2068
366375
compareStartrails.sh "${@}"
@@ -369,7 +378,7 @@ compare_startrails()
369378

370379
#####
371380
# Create multiple stretched images with different amounts and midpoints.
372-
compare_stretches()
381+
function compare_stretches()
373382
{
374383
# shellcheck disable=SC2068
375384
compareStretches.sh "${@}"
@@ -378,7 +387,7 @@ compare_stretches()
378387

379388
#####
380389
# Help determine some timelapse settings.
381-
compare_timelapse()
390+
function compare_timelapse()
382391
{
383392
# shellcheck disable=SC2068
384393
compareTimelapse.sh "${@}"
@@ -531,7 +540,25 @@ function run_command()
531540
local COMMAND="${1}"
532541
shift
533542

534-
if ! type "${COMMAND}" > /dev/null 2>&1 ; then
543+
local HTML
544+
if [[ ${COMMAND:0:4} == "HTML" ]]; then
545+
HTML="--html"
546+
COMMAND="${COMMAND:4}"
547+
else
548+
HTML=""
549+
fi
550+
551+
if [[ -z ${COMMAND} ]]; then
552+
E_ "\n${ME}: No command specified." >&2
553+
usage_and_exit --commands-only 2
554+
fi
555+
556+
# Check if command is a function; if so, assume it's one of ours.
557+
local T="$( type "${COMMAND}" 2>/dev/null )"
558+
local RET=$?
559+
echo "${T}" | grep -m 1 --silent "is a function" 2>/dev/null
560+
(( RET += $? ))
561+
if [[ ${RET} -ne 0 ]]; then
535562
E_ "\n${ME}: Unknown command '${COMMAND}'." >&2
536563
usage_and_exit --commands-only 2
537564
fi
@@ -542,7 +569,8 @@ function run_command()
542569
fi
543570

544571
ME_F="${COMMAND}" # global
545-
"${COMMAND}" "${@}"
572+
# shellcheck disable=SC2086
573+
"${COMMAND}" ${HTML} "${@}"
546574
}
547575

548576

0 commit comments

Comments
 (0)