🚀 Refactor DNS configuration scripts 💻
Some checks failed
release-tag / release-image (push) Failing after 40s

rootfs/usr/local/etc/docker/functions/entrypoint.sh
rootfs/usr/local/etc/docker/init.d/02-named.sh
This commit is contained in:
casjay
2025-11-30 15:59:48 -05:00
parent 2a18d54235
commit 9f401d3c23
2 changed files with 12 additions and 8 deletions

View File

@@ -642,8 +642,8 @@ __create_service_user() {
[ -d "$(dirname "$log_file")" ] || mkdir -p "$(dirname "$log_file")" 2>/dev/null
# Validate that we have at least a user or group to create
if [ -z "$create_user" ] && [ -z "$create_group" ]; then
echo "Error: No user or group specified to create" >&2
return 1
echo "No user or group specified to create" >&2
return 0
fi
# Validate user/group name format (alphanumeric, underscore, hyphen; must start with letter or underscore)
if [ -n "$create_user" ] && ! echo "$create_user" | grep -qE '^[a-z_][a-z0-9_-]*$'; then

View File

@@ -20,7 +20,7 @@
# - - - - - - - - - - - - - - - - - - - - - - - - -
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2120,SC2155,SC2199,SC2317,SC2329
# - - - - - - - - - - - - - - - - - - - - - - - - -
set -e
#set -e
# - - - - - - - - - - - - - - - - - - - - - - - - -
# run trap command on exit
trap 'retVal=$?; echo "❌ Fatal error occurred: Exit code $retVal at line $LINENO in command: $BASH_COMMAND"; kill -TERM 1' ERR
@@ -341,6 +341,7 @@ __pre_execute() {
zone_files="$(find "$DATA_DIR/zones/" -type f 2>/dev/null | wc -l)"
if [ $zone_files = 0 ] && [ ! -f "$VAR_DIR/primary/$HOSTNAME.zone" ]; then
file_name="$VAR_DIR/primary/$HOSTNAME.zone"
if ! grep -sq "$HOSTNAME" "$DNS_ZONE_FILE"; then
cat <<EOF >>"$DNS_ZONE_FILE"
# ********** begin $HOSTNAME **********
zone "$HOSTNAME" {
@@ -353,6 +354,7 @@ zone "$HOSTNAME" {
# ********** end $HOSTNAME **********
EOF
fi
cat <<EOF | tee "$VAR_DIR/primary/$HOSTNAME.zone" &>/dev/null
; config for $HOSTNAME
@@ -368,7 +370,7 @@ EOF
file_name="$(basename "$dns_file")"
domain_name="$(grep -Rs '\$ORIGIN' "$dns_file" | awk '{print $NF}' | sed 's|.$||g')"
if [ -f "$dns_file" ]; then
if [ -n "$domain_name" ] && ! grep -qs "$domain_name" "$NAMED_CONFIG_FILE"; then
if [ -n "$domain_name" ] && ! grep -qs "$domain_name" "$DNS_ZONE_FILE"; then
if [ "$DNS_TYPE" = "secondary" ]; then
[ -f "$VAR_DIR/secondary/$file_name" ] || echo "" >"$VAR_DIR/secondary/$file_name"
cat <<EOF >>"$DNS_ZONE_FILE"
@@ -383,7 +385,7 @@ zone "$domain_name" {
EOF
else
cp -Rf "$dns_file" "$VAR_DIR/primary/$file_name"
if [ -n "$DNS_SERVER_SECONDARY" ]; then
if [ -n "$DNS_SERVER_SECONDARY" ] && ! grep -qs "$domain_name" "$DNS_ZONE_FILE"; then
cat <<EOF >>"$DNS_ZONE_FILE"
# ********** begin $domain_name **********
zone "$domain_name" {
@@ -398,6 +400,7 @@ zone "$domain_name" {
EOF
else
if ! grep -qs "$domain_name" "$DNS_ZONE_FILE"; then
cat <<EOF >>"$DNS_ZONE_FILE"
# ********** begin $domain_name **********
zone "$domain_name" {
@@ -412,7 +415,8 @@ zone "$domain_name" {
EOF
fi
fi
grep -qs "$domain_name" "$DNS_ZONE_FILE" && echo "Added $domain_name to $DNS_ZONE_FILE"
fi
grep -qs "$domain_name" "$DNS_ZONE_FILE" && echo "Added $domain_name to $DNS_ZONE_FILE" || true
fi
fi
done