Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions install/ubuntu24/start.ubuntu24.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,31 @@ else
fi
fi

# create log and api mounts

echo "---------------------------------------------------------"
echo "[INSTALL] Create log and api mounts"
echo "---------------------------------------------------------"
echo

echo "[INSTALL] Cleaning up old mounts if any"
umount "${INSTALL_DIR}/log"
umount "${INSTALL_DIR}/api"

echo "[INSTALL] Creating log and api folders if they don't exist"
mkdir -p "${INSTALL_DIR}/log" "${INSTALL_DIR}/api"
umount "${INSTALL_DIR}/log" 2>/dev/null || true
umount "${INSTALL_DIR}/api" 2>/dev/null || true
mount -t tmpfs -o size=32m,noexec,nosuid,nodev tmpfs "${INSTALL_DIR}/log"
mount -t tmpfs -o size=16m,noexec,nosuid,nodev tmpfs "${INSTALL_DIR}/api"
# Create an empty log files

# Create the execution_queue.log file if it doesn't exist
echo "[INSTALL] Mounting log and api folders as tmpfs"
mount -t tmpfs -o noexec,nosuid,nodev tmpfs "${INSTALL_DIR}/log"
mount -t tmpfs -o noexec,nosuid,nodev tmpfs "${INSTALL_DIR}/api"

Comment on lines +153 to +156

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Make tmpfs sizing configurable and fail fast on mount errors.

Dropping hard limits aligns with the PR goal, but allow opt-in sizing via env to prevent host-wide OOM in constrained setups, and stop on mount failure instead of continuing.

-echo "[INSTALL] Mounting log and api folders as tmpfs"
-mount -t tmpfs -o noexec,nosuid,nodev tmpfs "${INSTALL_DIR}/log"
-mount -t tmpfs -o noexec,nosuid,nodev tmpfs "${INSTALL_DIR}/api"
+echo "[INSTALL] Mounting log and api folders as tmpfs"
+# Optional sizing via env: TMPFS_LOG_SIZE/TMPFS_API_SIZE (e.g., "128m" or "20%")
+LOG_TMPFS_OPTS=${LOG_TMPFS_OPTS:-"noexec,nosuid,nodev${TMPFS_LOG_SIZE:+,size=${TMPFS_LOG_SIZE}}"}
+API_TMPFS_OPTS=${API_TMPFS_OPTS:-"noexec,nosuid,nodev${TMPFS_API_SIZE:+,size=${TMPFS_API_SIZE}}"}
+mount -t tmpfs -o "$LOG_TMPFS_OPTS" tmpfs "${INSTALL_DIR}/log" \
+  || { echo "[INSTALL] ERROR: failed to mount ${INSTALL_DIR}/log tmpfs"; exit 1; }
+mount -t tmpfs -o "$API_TMPFS_OPTS" tmpfs "${INSTALL_DIR}/api" \
+  || { echo "[INSTALL] ERROR: failed to mount ${INSTALL_DIR}/api tmpfs"; exit 1; }

Run after install to confirm mounts:


🏁 Script executed:

#!/bin/bash
mount | awk '$3 ~ /(\/app\/log|\/app\/api)/'

Length of output: 43


🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE="install/ubuntu24/start.ubuntu24.sh"
echo "PWD: $(pwd)"
if [ -f "$FILE" ]; then
  echo "FOUND: $FILE"
  echo "---- lines 140-170 ----"
  nl -ba "$FILE" | sed -n '140,170p'
  echo "---- grep for tmpfs mounts in file ----"
  rg -n "mount -t tmpfs" "$FILE" || true
else
  echo "$FILE not found, searching repository for start.*.sh under install/"
  rg -n --hidden "start.*\\.sh" install || true
  echo "---- searching repo for tmpfs mounts ----"
  rg -n "mount -t tmpfs" || true
fi

Length of output: 130


🏁 Script executed:

#!/bin/bash
FILE="install/ubuntu24/start.ubuntu24.sh"
echo "PWD: $(pwd)"
echo "ls install/ubuntu24:"
ls -la install/ubuntu24 2>/dev/null || true

if [ -f "$FILE" ]; then
  echo "FOUND: $FILE"
  echo "---- lines 140-170 ----"
  if command -v sed >/dev/null 2>&1; then
    sed -n '140,170p' "$FILE" 2>/dev/null || true
  elif command -v awk >/dev/null 2>&1; then
    awk 'NR>=140 && NR<=170{print NR ":" $0}' "$FILE" || true
  else
    tail -n +140 "$FILE" | head -n 31 || true
  fi

  echo "---- grep for 'mount -t tmpfs' in file ----"
  grep -n -- 'mount -t tmpfs' "$FILE" 2>/dev/null || echo "no match in file"

  echo "---- grep for 'tmpfs' in file ----"
  grep -n -- 'tmpfs' "$FILE" 2>/dev/null || echo "no tmpfs occurrences in file"

else
  echo "$FILE not found; searching install/ for start*.sh"
  if command -v rg >/dev/null 2>&1; then
    rg -n --hidden "start.*\.sh" install || true
  else
    find install -type f -name "start*.sh" -print || true
  fi

  echo "---- searching repo for 'mount -t tmpfs' ----"
  if command -v rg >/dev/null 2>&1; then
    rg -n 'mount -t tmpfs' || true
  else
    grep -nR -- 'mount -t tmpfs' . || true
  fi
fi

echo "---- check mount availability (sandbox) ----"
if command -v mount >/dev/null 2>&1; then
  echo "mount found at: $(command -v mount)"
  mount | awk '$3 ~ /(\/app\/log|\/app\/api)/' || true
else
  echo "mount: not found in this sandbox; cannot verify live mounts"
fi

Length of output: 2115


Make tmpfs sizing configurable and fail fast on mount errors.

File: install/ubuntu24/start.ubuntu24.sh (around lines 153–155) — add env-configurable sizes and exit if mounts fail.

-echo "[INSTALL] Mounting log and api folders as tmpfs"
-mount -t tmpfs -o noexec,nosuid,nodev tmpfs "${INSTALL_DIR}/log"
-mount -t tmpfs -o noexec,nosuid,nodev tmpfs "${INSTALL_DIR}/api"
+echo "[INSTALL] Mounting log and api folders as tmpfs"
+# Optional sizing via env: TMPFS_LOG_SIZE/TMPFS_API_SIZE (e.g., "128m" or "20%")
+LOG_TMPFS_OPTS=${LOG_TMPFS_OPTS:-"noexec,nosuid,nodev${TMPFS_LOG_SIZE:+,size=${TMPFS_LOG_SIZE}}"}
+API_TMPFS_OPTS=${API_TMPFS_OPTS:-"noexec,nosuid,nodev${TMPFS_API_SIZE:+,size=${TMPFS_API_SIZE}}"}
+mount -t tmpfs -o "$LOG_TMPFS_OPTS" tmpfs "${INSTALL_DIR}/log" \
+  || { echo "[INSTALL] ERROR: failed to mount ${INSTALL_DIR}/log tmpfs"; exit 1; }
+mount -t tmpfs -o "$API_TMPFS_OPTS" tmpfs "${INSTALL_DIR}/api" \
+  || { echo "[INSTALL] ERROR: failed to mount ${INSTALL_DIR}/api tmpfs"; exit 1; }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echo "[INSTALL] Mounting log and api folders as tmpfs"
mount -t tmpfs -o noexec,nosuid,nodev tmpfs "${INSTALL_DIR}/log"
mount -t tmpfs -o noexec,nosuid,nodev tmpfs "${INSTALL_DIR}/api"
echo "[INSTALL] Mounting log and api folders as tmpfs"
# Optional sizing via env: TMPFS_LOG_SIZE/TMPFS_API_SIZE (e.g., "128m" or "20%")
LOG_TMPFS_OPTS=${LOG_TMPFS_OPTS:-"noexec,nosuid,nodev${TMPFS_LOG_SIZE:+,size=${TMPFS_LOG_SIZE}}"}
API_TMPFS_OPTS=${API_TMPFS_OPTS:-"noexec,nosuid,nodev${TMPFS_API_SIZE:+,size=${TMPFS_API_SIZE}}"}
mount -t tmpfs -o "$LOG_TMPFS_OPTS" tmpfs "${INSTALL_DIR}/log" \
|| { echo "[INSTALL] ERROR: failed to mount ${INSTALL_DIR}/log tmpfs"; exit 1; }
mount -t tmpfs -o "$API_TMPFS_OPTS" tmpfs "${INSTALL_DIR}/api" \
|| { echo "[INSTALL] ERROR: failed to mount ${INSTALL_DIR}/api tmpfs"; exit 1; }


# Create log files if they don't exist
echo "[INSTALL] Creating log files if they don't exist"
touch "${INSTALL_DIR}"/log/{app.log,execution_queue.log,app_front.log,app.php_errors.log,stderr.log,stdout.log,db_is_locked.log}
touch "${INSTALL_DIR}"/api/user_notifications.json
# Create plugins sub-directory if it doesn't exist in case a custom log folder is used
mkdir -p "${INSTALL_DIR}"/log/plugins


# Fixing file permissions
echo "[INSTALL] Fixing file permissions"
chown root:www-data "${INSTALL_DIR}"/api/user_notifications.json
Expand Down