From 6f06b3a5edfd09f16af45109e7c760394f1dede9 Mon Sep 17 00:00:00 2001
From: Martin Weise <martin.weise@tuwien.ac.at>
Date: Fri, 15 Nov 2024 11:48:34 -0600
Subject: [PATCH] Updated checks

---
 .gitlab-ci.yml | 15 ++++++++++++---
 install.sh     | 18 ++++++++++++------
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 336daf1eb3..9a8712eb44 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -162,9 +162,18 @@ verify-install-script:
   variables:
     SKIP_CHECKS: 1
   script:
-    - apk add bash curl
-    - bash install.sh
-    - exit 0
+    - "apk add bash curl"
+    - "curl -sSL https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/release-${DOC_VERSION}/install.sh | bash | grep 'Success!'"
+
+verify-dist:
+  image: docker.io/alpine:3.20
+  stage: verify
+  only:
+    refs:
+      - /^release-.*/
+  script:
+    - "apk add curl"
+    - "curl -v --output /dev/null --fail https://www.ifs.tuwien.ac.at/infrastructures/dbrepo/${APP_VERSION}/dist.tar.gz"
 
 lint-helm-chart:
   image: docker.io/alpine:3.20
diff --git a/install.sh b/install.sh
index 74206b9e02..711bd024f2 100644
--- a/install.sh
+++ b/install.sh
@@ -43,12 +43,18 @@ if [[ $SKIP_CHECKS -eq 0 ]] && [[ $DOWNLOAD_ONLY -ne 1 ]]; then
   fi
   MAX_MAP_COUNT=$(cat /proc/sys/vm/max_map_count)
   if [[ $MAX_MAP_COUNT -lt $MIN_MAP_COUNT ]]; then
-    echo "You do not have enough max. map counts:"
-    echo ""
-    echo "  - we found max. ${MAX_MAP_COUNT} map count instead of necessary ${MIN_MAP_COUNT}"
-    echo "  - update your /etc/sysctl.conf file and add the line 'vm.max_map_count=${MIN_MAP_COUNT}' at the end and apply it with 'sysctl -p'"
-    echo "  - if you believe this is a mistake, skip startup checks with the SKIP_CHECKS=1 flag"
-    exit 4
+    echo "You do not have enough max. map counts: found ${MAX_MAP_COUNT} instead of minimum ${MIN_MAP_COUNT}"
+    if [ $(id -u) -eq 0 ]; then
+        echo "  - attempt to update the /etc/sysctl.conf file  and add the line 'vm.max_map_count=${MIN_MAP_COUNT}' at the end"
+        echo "vm.max_map_count=${MIN_MAP_COUNT}" >> /etc/sysctl.conf
+        sysctl -p
+        if [[ $MAX_MAP_COUNT -lt $MIN_MAP_COUNT ]]; then
+            exit 4
+        fi
+    else
+        echo "  - you need to re-run the install.sh script as root to fix this"
+        exit 4
+    fi
   else
     echo "MAP COUNT ${MAX_MAP_COUNT} OK"
   fi
-- 
GitLab