mirror of
https://github.com/calibrain/shelfmark.git
synced 2026-09-24 21:50:25 +01:00
This PR add the option to set UID/GID during runtime, making sure the application is running as a non-root user. Besides this, it also helps with making sure UID/GID match between containers.
23 lines
484 B
Bash
23 lines
484 B
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
mkdir -p /var/logs
|
|
mkdir -p "$INGEST_DIR"
|
|
|
|
# Create group if it doesn't exist
|
|
if ! getent group "$GID" >/dev/null; then
|
|
groupadd -g "$GID" abc
|
|
fi
|
|
|
|
# Create user if it doesn't exist
|
|
if ! id -u "$UID" >/dev/null 2>&1; then
|
|
useradd -u "$UID" -g "$GID" -d /app -s /sbin/nologin abc
|
|
fi
|
|
|
|
# Adjust ownership of application directories
|
|
chown -R $UID:$GID /app "$INGEST_DIR" /var/logs
|
|
|
|
# Switch to the created user and execute the main command
|
|
exec gosu $UID "$@"
|
|
|