Fixed docker
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 36s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 36s
This commit is contained in:
@@ -1,42 +1,45 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
set -eu
|
||||
COMMAND="/usr/local/bin/nsupdate.sh"
|
||||
|
||||
# Default schedule if not specified
|
||||
SCHEDULE="${SCHEDULE:-* * * * *}"
|
||||
|
||||
# Default cron log level if not specified
|
||||
CRON_LOG_LEVEL="${CRON_LOG_LEVEL:-2}"
|
||||
PUID="${PUID:-1000}"
|
||||
PGID="${PGID:-1000}"
|
||||
CRON_FILE="/etc/crontabs/root"
|
||||
|
||||
# Create or update group with specified PGID
|
||||
if grep -q "^nsupdate:" /etc/group 2>/dev/null; then
|
||||
delgroup nsupdate 2>/dev/null || true
|
||||
fi
|
||||
addgroup -g "${PGID}" nsupdate 2>/dev/null || true
|
||||
# Default user name not specified
|
||||
USERNAME="${USERNAME:-nsupdate}"
|
||||
|
||||
# Create or update user with specified PUID
|
||||
if grep -q "^nsupdate:" /etc/passwd 2>/dev/null; then
|
||||
deluser nsupdate 2>/dev/null || true
|
||||
fi
|
||||
adduser -u "${PUID}" -G nsupdate -s /sbin/nologin -D nsupdate 2>/dev/null || true
|
||||
# Default UID and GID if not specified
|
||||
PUID=${PUID:-1000}
|
||||
PGID=${PGID:-1000}
|
||||
|
||||
# Set ownership of volumes
|
||||
chown -R "${PUID}:${PGID}" /config /log
|
||||
# Default timezone if not specified
|
||||
TZ=${TZ:-Etc/UTC}
|
||||
|
||||
# Ensure crontabs directory exists
|
||||
mkdir -p "$(dirname "${CRON_FILE}")"
|
||||
# Set the timezone
|
||||
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
|
||||
echo "$TZ" >/etc/timezone
|
||||
echo "Timezone set to $TZ"
|
||||
|
||||
# Write cron job to run as the specified user (by UID:GID)
|
||||
printf '%s su -s /bin/sh %s:%s -c /usr/local/bin/nsupdate.sh\n' "${SCHEDULE}" "${PUID}" "${PGID}" > "${CRON_FILE}"
|
||||
chmod 600 "${CRON_FILE}"
|
||||
# Create nsupdate group
|
||||
addgroup -S --gid $PGID "$USERNAME"
|
||||
|
||||
if [ "$#" -gt 0 ]; then
|
||||
if [ "$1" = "crond" ]; then
|
||||
shift
|
||||
exec crond -l "${CRON_LOG_LEVEL}" "$@"
|
||||
fi
|
||||
# Create nsupdate user
|
||||
adduser -S -u $PUID -G "$USERNAME" -D -H -s /bin/false "$USERNAME"
|
||||
|
||||
exec "$@"
|
||||
fi
|
||||
CRON_FILE="/etc/crontabs/$USERNAME"
|
||||
mkdir -p /etc/crontabs
|
||||
printf '%s %s %s\n' "$SCHEDULE" "$USERNAME" "$COMMAND" > "$CRON_FILE"
|
||||
chmod 600 "$CRON_FILE"
|
||||
|
||||
# Set correct permissions
|
||||
chown -R "$USERNAME":"$USERNAME" /config
|
||||
chown -R "$USERNAME":"$USERNAME" /log
|
||||
echo "Permissions adjusted"
|
||||
|
||||
# Start nsupdate in the foreground with reduced warnings
|
||||
echo "Starting cron..."
|
||||
exec crond -l "${CRON_LOG_LEVEL}" -f
|
||||
Reference in New Issue
Block a user