Skip to content

Commit 79eb9d7

Browse files
committed
feat(base): ensure ampstart fails/continues as appropriate
1 parent 949cc42 commit 79eb9d7

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

scripts/base/ampstart.sh

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,38 +43,47 @@ chown -R amp:amp /home/amp
4343

4444
# Make AMP binary executable
4545
AMP_BIN="/AMP/AMP_Linux_${ARCH}"
46-
[ -f "${AMP_BIN}" ] && chmod +x "${AMP_BIN}"
46+
chmod +x "${AMP_BIN}" || { echo "[Error] AMP binary not found or cannot be made executable"; exit 101; }
4747

48-
# Install extra dependencies if needed
48+
# Install extra dependencies if needed (non-fatal)
4949
REQUIRED_DEPS=()
5050
if [[ -n "${AMP_CONTAINER_DEPS:-}" ]]; then
5151
# shellcheck disable=SC2207
52-
REQUIRED_DEPS=($(jq -r '.[]? | select(type=="string" and length>0)' <<<"${AMP_CONTAINER_DEPS}" || echo))
52+
REQUIRED_DEPS=($(jq -r '.[]? | select(type=="string" and length>0)' <<<"${AMP_CONTAINER_DEPS}" 2>/dev/null || echo))
5353
fi
5454

5555
if ((${#REQUIRED_DEPS[@]})); then
5656
echo "[Info] Installing extra dependencies..."
57-
apt-get update
58-
apt-get install -o APT::Keep-Downloaded-Packages="false" -y --no-install-recommends --allow-downgrades "${REQUIRED_DEPS[@]}"
59-
apt-get clean
60-
rm -rf /var/lib/apt/lists/*
57+
(
58+
set +e
59+
apt-get update || echo "[Warn] apt-get update failed; continuing"
60+
apt-get install -y --no-install-recommends --allow-downgrades \
61+
-o APT::Keep-Downloaded-Packages="false" "${REQUIRED_DEPS[@]}" \
62+
|| echo "[Warn] apt-get install failed (bad package name?); continuing"
63+
apt-get clean >/dev/null 2>&1 || true
64+
rm -rf /var/lib/apt/lists/* || true
65+
)
6166
fi
6267

63-
# Set custom mountpoint permissions if needed
64-
if [ -n "${AMP_MOUNTPOINTS}" ]; then
65-
echo "[Info] Updating custom mountpoint permissions..."
68+
# Set custom mountpoint permissions if needed (non-fatal)
69+
if [[ -n "${AMP_MOUNTPOINTS:-}" ]]; then
70+
echo "[Info] Updating custom mountpoint permissions..."
6671
IFS=':' read -r -a dirs <<< "${AMP_MOUNTPOINTS}"
6772
for dir in "${dirs[@]}"; do
68-
[ -n "${dir}" ] || continue
69-
chown -R amp:amp "${dir}"
73+
[[ -n "${dir}" ]] || continue
74+
if [[ -e "${dir}" ]]; then
75+
chown -R amp:"${AMPGROUPID}" "${dir}" 2>/dev/null || echo "[Warn] chown failed for ${dir}; continuing"
76+
else
77+
echo "[Warn] Mountpoint not found: ${dir}; skipping"
78+
fi
7079
done
7180
fi
7281

73-
# Run custom start script if it exists
74-
if [ -f "/AMP/customstart.sh" ]; then
82+
# Run custom start script if it exists (non-fatal)
83+
if [[ -f "/AMP/customstart.sh" ]]; then
7584
echo "[Info] Running customstart.sh..."
76-
chmod +x /AMP/customstart.sh
77-
/AMP/customstart.sh
85+
chmod +x /AMP/customstart.sh 2>/dev/null || true
86+
( set +e; /AMP/customstart.sh; rc=$?; ((rc==0)) || echo "[Warn] customstart.sh exited with $rc; continuing" )
7887
fi
7988

8089
# Handoff

0 commit comments

Comments
 (0)