1
0
mirror of https://github.com/mailcow/mailcow-dockerized.git synced 2025-12-11 00:46:01 +00:00

update: moved _modules initialization and update at the beginning of update script

This commit is contained in:
DerLinkman
2025-12-03 16:54:26 +01:00
parent 9a2887cf46
commit 930ca76ea7

View File

@@ -20,11 +20,28 @@ fi
BRANCH="$(cd "${SCRIPT_DIR}" && git rev-parse --abbrev-ref HEAD)"
MODULE_DIR="${SCRIPT_DIR}/_modules"
# Calculate hash before fetch
if [[ -d "${MODULE_DIR}" && -n "$(ls -A "${MODULE_DIR}" 2>/dev/null)" ]]; then
MODULES_HASH_BEFORE=$(find "${MODULE_DIR}" -type f -exec sha256sum {} \; 2>/dev/null | sort | sha256sum | awk '{print $1}')
else
MODULES_HASH_BEFORE="EMPTY"
fi
echo -e "\e[33mFetching latest _modules from origin/${BRANCH}…\e[0m"
git fetch origin "${BRANCH}"
git checkout "origin/${BRANCH}" -- _modules
if [[ ! -d "${MODULE_DIR}" || -z "$(ls -A "${MODULE_DIR}")" ]]; then
echo -e "\e[33m_modules is missing or empty fetching all Modules from origin/${BRANCH}\e[0m"
git fetch origin "${BRANCH}"
git checkout "origin/${BRANCH}" -- _modules
echo -e "\e[33mDone. Please restart the script...\e[0m"
echo -e "\e[31mError: _modules is still missing or empty after fetch!\e[0m"
exit 2
fi
# Calculate hash after fetch
MODULES_HASH_AFTER=$(find "${MODULE_DIR}" -type f -exec sha256sum {} \; 2>/dev/null | sort | sha256sum | awk '{print $1}')
# Check if modules changed
if [[ "${MODULES_HASH_BEFORE}" != "${MODULES_HASH_AFTER}" ]]; then
echo -e "\e[33m_modules have been updated. Please restart the update script.\e[0m"
exit 2
fi
@@ -320,28 +337,6 @@ if [ ! "$DEV" ]; then
chmod +x update.sh
EXIT_COUNT+=1
fi
MODULE_DIR="$(dirname "$0")/_modules"
echo -e "\e[32mChecking for updates in _modules...\e[0m"
if [ ! -d "${MODULE_DIR}" ] || [ -z "$(ls -A "${MODULE_DIR}")" ]; then
echo -e "\e[33m_modules missing or empty — fetching from origin...\e[0m"
git checkout "origin/${BRANCH}" -- _modules
else
OLD_SUM="$(find "${MODULE_DIR}" -type f -exec sha1sum {} \; | sort | sha1sum)"
git fetch origin
git checkout "origin/${BRANCH}" -- _modules
NEW_SUM="$(find "${MODULE_DIR}" -type f -exec sha1sum {} \; | sort | sha1sum)"
if [[ "${OLD_SUM}" != "${NEW_SUM}" ]]; then
EXIT_COUNT+=1
fi
fi
if [ ${EXIT_COUNT} -ge 1 ]; then
echo "Changes for the update Script, please run this script again, exiting!"
exit 2
fi
fi
if [ ! "$FORCE" ]; then