Skip to content

Commit ebe6872

Browse files
committed
test: revert to new version with no LD_LIBRARY_PATH
1 parent fb9a9ec commit ebe6872

File tree

1 file changed

+52
-62
lines changed

1 file changed

+52
-62
lines changed

scripts/base/ampstart.sh

Lines changed: 52 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,70 @@
11
#!/bin/bash
22

3-
echo "[Info] AMPStart for Docker"
4-
5-
if [ -z "${AMPUSERID}" ]; then
6-
echo "[Info] This docker image cannot be used directly by itself - it must be started by ampinstmgr"
7-
exit 100
8-
fi
3+
#set -Eeuo pipefail
4+
#trap 'echo "[ERR] line $LINENO: $BASH_COMMAND (exit $?)"' ERR
95

10-
#Check if the AMP user already exists
11-
getent passwd amp &> /dev/null
6+
echo "[Info] AMPStart for Docker"
7+
ARCH=$(uname -m)
128

13-
if [ "$?" == "0" ]; then
14-
echo "[Info] AMP user already exists, continuing..."
15-
else
16-
echo "[Info] Performing first-time container setup..."
17-
groupadd -r -g $AMPGROUPID amp > /dev/null
18-
useradd -m -d /home/amp -s /bin/bash -c "AMP Process User" -u $AMPUSERID -g $AMPGROUPID amp > /dev/null
19-
touch /home/amp/.gitconfig
20-
chown -R amp:amp /home/amp 2> /dev/null
21-
usermod -aG tty amp
22-
chmod +x /AMP/AMP_Linux_x86_64
23-
echo "[Info] Container setup complete."
24-
fi
9+
# Context check
10+
[ -z "${AMPUSERID}" ] && { echo "[Error] This docker image cannot be used directly by itself - it must be started by ampinstmgr"; exit 100; }
2511

26-
if [ -f "$INSTALLED_DEPS_FILE" ]; then
27-
INSTALLED_DEPS=$(jq -r '.[]' $INSTALLED_DEPS_FILE)
28-
else
29-
INSTALLED_DEPS=""
30-
echo "[]" > $INSTALLED_DEPS_FILE
31-
fi
12+
# Create /etc/machine-id (addresses Proton/dbus issues)
13+
mkdir -p /var/lib/dbus
14+
rm -f /etc/machine-id /var/lib/dbus/machine-id
15+
dbus-uuidgen --ensure=/etc/machine-id
16+
ln -s /etc/machine-id /var/lib/dbus/machine-id
3217

33-
REQUIRED_DEPS=$(echo $AMP_CONTAINER_DEPS | jq -r '.[]')
18+
# Set up amp user and group
19+
: "${AMPUSERID:?[Error] AMPUSERID not set}"
20+
: "${AMPGROUPID:?[Error] AMPGROUPID not set}"
21+
echo "[Info] Setting up amp user and group..."
22+
getent group "${AMPGROUPID}" >/dev/null 2>&1 || groupadd -r -g "${AMPGROUPID}" amp
23+
id -u amp >/dev/null 2>&1 || useradd -m -d /home/amp -s /bin/bash -c "AMP Process User" -u "${AMPUSERID}" -g "${AMPGROUPID}" amp
24+
usermod -aG tty amp
25+
touch /home/amp/.gitconfig
26+
chown -R amp:amp /home/amp 2> /dev/null
3427

35-
DEPS_TO_INSTALL=()
36-
for DEP in $REQUIRED_DEPS; do
37-
if ! [[ $INSTALLED_DEPS =~ $DEP ]]; then
38-
DEPS_TO_INSTALL+=($DEP)
39-
fi
40-
done
28+
# Make AMP binary executable
29+
AMP_BIN="/AMP/AMP_Linux_${ARCH}"
30+
[ -f "${AMP_BIN}" ] && chmod +x "${AMP_BIN}"
4131

42-
if [ ${#DEPS_TO_INSTALL[@]} -ne 0 ]; then
43-
echo "[Info] Installing dependencies..."
32+
# Install extra dependencies if needed
33+
REQUIRED_DEPS=()
34+
if [[ -n "${AMP_CONTAINER_DEPS:-}" ]]; then
35+
# shellcheck disable=SC2207
36+
REQUIRED_DEPS=($(jq -r '.[]? | select(type=="string" and length>0)' <<<"${AMP_CONTAINER_DEPS}" || echo))
37+
fi
38+
if ((${#REQUIRED_DEPS[@]})); then
39+
echo "[Info] Installing extra dependencies..."
4440
apt-get update
45-
apt-get install --allow-downgrades -y ${DEPS_TO_INSTALL[@]}
46-
47-
# for DEP in ${DEPS_TO_INSTALL[@]}; do
48-
# jq --arg dep "$DEP" '. += [$dep]' $INSTALLED_DEPS_FILE > temp && mv temp $INSTALLED_DEPS_FILE
49-
# done
50-
41+
apt-get install -o APT::Keep-Downloaded-Packages="false" -y --no-install-recommends --allow-downgrades "${REQUIRED_DEPS[@]}"
5142
apt-get clean
5243
rm -rf /var/lib/apt/lists/*
53-
echo "[Info] Installation complete."
54-
else
55-
echo "[Info] No missing dependencies to install."
5644
fi
5745

58-
if [ -n "$AMP_MOUNTPOINTS" ]; then
59-
echo "[Info] Updating mountpoint permissions..."
60-
IFS=':' read -r -a dirs <<< "$AMP_MOUNTPOINTS"
61-
46+
# Set custom mountpoint permissions if needed
47+
if [ -n "${AMP_MOUNTPOINTS}" ]; then
48+
echo "[Info] Updating custom mountpoint permissions..."
49+
IFS=':' read -r -a dirs <<< "${AMP_MOUNTPOINTS}"
6250
for dir in "${dirs[@]}"; do
63-
echo "[Info] - Updating $dir..."
64-
chown -R amp:amp "$dir"
51+
[ -n "${dir}" ] || continue
52+
chown -R amp:amp "${dir}"
6553
done
6654
fi
6755

68-
export AMPHOSTPLATFORM
69-
export AMP_CONTAINER
70-
export AMPMEMORYLIMIT
71-
export AMPSWAPLIMIT
72-
export AMPCONTAINERCPUS
73-
export AMP_CONTAINER_HOST_NETWORK
74-
#export AMP_SHARED_INSTALL
75-
#export DOTNET_GCHeapHardLimit=0x10000000
76-
77-
ARGS=$@
78-
exec su -l -w AMPHOSTPLATFORM,AMP_CONTAINER,AMPMEMORYLIMIT,AMP_CONTAINER_HOST_NETWORK,AMPSWAPLIMIT,AMPCONTAINERCPUS,LANG,LANGUAGE,LC_ALL -c "cd /AMP; HOME=/home/amp exec /AMP/AMP_Linux_x86_64 ${ARGS}; exit $?" -- amp
79-
exit $?
56+
# Run custom start script if it exists
57+
if [ -f "/AMP/customstart.sh" ]; then
58+
echo "[Info] Running customstart.sh..."
59+
chmod +x /AMP/customstart.sh
60+
/AMP/customstart.sh
61+
fi
8062

63+
# Handoff
64+
echo "[Info] Starting AMP..."
65+
exec su -l \
66+
-w AMPHOSTPLATFORM,AMP_CONTAINER,AMPMEMORYLIMIT,AMPSWAPLIMIT,AMPCONTAINERCPUS,AMP_CONTAINER_HOST_NETWORK,LANG,LANGUAGE,LC_ALL \
67+
amp -c '
68+
cd /AMP
69+
exec '"${AMP_BIN}"' "$@"
70+
' -- _ "$@"

0 commit comments

Comments
 (0)