Skip to content

Commit

Permalink
Update install.sh: streamlining
Browse files Browse the repository at this point in the history
Indented a lot of lines, but few functional changes.
  • Loading branch information
EricClaeys authored Oct 24, 2023
1 parent 9235415 commit c05e0cf
Showing 1 changed file with 110 additions and 103 deletions.
213 changes: 110 additions & 103 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -818,21 +818,22 @@ install_webserver_et_al()
if ! check_success $? "lighttpd installation failed" "${TMP}" "${DEBUG}" ; then
exit_with_image 1 "${STATUS_ERROR}" "lighttpd installation failed"
fi

FINAL_LIGHTTPD_FILE="/etc/lighttpd/lighttpd.conf"
sed \
-e "s;XX_ALLSKY_WEBUI_XX;${ALLSKY_WEBUI};g" \
-e "s;XX_ALLSKY_HOME_XX;${ALLSKY_HOME};g" \
-e "s;XX_ALLSKY_IMAGES_XX;${ALLSKY_IMAGES};g" \
-e "s;XX_ALLSKY_CONFIG_XX;${ALLSKY_CONFIG};g" \
-e "s;XX_ALLSKY_WEBSITE_XX;${ALLSKY_WEBSITE};g" \
-e "s;XX_ALLSKY_OVERLAY_XX;${ALLSKY_OVERLAY};g" \
-e "s;XX_ALLSKY_DOCUMENTATION_XX;${ALLSKY_DOCUMENTATION};g" \
"${REPO_LIGHTTPD_FILE}" > /tmp/x
sudo install -m 0644 /tmp/x "${FINAL_LIGHTTPD_FILE}" && rm -f /tmp/x

STATUS_VARIABLES+=("install_webserver_et_al='true'\n")
fi

FINAL_LIGHTTPD_FILE="/etc/lighttpd/lighttpd.conf"
sed \
-e "s;XX_ALLSKY_WEBUI_XX;${ALLSKY_WEBUI};g" \
-e "s;XX_ALLSKY_HOME_XX;${ALLSKY_HOME};g" \
-e "s;XX_ALLSKY_IMAGES_XX;${ALLSKY_IMAGES};g" \
-e "s;XX_ALLSKY_CONFIG_XX;${ALLSKY_CONFIG};g" \
-e "s;XX_ALLSKY_WEBSITE_XX;${ALLSKY_WEBSITE};g" \
-e "s;XX_ALLSKY_OVERLAY_XX;${ALLSKY_OVERLAY};g" \
-e "s;XX_ALLSKY_DOCUMENTATION_XX;${ALLSKY_DOCUMENTATION};g" \
"${REPO_LIGHTTPD_FILE}" > /tmp/x
sudo install -m 0644 /tmp/x "${FINAL_LIGHTTPD_FILE}" && rm -f /tmp/x

# Ignore output since it may already be enabled.
sudo lighty-enable-mod fastcgi-php > /dev/null 2>&1

Expand Down Expand Up @@ -2249,118 +2250,124 @@ do_update()
install_overlay()
{
if [[ ${installed_PHP_modules} != "true" ]]; then
display_msg --log progress "Installing PHP modules."
display_msg --log progress "Installing PHP modules and dependencies."
TMP="${ALLSKY_INSTALLATION_LOGS}/PHP_modules.log"
sudo apt-get --assume-yes install php-zip php-sqlite3 python3-pip > "${TMP}" 2>&1
check_success $? "PHP module installation failed" "${TMP}" "${DEBUG}"
[[ $? -ne 0 ]] && exit_with_image 1 "${STATUS_ERROR}" "PHP module install failed."

display_msg --log progress "Installing other PHP dependencies."
TMP="${ALLSKY_INSTALLATION_LOGS}/libatlas.log"
sudo apt-get --assume-yes install libatlas-base-dev > "${TMP}" 2>&1
check_success $? "PHP dependencies failed" "${TMP}" "${DEBUG}"
[[ $? -ne 0 ]] && exit_with_image 1 "${STATUS_ERROR}" "PHP dependencies failed."

STATUS_VARIABLES+=( "installed_PHP_modules='true'\n" )
fi

# Doing all the python dependencies at once can run /tmp out of space, so do one at a time.
# This also allows us to display progress messages.
M=" for ${OS^}"
R="-${OS}"
if [[ ${OS} == "buster" ]]; then
# Force pip upgrade, without this installations on Buster fail
pip3 install --upgrade pip > /dev/null 2>&1
elif [[ ${OS} != "bullseye" && ${OS} != "bookworm" ]]; then
# TODO: is this an error? Unknown OS?
M=""
R=""
fi

local NAME="Python_dependencies"
display_msg --logonly info "Attempting to locate Python dependency file"

local PREFIX="${ALLSKY_REPO}/requirements"
for REQUIREMENTS_FILE in "${PREFIX}${R}-${LONG_BITS}.txt" \
"${PREFIX}${R}.txt" \
"${PREFIX}-${LONG_BITS}.txt" \
"${PREFIX}.txt" \
"END"
do
if [[ ${REQUIREMENTS_FILE} == "END" ]]; then
display_msg --log error "Unable to find a requirements file!"
exit 2
fi

if [[ -f ${REQUIREMENTS_FILE} ]]; then
display_msg --logonly info "${REQUIREMENTS_FILE} - File found!"
else
display_msg --logonly info "${REQUIREMENTS_FILE} - File not found!"
fi
done

local NUM_TO_INSTALL=$( wc -l < "${REQUIREMENTS_FILE}" )

# See how many have already been installed - if all, then skip this step.
local NUM_INSTALLED="$( set | grep -c "^${NAME}" )"
if [[ ${NUM_INSTALLED} -eq "${NUM_TO_INSTALL}" ||
${installed_Python_dependencies} == "true" ]]; then
display_msg --logonly info "Skipping: ${NAME} - all packages already installed"
if [[ ${installed_python} == "true" ]]; then
display_msg --log info "Python and related packages already installed."
else
# AG - Bookworm mod 12/10/23
display_msg --log progress "Installing Python3-full and related packages."
local TMP="${ALLSKY_INSTALLATION_LOGS}/python_full.log"
(
sudo apt-get --assume-yes install python3-full &&
sudo apt-get --assume-yes install libgfortran5 libopenblas0-pthread
) > "${TMP}" 2>&1
check_success $? "python3-full install failed" "${TMP}" "${DEBUG}"
[[ $? -ne 0 ]] && exit_with_image 1 "${STATUS_ERROR}" "python3-full install failed."
# Doing all the python dependencies at once can run /tmp out of space, so do one at a time.
# This also allows us to display progress messages.
M=" for ${OS^}"
R="-${OS}"
if [[ ${OS} == "buster" ]]; then
# Force pip upgrade, without this installations on Buster fail
pip3 install --upgrade pip > /dev/null 2>&1
elif [[ ${OS} != "bullseye" && ${OS} != "bookworm" ]]; then
# TODO: is this an error? Unknown OS?
M=""
R=""
fi

python3 -m venv "${ALLSKY_HOME}/venv"
#shellcheck disable=SC1090,SC1091
source "${ALLSKY_HOME}/venv/bin/activate"
local NAME="Python_dependencies"
display_msg --logonly info "Attempting to locate Python dependency file"

local TMP="${ALLSKY_INSTALLATION_LOGS}/${NAME}"
display_msg --log progress "Installing ${NAME}${M}:"
local COUNT=0
rm -f "${STATUS_FILE_TEMP}"
while read -r package
local PREFIX="${ALLSKY_REPO}/requirements"
for REQUIREMENTS_FILE in "${PREFIX}${R}-${LONG_BITS}.txt" \
"${PREFIX}${R}.txt" \
"${PREFIX}-${LONG_BITS}.txt" \
"${PREFIX}.txt" \
"END"
do
((COUNT++))
echo "${package}" > /tmp/package
if [[ ${COUNT} -lt 10 ]]; then
C=" ${COUNT}"
else
C="${COUNT}"
if [[ ${REQUIREMENTS_FILE} == "END" ]]; then
display_msg --log error "Unable to find a requirements file!"
exit_with_image 1 "No requirements file"
fi

local PACKAGE=" === Package # ${C} of ${NUM_TO_INSTALL}: [${package}]"
# Need indirection since the ${STATUS_NAME} is the variable name and we want its value.
local STATUS_NAME="${NAME}_${COUNT}"
eval "STATUS_VALUE=\${${STATUS_NAME}}"
if [[ ${STATUS_VALUE} == "true" ]]; then
display_msg --log progress "${PACKAGE} - already installed."
continue
if [[ -f ${REQUIREMENTS_FILE} ]]; then
display_msg --logonly info "${REQUIREMENTS_FILE} - File found!"
else
display_msg --logonly info "${REQUIREMENTS_FILE} - File not found!"
fi
display_msg --log progress "${PACKAGE}"
done

local NUM_TO_INSTALL=$( wc -l < "${REQUIREMENTS_FILE}" )

# See how many have already been installed - if all, then skip this step.
local NUM_INSTALLED="$( set | grep -c "^${NAME}" )"
if [[ ${NUM_INSTALLED} -eq "${NUM_TO_INSTALL}" ||
${installed_Python_dependencies} == "true" ]]; then
display_msg --logonly info "Skipping: ${NAME} - all packages already installed"
else
# AG - Bookworm mod 12/10/23
display_msg --log progress "Installing Python3-full and related packages."
local TMP="${ALLSKY_INSTALLATION_LOGS}/python_full.log"
(
sudo apt-get --assume-yes install python3-full &&
sudo apt-get --assume-yes install libgfortran5 libopenblas0-pthread
) > "${TMP}" 2>&1
check_success $? "python3-full install failed" "${TMP}" "${DEBUG}"
[[ $? -ne 0 ]] && exit_with_image 1 "${STATUS_ERROR}" "python3-full install failed."

python3 -m venv "${ALLSKY_HOME}/venv"
#shellcheck disable=SC1090,SC1091
source "${ALLSKY_HOME}/venv/bin/activate"

local TMP="${ALLSKY_INSTALLATION_LOGS}/${NAME}"
display_msg --log progress "Installing ${NAME}${M}:"
local COUNT=0
rm -f "${STATUS_FILE_TEMP}"
while read -r package
do
((COUNT++))
echo "${package}" > /tmp/package
if [[ ${COUNT} -lt 10 ]]; then
C=" ${COUNT}"
else
C="${COUNT}"
fi

L="${TMP}.${COUNT}.log"
local M="${NAME} [${package}] failed"
pip3 install --no-warn-script-location -r /tmp/package > "${L}" 2>&1
# These files are too big to display so pass in "0" instead of ${DEBUG}.
if ! check_success $? "${M}" "${L}" 0 ; then
rm -fr "${PIP3_BUILD}"
local PACKAGE=" === Package # ${C} of ${NUM_TO_INSTALL}: [${package}]"
# Need indirection since the ${STATUS_NAME} is the variable name and we want its value.
local STATUS_NAME="${NAME}_${COUNT}"
eval "STATUS_VALUE=\${${STATUS_NAME}}"
if [[ ${STATUS_VALUE} == "true" ]]; then
display_msg --log progress "${PACKAGE} - already installed."
continue
fi
display_msg --log progress "${PACKAGE}"

# Add current status
update_status_from_temp_file
L="${TMP}.${COUNT}.log"
local M="${NAME} [${package}] failed"
pip3 install --no-warn-script-location -r /tmp/package > "${L}" 2>&1
# These files are too big to display so pass in "0" instead of ${DEBUG}.
if ! check_success $? "${M}" "${L}" 0 ; then
rm -fr "${PIP3_BUILD}"

exit_with_image 1 "${STATUS_ERROR}" "${M}."
fi
echo "${STATUS_NAME}='true'" >> "${STATUS_FILE_TEMP}"
done < "${REQUIREMENTS_FILE}"
# Add current status
update_status_from_temp_file

# Add the status back in.
update_status_from_temp_file
exit_with_image 1 "${STATUS_ERROR}" "${M}."
fi
echo "${STATUS_NAME}='true'" >> "${STATUS_FILE_TEMP}"
done < "${REQUIREMENTS_FILE}"

# Add the status back in.
update_status_from_temp_file
fi

STATUS_VARIABLES+=( "installed_python='true'\n" )
fi

if [[ ${installing_Trutype_fonts} != "true" ]]; then
Expand Down Expand Up @@ -2540,7 +2547,7 @@ check_new_exposure_algorithm()
local FIELD="experimentalExposure"
local NEW="$( settings ".${FIELD}" )"
[[ ${NEW} -eq 1 ]] && return

MSG="There is a new auto-exposure algorithm for nighttime images that initial testing indicates"
MSG="${MSG} it creates better images at night and during the day-to-night transition."
MSG="${MSG}\n\nDo you want to use it?"
Expand Down Expand Up @@ -2812,7 +2819,7 @@ if [[ -z ${FUNCTION} && -s ${STATUS_FILE} ]]; then
unset get_desired_locale # forces a re-prompt
unset CURRENT_LOCALE # It will get re-calculated
fi

else
MSG="Do you want to restart the installation from the beginning?"
MSG="${MSG}\n\nSelecting <No> will exit the installation without making any changes."
Expand Down

0 comments on commit c05e0cf

Please sign in to comment.