From 02942947559d3c0048bb3ebe62ccd1ec2272758a Mon Sep 17 00:00:00 2001 From: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> Date: Mon, 17 Feb 2025 01:14:18 +0100 Subject: [PATCH] fix: revert `__declare_readonly` overcomplication (#4372) * fix: revert `__declare_readonly` overcomplication * chore: remove redundant checks Signed-off-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> --- target/scripts/startup/setup.d/mail_state.sh | 6 ++++-- target/scripts/startup/variables-stack.sh | 15 --------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/target/scripts/startup/setup.d/mail_state.sh b/target/scripts/startup/setup.d/mail_state.sh index 931e3c05..34623859 100644 --- a/target/scripts/startup/setup.d/mail_state.sh +++ b/target/scripts/startup/setup.d/mail_state.sh @@ -1,9 +1,11 @@ #!/bin/bash +DMS_STATE_DIR='/var/mail-state' + # Consolidate all states into a single directory # (/var/mail-state) to allow persistence using docker volumes function _setup_save_states() { - if [[ ! -d ${DMS_STATE_DIR:?DMS_STATE_DIR is not set} ]]; then + if [[ ! -d ${DMS_STATE_DIR} ]]; then _log 'debug' "'${DMS_STATE_DIR}' is not present - not consolidating state" return 0 fi @@ -91,7 +93,7 @@ function _setup_save_states() { # These corrections are to fix changes to UID/GID values between upgrades, # or when ownership/permissions were altered externally on the host (eg: migration or system scripts) function _setup_adjust_state_permissions() { - [[ ! -d ${DMS_STATE_DIR:?DMS_STATE_DIR is not set} ]] && return 0 + [[ ! -d ${DMS_STATE_DIR} ]] && return 0 # This ensures the user and group of the files from the external mount have their # numeric ID values in sync. New releases where the installed packages order changes diff --git a/target/scripts/startup/variables-stack.sh b/target/scripts/startup/variables-stack.sh index f8f5af5e..3d0d1bee 100644 --- a/target/scripts/startup/variables-stack.sh +++ b/target/scripts/startup/variables-stack.sh @@ -16,17 +16,6 @@ function _early_variables_setup() { __environment_variables_export } -# Declare a variable as readonly if it is not already set. -function __declare_readonly() { - local VARIABLE_NAME=${1:?Variable name required when declaring a variable as readonly} - local VARIABLE_VALUE=${2:?Variable value required when declaring a variable as readonly} - - if [[ ! -v ${VARIABLE_NAME} ]]; then - readonly "${VARIABLE_NAME}=${VARIABLE_VALUE}" - VARS[${VARIABLE_NAME}]="${VARIABLE_VALUE}" - fi -} - # This function handles variables that are deprecated. This allows a # smooth transition period, without the need of removing a variable # completely with a single version. @@ -73,10 +62,6 @@ function __environment_variables_general_setup() { VARS[DMS_VMAIL_UID]="${DMS_VMAIL_UID:=5000}" VARS[DMS_VMAIL_GID]="${DMS_VMAIL_GID:=5000}" - # internal variables are next - - __declare_readonly 'DMS_STATE_DIR' '/var/mail-state' - # user-customizable are last _log 'trace' 'Setting anti-spam & anti-virus environment variables'