Skip to content

Commit 6b6e0b7

Browse files
committed
feat(ampstart.sh): add AMP_INSTANCE_ID env var
1 parent c8a15b0 commit 6b6e0b7

3 files changed

Lines changed: 27 additions & 12 deletions

File tree

scripts/apps/redis/ampstart.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ ARCH=$(uname -m)
88
# Context check
99
[[ -z "${AMPUSERID}" ]] && { echo "[Error] This docker image cannot be used directly by itself - it must be started by ampinstmgr"; exit 100; }
1010

11-
# Create /etc/machine-id (addresses Proton/dbus issues)
11+
# Create /etc/machine-id using the instance UUID if AMP_INSTANCE_ID exists (addresses Proton/dbus issues)
1212
mkdir -p /var/lib/dbus
1313
rm -f /etc/machine-id /var/lib/dbus/machine-id
14-
dbus-uuidgen --ensure=/etc/machine-id
15-
ln -s /etc/machine-id /var/lib/dbus/machine-id
14+
if [[ -n "${AMP_INSTANCE_ID:-}" ]]; then
15+
printf '%s\n' "${AMP_INSTANCE_ID//-/}" > /etc/machine-id
16+
else
17+
dbus-uuidgen --ensure=/etc/machine-id
18+
fi
19+
ln -sf /etc/machine-id /var/lib/dbus/machine-id
20+
chmod 0444 /etc/machine-id
1621

1722
# Create /tmp/.X11-unix (for Xvfb etc)
1823
install -d -o root -g root -m 1777 /tmp/.X11-unix
@@ -110,7 +115,7 @@ keep_env=(
110115
CARGO_HOME="${CARGO_HOME}"
111116
)
112117
# Always keep these AMP_ env vars if set
113-
for v in AMPHOSTPLATFORM AMP_CONTAINER AMP_CONTAINER_HOST_NETWORK AMPMEMORYLIMIT AMPSWAPLIMIT AMPCONTAINERCPUS; do
118+
for v in AMPHOSTPLATFORM AMP_CONTAINER AMP_CONTAINER_HOST_NETWORK AMPMEMORYLIMIT AMPSWAPLIMIT AMPCONTAINERCPUS AMP_INSTANCE_ID; do
114119
if [[ -n "${!v-}" ]]; then keep_env+=("$v=${!v}"); fi
115120
done
116121
# Extra passthrough of env vars listed in AMP_ADDITIONAL_ENV_VARS in the Dockerfile

scripts/apps/uptime-kuma-2/ampstart.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ ARCH=$(uname -m)
88
# Context check
99
[[ -z "${AMPUSERID}" ]] && { echo "[Error] This docker image cannot be used directly by itself - it must be started by ampinstmgr"; exit 100; }
1010

11-
# Create /etc/machine-id (addresses Proton/dbus issues)
11+
# Create /etc/machine-id using the instance UUID if AMP_INSTANCE_ID exists (addresses Proton/dbus issues)
1212
mkdir -p /var/lib/dbus
1313
rm -f /etc/machine-id /var/lib/dbus/machine-id
14-
dbus-uuidgen --ensure=/etc/machine-id
15-
ln -s /etc/machine-id /var/lib/dbus/machine-id
14+
if [[ -n "${AMP_INSTANCE_ID:-}" ]]; then
15+
printf '%s\n' "${AMP_INSTANCE_ID//-/}" > /etc/machine-id
16+
else
17+
dbus-uuidgen --ensure=/etc/machine-id
18+
fi
19+
ln -sf /etc/machine-id /var/lib/dbus/machine-id
20+
chmod 0444 /etc/machine-id
1621

1722
# Create /tmp/.X11-unix (for Xvfb etc)
1823
install -d -o root -g root -m 1777 /tmp/.X11-unix
@@ -106,7 +111,7 @@ keep_env=(
106111
XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR}"
107112
)
108113
# Always keep these AMP_ env vars if set
109-
for v in AMPHOSTPLATFORM AMP_CONTAINER AMP_CONTAINER_HOST_NETWORK AMPMEMORYLIMIT AMPSWAPLIMIT AMPCONTAINERCPUS; do
114+
for v in AMPHOSTPLATFORM AMP_CONTAINER AMP_CONTAINER_HOST_NETWORK AMPMEMORYLIMIT AMPSWAPLIMIT AMPCONTAINERCPUS AMP_INSTANCE_ID; do
110115
if [[ -n "${!v-}" ]]; then keep_env+=("$v=${!v}"); fi
111116
done
112117
# Extra passthrough of env vars listed in AMP_ADDITIONAL_ENV_VARS in the Dockerfile

scripts/base/ampstart.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ ARCH=$(uname -m)
88
# Context check
99
[[ -z "${AMPUSERID}" ]] && { echo "[Error] This docker image cannot be used directly by itself - it must be started by ampinstmgr"; exit 100; }
1010

11-
# Create /etc/machine-id (addresses Proton/dbus issues)
11+
# Create /etc/machine-id using the instance UUID if AMP_INSTANCE_ID exists (addresses Proton/dbus issues)
1212
mkdir -p /var/lib/dbus
1313
rm -f /etc/machine-id /var/lib/dbus/machine-id
14-
dbus-uuidgen --ensure=/etc/machine-id
15-
ln -s /etc/machine-id /var/lib/dbus/machine-id
14+
if [[ -n "${AMP_INSTANCE_ID:-}" ]]; then
15+
printf '%s\n' "${AMP_INSTANCE_ID//-/}" > /etc/machine-id
16+
else
17+
dbus-uuidgen --ensure=/etc/machine-id
18+
fi
19+
ln -sf /etc/machine-id /var/lib/dbus/machine-id
20+
chmod 0444 /etc/machine-id
1621

1722
# Create /tmp/.X11-unix (for Xvfb etc)
1823
install -d -o root -g root -m 1777 /tmp/.X11-unix
@@ -103,7 +108,7 @@ keep_env=(
103108
XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR}"
104109
)
105110
# Always keep these AMP_ env vars if set
106-
for v in AMPHOSTPLATFORM AMP_CONTAINER AMP_CONTAINER_HOST_NETWORK AMPMEMORYLIMIT AMPSWAPLIMIT AMPCONTAINERCPUS; do
111+
for v in AMPHOSTPLATFORM AMP_CONTAINER AMP_CONTAINER_HOST_NETWORK AMPMEMORYLIMIT AMPSWAPLIMIT AMPCONTAINERCPUS AMP_INSTANCE_ID; do
107112
if [[ -n "${!v-}" ]]; then keep_env+=("$v=${!v}"); fi
108113
done
109114
# Extra passthrough of env vars listed in AMP_ADDITIONAL_ENV_VARS in the Dockerfile

0 commit comments

Comments
 (0)