From 82c43bbcc7369d44f0f38cc6442ee0d6f5a20003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Capil=C3=A9?= Date: Mon, 2 Dec 2024 14:57:20 -0300 Subject: [PATCH] fix for when CORE_COMMIT is undefined or files/VERSION is empty --- core/files/entrypoint_nginx.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/files/entrypoint_nginx.sh b/core/files/entrypoint_nginx.sh index 489541d..6c4f5af 100755 --- a/core/files/entrypoint_nginx.sh +++ b/core/files/entrypoint_nginx.sh @@ -141,13 +141,14 @@ update_misp_data_files(){ # If $MISP_APP_FILES_PATH was not changed since the build, skip file updates there FILES_VERSION= MISP_APP_FILES_PATH=/var/www/MISP/app/files + CORE_COMMIT=${CORE_COMMIT:-${CORE_TAG}} if [ -f ${MISP_APP_FILES_PATH}/VERSION ]; then FILES_VERSION=$(cat ${MISP_APP_FILES_PATH}/VERSION) echo "... found local files/VERSION:" $FILES_VERSION - fi - if [ $FILES_VERSION = ${CORE_COMMIT:-${CORE_TAG}} ]; then - echo "... local files/ match distribution version, skipping file sync" - return 0; + if [ "$FILES_VERSION" = "${CORE_COMMIT:-$(jq -r '"v\(.major).\(.minor).\(.hotfix)"' /var/www/MISP/VERSION.json)}" ]; then + echo "... local files/ match distribution version, skipping file sync" + return 0; + fi fi for DIR in $(ls /var/www/MISP/app/files.dist); do if [ "$DIR" = "certs" ] || [ "$DIR" = "img" ] || [ "$DIR" == "taxonomies" ] ; then @@ -162,12 +163,11 @@ update_misp_data_files(){ enforce_misp_data_permissions(){ # If $MISP_APP_FILES_PATH was not changed since the build, skip file updates there - FILES_VERSION= MISP_APP_FILES_PATH=/var/www/MISP/app/files - if [ -f ${MISP_APP_FILES_PATH}/VERSION ]; then - FILES_VERSION=$(cat ${MISP_APP_FILES_PATH}/VERSION) - fi - if [ $FILES_VERSION != ${CORE_COMMIT:-${CORE_TAG}} ]; then + CORE_COMMIT=${CORE_COMMIT:-${CORE_TAG}} + if [ -f "${MISP_APP_FILES_PATH}/VERSION" ] && [ "$(cat ${MISP_APP_FILES_PATH}/VERSION)" = "${CORE_COMMIT:-$(jq -r '"v\(.major).\(.minor).\(.hotfix)"' /var/www/MISP/VERSION.json)}" ]; then + echo "... local files/ match distribution version, skipping data permissions in files/" + else echo "... chown -R www-data:www-data /var/www/MISP/app/tmp" && find /var/www/MISP/app/tmp \( ! -user www-data -or ! -group www-data \) -exec chown www-data:www-data {} + # Files are also executable and read only, because we have some rogue scripts like 'cake' and we can not do a full inventory echo "... chmod -R 0550 files /var/www/MISP/app/tmp" && find /var/www/MISP/app/tmp -not -perm 550 -type f -exec chmod 0550 {} +