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

Install.sh bug fix with prior settings file #2777

Merged
merged 3 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
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
37 changes: 29 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ STATUS_NOT_CONTINUE="User elected not to continue" # Exiting, but not an error
STATUS_NO_REBOOT="User elected not to reboot"
STATUS_CLEAR="Clear" # Clear the file
STATUS_ERROR="Error encountered"
STATUS_INT="Got interrupt"
STATUS_VARIABLES=() # Holds all the variables and values to save

# Some versions of Linux default to 750 so web server can't read it
chmod 755 "${ALLSKY_HOME}"

OS="$(grep CODENAME /etc/os-release | cut -d= -f2)" # usually buster or bullseye

####################### functions

############################################## functions

####
#
Expand Down Expand Up @@ -1617,10 +1619,22 @@ restore_prior_settings_file()
if [[ ${PRIOR_ALLSKY} == "newStyle" ]]; then
if [[ -f ${PRIOR_SETTINGS_FILE} ]]; then

MSG="Checking link for newStyle PRIOR_SETTINGS_FILE '${PRIOR_SETTINGS_FILE}'"
display_msg --logonly info "${MSG}"

# The prior settings file SHOULD be a link to a camera-specific file.
# Make sure that's true; if not, fix it.
if ! MSG="$( check_settings_link "${SETTINGS_FILE}" )" ; then
display_msg --log info "${MSG}"
MSG="$( check_settings_link "${PRIOR_SETTINGS_FILE}" )"
RET=$?
if [[ ${RET} -ne 0 ]]; then
display_msg --log error "${MSG}"
if [[ ${RET} -eq "${EXIT_ERROR_STOP}" ]]; then
# If we can't process the PRIOR_SETTINGS_FILE we can't really continue.
# TODO: Maybe we copy all the camera-specific files over and let makeChanges.sh create
# the new settings file based on the camera-specific one, and let the user know to
# check the settings since they may be old.
exit_installation 1 "${STATUS_ERROR}" "Unable to check prior settings file."
fi
fi

# Camera-specific settings file names are:
Expand Down Expand Up @@ -2133,7 +2147,7 @@ install_overlay()

exit_with_image 1 "${STATUS_ERROR}" "${M}."
fi
echo "${STATUS_NAME}='true'" >> "${TEMP_STATUS_FILE}"
echo "${STATUS_NAME}='true'" >> "${STATUS_FILE_TEMP}"
done < "${ALLSKY_REPO}/requirements${R}.txt"

# Add the status back in.
Expand Down Expand Up @@ -2350,7 +2364,7 @@ exit_installation()
clear_status
else
[[ -n ${MORE_STATUS} ]] && MORE_STATUS="; MORE_STATUS='${MORE_STATUS}'"
echo -e "STATUS_INSTALLATION='${STATUS}'${MORE_STATUS}" > "${STATUS_FILE}"
echo -e "STATUS_INSTALLATION='${STATUS_CODE}'${MORE_STATUS}" > "${STATUS_FILE}"
echo -e "${STATUS_VARIABLES[@]}" >> "${STATUS_FILE}"
fi
fi
Expand All @@ -2361,10 +2375,14 @@ exit_installation()
}


####
handle_interrupts()
{
display_msg --log info "\nGot interrupt - saving installation status, then exiting.\n"
exit_installation 1 "${STATUS_INT}" "Saving status."
}

####################### Main part of program

OS="$(grep CODENAME /etc/os-release | cut -d= -f2)" # usually buster or bullseye
############################################## Main part of program

##### Calculate whiptail sizes
calc_wt_size
Expand Down Expand Up @@ -2439,6 +2457,7 @@ TESTING="${TESTING}" # xxx keeps shellcheck quiet
shift
done


if [[ -n ${FUNCTION} ]]; then
# Don't log when a single function is executed.
DISPLAY_MSG_LOG=""
Expand All @@ -2451,6 +2470,8 @@ fi
[[ ${HELP} == "true" ]] && usage_and_exit 0
[[ ${OK} == "false" ]] && usage_and_exit 1

trap "handle_interrupts" SIGTERM SIGINT

# See if we should skip some steps.
# When most function are called they add a variable with the function's name set to "true".
if [[ -z ${FUNCTION} && -s ${STATUS_FILE} ]]; then
Expand Down
17 changes: 13 additions & 4 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,10 @@ function settings()
{
local M="${ME:-settings}"
local FIELD="${1}"
[[ ${FIELD:0:1} != "." ]] && echo "${M}: Field names must begin with period '.'" >&2 && return 1
if [[ ${FIELD:0:1} != "." ]]; then
echo "${M}: Field names must begin with period '.'" >&2
return 1
fi

local FILE="${2:-${SETTINGS_FILE}}"
if j="$( jq -r "${FIELD}" "${FILE}" )" ; then
Expand Down Expand Up @@ -506,10 +509,16 @@ function check_settings_link()
FULL_FILE="${1}"
if [[ -z ${FULL_FILE} ]]; then
echo "check_settings_link(): Settings file not specified."
return 1
return "${EXIT_ERROR_STOP}"
fi
if [[ -z ${CAMERA_TYPE} ]]; then
CAMERA_TYPE="$( settings .cameraType "${FULL_FILE}" )"
[[ $? -ne 0 || -z ${CAMERA_TYPE} ]] && return "${EXIT_ERROR_STOP}"
fi
if [[ -z ${CAMERA_MODEL} ]]; then
CAMERA_MODEL="$( settings .cameraModel "${FULL_FILE}" )"
[[ $? -ne 0 || -z ${CAMERA_TYPE} ]] && return "${EXIT_ERROR_STOP}"
fi
[[ -z ${CAMERA_TYPE} ]] && CAMERA_TYPE="$( settings .cameraType "${FULL_FILE}" )"
[[ -z ${CAMERA_MODEL} ]] && CAMERA_MODEL="$( settings .cameraModel "${FULL_FILE}" )"

DIRNAME="$( dirname "${FULL_FILE}" )"
FILE="$( basename "${FULL_FILE}" )"
Expand Down