Archived
fix: name docker runtime user
This commit is contained in:
@@ -4,6 +4,8 @@ set -euo pipefail
|
||||
nodejs_major=${NODEJS_MAJOR:-22}
|
||||
nodejs_repo=${NODEJS_REPO:-auto}
|
||||
extra_zypper_packages=${PI_WEB_EXTRA_ZYPPER_PACKAGES:-}
|
||||
runtime_uid=${PI_WEB_UID:-1000}
|
||||
runtime_gid=${PI_WEB_GID:-1000}
|
||||
|
||||
nodejs_repo_flavor() {
|
||||
local rpm_arch
|
||||
@@ -120,16 +122,38 @@ npx --version
|
||||
python3 --version
|
||||
git --version
|
||||
|
||||
if ! getent group node >/dev/null 2>&1; then
|
||||
groupadd --gid 1000 node
|
||||
case "$runtime_uid" in
|
||||
""|*[!0-9]*)
|
||||
echo "PI_WEB_UID must be a numeric user ID, got: $runtime_uid" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$runtime_gid" in
|
||||
""|*[!0-9]*)
|
||||
echo "PI_WEB_GID must be a numeric group ID, got: $runtime_gid" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
runtime_user=pi-web
|
||||
runtime_group=pi-web
|
||||
if getent group "$runtime_gid" >/dev/null 2>&1; then
|
||||
runtime_group=$(getent group "$runtime_gid" | cut -d: -f1)
|
||||
elif getent group "$runtime_group" >/dev/null 2>&1; then
|
||||
groupmod --gid "$runtime_gid" "$runtime_group"
|
||||
else
|
||||
groupadd --gid "$runtime_gid" "$runtime_group"
|
||||
fi
|
||||
|
||||
if ! id node >/dev/null 2>&1; then
|
||||
useradd --uid 1000 --gid node --create-home --home-dir /home/node --shell /bin/bash node
|
||||
if id "$runtime_user" >/dev/null 2>&1; then
|
||||
usermod --non-unique --uid "$runtime_uid" --gid "$runtime_group" --home "/home/$runtime_user" --shell /bin/bash "$runtime_user"
|
||||
else
|
||||
useradd --non-unique --uid "$runtime_uid" --gid "$runtime_group" --create-home --home-dir "/home/$runtime_user" --shell /bin/bash "$runtime_user"
|
||||
fi
|
||||
|
||||
mkdir -p /data/home /data/config /data/npm-cache /data/pi-web /data/pi-agent /workspace
|
||||
chown -R node:node /data /workspace /home/node
|
||||
mkdir -p /data/home /data/config /data/npm-cache /data/pi-web /data/pi-agent /workspace "/home/$runtime_user"
|
||||
chown -R "$runtime_uid:$runtime_gid" /data /workspace "/home/$runtime_user"
|
||||
|
||||
zypper clean --all
|
||||
rm -rf /var/cache/zypp/*
|
||||
|
||||
Reference in New Issue
Block a user