Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved log messages in install.sh #2725

Merged
merged 3 commits into from
May 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ save_camera_capabilities()
"cameraType" "Camera Type" "${PRIOR_CAMERA_TYPE}" "${CAMERA_TYPE}" 2>&1 )"
RET=$?

display_msg "${LOG_TYPE}" info "${MSG}"
[[ -n ${MSG} ]] && display_msg "${LOG_TYPE}" info "${MSG}"
if [[ ${RET} -ne 0 ]]; then
#shellcheck disable=SC2086
if [[ ${RET} -eq ${EXIT_NO_CAMERA} ]]; then
Expand All @@ -385,7 +385,8 @@ save_camera_capabilities()
fi
return 1
else
MSG="$( ls -l "${ALLSKY_CONFIG}/settings"*.json 2>/dev/null )"
#shellcheck disable=SC2012
MSG="$( ls -l "${ALLSKY_CONFIG}/settings"*.json 2>/dev/null | sed 's/^/ /' )"
display_msg "${LOG_TYPE}" info "Settings files:\n${MSG}"
fi

Expand Down Expand Up @@ -556,7 +557,6 @@ check_and_mount_tmp()

if [[ -d "${ALLSKY_TMP}" ]]; then
local IMAGES="$(find "${ALLSKY_TMP}" -name '*.jpg')"
display_msg --logonly debug "Existing IMAGES=${IMAGES}"
if [[ -n ${IMAGES} ]]; then
mkdir "${TMP_DIR}"
# Need to allow for files with spaces in their names.
Expand Down Expand Up @@ -1031,7 +1031,7 @@ get_locale()
CURRENT_LOCALE="$(echo "${TEMP_LOCALE}" | sed --silent -e '/LC_ALL=/ s/LC_ALL=//p')"
fi
fi
display_msg --logonly info "CURRENT_LOCALE=${CURRENT_LOCALE}\nTEMP_LOCALE=${TEMP_LOCALE}"
display_msg --logonly info "CURRENT_LOCALE=${CURRENT_LOCALE}, TEMP_LOCALE=${TEMP_LOCALE}"

local D=""
if [[ -n ${CURRENT_LOCALE} && ${CURRENT_LOCALE} != "null" ]]; then
Expand Down Expand Up @@ -1092,13 +1092,14 @@ set_locale()
if [[ ${CURRENT_LOCALE} == "${LOCALE}" ]]; then
display_msg --log progress "Keeping '${LOCALE}' locale."
local L="$( settings .locale )"
MSG="Settings file '${SETTINGS_FILE}'"
if [[ ${L} == "" || ${L} == "null" ]]; then
# Probably a new install.
MSG="* Info: Settings file '${SETTINGS_FILE}' did not contain .locale."
MSG="${MSG} did NOT contain .locale so adding it."
display_msg --logonly info "${MSG}"
update_locale "${LOCALE}" "${SETTINGS_FILE}"
else
MSG="* Info: Settings file '${SETTINGS_FILE}' contained .locale = '${L}'."
MSG="${MSG} CONTAINED .locale = '${L}'."
display_msg --logonly info "${MSG}"
fi
return
Expand Down Expand Up @@ -1466,7 +1467,7 @@ restore_prior_settings_files()
display_msg --log progress "Restoring settings files:"
FIRST_ONE="false"
fi
display_msg --log progress "\t'$(basename "${F}")'"
display_msg --log progress "\t$(basename "${F}")"
cp -a "${F}" "${ALLSKY_CONFIG}"
done
else
Expand Down Expand Up @@ -1562,7 +1563,7 @@ restore_prior_files()
# Do all the being restores, then all the updates.
local V=""

display_msg --log progress "Restoring:"
display_msg --log progress "Restoring prior:"

# TODO: endOfNight_additionalStepts.sh script is going away in the next major release.
if [[ -f ${PRIOR_ALLSKY_DIR}/scripts/endOfNight_additionalSteps.sh ]]; then
Expand All @@ -1586,7 +1587,7 @@ restore_prior_files()
mv "${PRIOR_ALLSKY_DIR}/images" "${ALLSKY_HOME}"
else
# This is probably very rare so let the user know
MSG=" No prior 'images' directory so can't restore; This unusual."
MSG=" No prior 'images' directory so can't restore; This is unusual."
display_msg --log progress "${MSG}"
fi

Expand All @@ -1599,13 +1600,15 @@ restore_prior_files()

if [[ -d ${PRIOR_CONFIG_DIR}/modules ]]; then
display_msg --log progress " 'modules' directory."

# Copy the user's prior data to the new file which may contain new fields.
"${ALLSKY_SCRIPTS}"/flowupgrade.py --prior "${PRIOR_CONFIG_DIR}" --config "${ALLSKY_CONFIG}"
else
display_msg "${LOG_TYPE}" progress " No prior 'modules' directory so can't restore."
fi

if [[ -d ${PRIOR_CONFIG_DIR}/overlay ]]; then
display_msg --log progress " 'overlays' directory."
display_msg --log progress " 'overlay' directory."
cp -ar "${PRIOR_CONFIG_DIR}/overlay" "${ALLSKY_CONFIG}"

# Restore the fields.json file as it's part of the main Allsky distribution
Expand All @@ -1625,10 +1628,10 @@ restore_prior_files()
# This is not in a "standard" directory so we need to determine where it was.
EXTRA="${PRIOR_ALLSKY_DIR}${ALLSKY_EXTRA//${ALLSKY_HOME}/}"
if [[ -d ${EXTRA} ]]; then
display_msg --log progress " 'extra' files."
display_msg --log progress " '${EXTRA}' directory."
cp -ar "${EXTRA}" "${ALLSKY_EXTRA}/.."
else
display_msg "${LOG_TYPE}" progress " prior 'extra' directory so can't restore."
display_msg "${LOG_TYPE}" progress " No prior '${EXTRA}' directory so can't restore."
fi

if [[ ${PRIOR_ALLSKY} == "new" ]]; then
Expand All @@ -1646,7 +1649,7 @@ restore_prior_files()

# Restore any REMOTE Allsky Website configuration file.
if [[ -f ${PRIOR_CONFIG_DIR}/${ALLSKY_REMOTE_WEBSITE_CONFIGURATION_NAME} ]]; then
MSG=" remote Allsky Website ${ALLSKY_REMOTE_WEBSITE_CONFIGURATION_NAME}."
MSG=" '${ALLSKY_REMOTE_WEBSITE_CONFIGURATION_NAME}'."
display_msg --log progress "${MSG}"
cp -a "${PRIOR_CONFIG_DIR}/${ALLSKY_REMOTE_WEBSITE_CONFIGURATION_NAME}" \
"${ALLSKY_REMOTE_WEBSITE_CONFIGURATION_FILE}"
Expand Down Expand Up @@ -1702,10 +1705,8 @@ restore_prior_files()

CONFIG_SH_VERSION="$(get_variable "CONFIG_SH_VERSION" "${ALLSKY_CONFIG}/config.sh")"
PRIOR_CONFIG_SH_VERSION="$(get_variable "CONFIG_SH_VERSION" "${PRIOR_CONFIG_FILE}")"
MSG="CONFIG_SH_VERSION=${CONFIG_SH_VERSION}, PRIOR=${PRIOR_CONFIG_SH_VERSION}"
display_msg "${LOG_TYPE}" info "${MSG}"
if [[ ${CONFIG_SH_VERSION} == "${PRIOR_CONFIG_SH_VERSION}" ]]; then
display_msg --log progress " prior 'config.sh' file, as is."
display_msg --log progress " Prior 'config.sh' file, as is."
cp "${PRIOR_CONFIG_FILE}" "${ALLSKY_CONFIG}" && RESTORED_PRIOR_CONFIG_SH="true"
else
if [[ -z ${PRIOR_CONFIG_SH_VERSION} ]]; then
Expand All @@ -1718,6 +1719,8 @@ restore_prior_files()
MSG=" Not restoring prior 'config.sh': ${MSG}."
display_msg --log progress "${MSG}"
fi
MSG=" CONFIG_SH_VERSION=${CONFIG_SH_VERSION}, PRIOR=${PRIOR_CONFIG_SH_VERSION}"
display_msg "${LOG_TYPE}" info "${MSG}"

# Unlike the config.sh file which was always in allsky/config,
# the ftp-settings.sh file used to be in allsky/scripts.
Expand All @@ -1736,10 +1739,9 @@ restore_prior_files()
PRIOR_FTP_FILE=""
PRIOR_FTP_SH_VERSION="no file"
fi
display_msg "${LOG_TYPE}" info "FTP_SH_VERSION=${FTP_SH_VERSION}, PRIOR=${PRIOR_FTP_SH_VERSION}"

if [[ ${FTP_SH_VERSION} == "${PRIOR_FTP_SH_VERSION}" ]]; then
display_msg --log progress " prior 'ftp-settings.sh' file, as is."
display_msg --log progress " Prior 'ftp-settings.sh' file, as is."
cp "${PRIOR_FTP_FILE}" "${ALLSKY_CONFIG}" && RESTORED_PRIOR_FTP_SH="true"
else
if [[ ${PRIOR_FTP_SH_VERSION} == "no version" ]]; then
Expand All @@ -1753,19 +1755,20 @@ restore_prior_files()
fi
display_msg --log progress " Not restoring prior 'ftp-settings.sh': ${MSG}"
fi
MSG=" FTP_SH_VERSION=${FTP_SH_VERSION}, PRIOR=${PRIOR_FTP_SH_VERSION}"
display_msg "${LOG_TYPE}" info "${MSG}"

# Done with restores, now the updates.

if [[ -f ${PRIOR_CONFIG_DIR}/${ALLSKY_REMOTE_WEBSITE_CONFIGURATION_NAME} ]]; then
display_msg "${LOG_TYPE}" info "Prior remote Website's AllskyVersion=${V}"
if [[ ${V} != "${ALLSKY_VERSION}" ]]; then
MSG="Updating AllskyVersion in remote Website from '${V}' to '${ALLSKY_VERSION}'"
display_msg --log progress "${MSG}"
jq ".config.AllskyVersion = \"${ALLSKY_VERSION}\"" \
"${ALLSKY_REMOTE_WEBSITE_CONFIGURATION_FILE}" > /tmp/x \
&& mv /tmp/x "${ALLSKY_REMOTE_WEBSITE_CONFIGURATION_FILE}"
else
display_msg --log progress "Prior remote Website already at version ${V}."
display_msg --log progress "Prior remote Website already at latest version ${V}."
fi
fi

Expand Down