🗃️ rootfs: shield internal entrypoint PID files from /run/*.pid sweeps 🗃️
Some checks failed
bind / release-bind (push) Has been cancelled

Update the embedded entrypoint copies in rootfs/ to match the
upstream template change. Internal state files renamed to dotfiles
so they're not matched by `/run/*.pid` cleanup globs:
- /run/init.d/entrypoint.pid -> /run/.entrypoint.pid
- /run/no_exit.pid -> /run/.no_exit.pid
- /run/backup.pid -> /run/.backup.pid
- /run/__start_init_scripts.pid -> /run/.start_init_scripts.pid
Per-service PIDs in /run/init.d/ are unchanged.

.claude/
Dockerfile
.env.scripts
.gitattributes
.gitea/workflows/docker.yaml
.gitignore
LICENSE.md
rootfs/root/docker/setup/00-init.sh
rootfs/root/docker/setup/01-system.sh
rootfs/root/docker/setup/02-packages.sh
rootfs/root/docker/setup/03-files.sh
rootfs/root/docker/setup/04-users.sh
rootfs/root/docker/setup/05-custom.sh
rootfs/root/docker/setup/06-post.sh
rootfs/root/docker/setup/07-cleanup.sh
rootfs/tmp/etc/bind/named.conf
rootfs/tmp/etc/nginx/fastcgi_params
rootfs/tmp/etc/nginx/nginx.conf
rootfs/usr/local/bin/entrypoint.sh
rootfs/usr/local/bin/pkmgr
rootfs/usr/local/etc/docker/functions/entrypoint.sh
rootfs/usr/local/etc/docker/init.d/01-tor.sh
rootfs/usr/local/etc/docker/init.d/02-named.sh
rootfs/usr/local/etc/docker/init.d/03-nginx.sh
rootfs/usr/local/etc/docker/init.d/04-php-fpm.sh
rootfs/usr/local/share/template-files/config/env/default.sample
rootfs/usr/local/share/template-files/config/env/examples/zz-entrypoint.sh
This commit is contained in:
casjay
2026-05-05 19:11:09 -04:00
parent b542a49619
commit 8c510016c3
27 changed files with 882 additions and 621 deletions

View File

@@ -0,0 +1,29 @@
{
"permissions": {
"allow": [
"Bash(tee /root/Projects/github/casjaysdevdocker/bind/rootfs/usr/local/etc/docker/functions/entrypoint.sh)",
"Bash(tee /root/Projects/github/casjaysdevdocker/bind/rootfs/usr/local/bin/entrypoint.sh)",
"Bash(tee *)",
"Bash(bash /tmp/gen_init_tor.sh)",
"Bash(bash /tmp/gen_init_named.sh)",
"Bash(bash -n /root/Projects/github/casjaysdevdocker/bind/rootfs/usr/local/etc/docker/init.d/01-tor.sh)",
"Bash(bash -n /root/Projects/github/casjaysdevdocker/bind/rootfs/usr/local/etc/docker/init.d/02-named.sh)",
"Bash(bash -n /root/Projects/github/casjaysdevdocker/bind/rootfs/usr/local/etc/docker/init.d/03-nginx.sh)",
"Bash(bash -n /root/Projects/github/casjaysdevdocker/bind/rootfs/usr/local/etc/docker/init.d/04-php-fpm.sh)",
"Bash(bash -n /root/Projects/github/casjaysdevdocker/bind/rootfs/usr/local/etc/docker/init.d/start-service.sh)",
"Bash(bash -n /root/Projects/github/casjaysdevdocker/bind/rootfs/usr/local/bin/entrypoint.sh)",
"Bash(bash -n /root/Projects/github/casjaysdevdocker/bind/rootfs/usr/local/etc/docker/functions/entrypoint.sh)",
"Bash(bash -n /root/Projects/github/casjaysdevdocker/bind/rootfs/usr/local/bin/pkmgr)",
"Bash(python3 -c \"import os; os.remove\\('/root/Projects/github/casjaysdevdocker/bind/rootfs/usr/local/etc/docker/init.d/start-service.sh'\\)\")",
"Bash(dig @127.0.0.1 -p 15300 bind.test.local +short +time=3 +tries=1)",
"Bash(dig @127.0.0.1 -p 15300 bind.test.local SOA +noall +answer +time=3 +tries=1)",
"Bash(dig @127.0.0.1 -p 15300 bind. SOA +noall +answer +time=3 +tries=1)",
"Bash(python3 -c \"import os; os.remove\\('/root/Projects/github/casjaysdevdocker/bind/rootfs/tmp/etc/nginx/real_ip.conf'\\); os.remove\\('/root/Projects/github/casjaysdevdocker/bind/rootfs/tmp/etc/nginx/fastcgi_params'\\)\")",
"Bash(dig @127.0.0.1 -p 15300 bind. A +short +time=4 +tries=1)",
"Bash(dig @127.0.0.1 -p 15300 duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion +short +time=5 +tries=1)",
"Read(//etc/docker/**)",
"Bash(python3 -c 'import json; json.load\\(open\\(\"/etc/docker/daemon.json\"\\)\\); print\\(\"OK\"\\)')",
"Bash(python3 -m json.tool)"
]
}
}

View File

@@ -1,58 +1,84 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202408270947-git ##@Version : 202605051439-git
# @@Author : CasjaysDev # @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro> # @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT # @@License : MIT
# @@Copyright : Copyright 2024 CasjaysDev # @@Copyright : Copyright 2026 CasjaysDev
# @@Created : Tue Aug 27 09:47:41 AM EDT 2024 # @@Created : Tue May 5 02:39:59 PM EDT 2026
# @@File : .env.scripts # @@File : .env.scripts
# @@Description : Variables for gen-dockerfile and buildx scripts # @@Description : Variables for gen-dockerfile and buildx scripts
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # @@Changelog : newScript
# @@TODO : Refactor code
# @@Other : N/A
# @@Resource : N/A
# @@Terminal App : yes
# @@sudo/root : yes
# @@Template : templates/dockerfiles/dotenv.template
# - - - - - - - - - - - - - - - - - - - - - - - - -
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
# - - - - - - - - - - - - - - - - - - - - - - - - -
# entrypoint Settings # entrypoint Settings
DOCKER_ENTYPOINT_PORTS_WEB="${DOCKER_ENTYPOINT_PORTS_WEB}" DOCKER_ENTYPOINT_PORTS_WEB="${DOCKER_ENTYPOINT_PORTS_WEB}"
DOCKER_ENTYPOINT_PORTS_SRV="${DOCKER_ENTYPOINT_PORTS_SRV}" DOCKER_ENTYPOINT_PORTS_SRV="${DOCKER_ENTYPOINT_PORTS_SRV}"
DOCKER_ENTYPOINT_HEALTH_APPS="$DOCKER_ENTYPOINT_HEALTH_APPS" DOCKER_ENTYPOINT_HEALTH_APPS="$DOCKER_ENTYPOINT_HEALTH_APPS"
DOCKER_ENTYPOINT_HEALTH_ENDPOINTS="$DOCKER_ENTYPOINT_HEALTH_ENDPOINTS" DOCKER_ENTYPOINT_HEALTH_ENDPOINTS="$DOCKER_ENTYPOINT_HEALTH_ENDPOINTS"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Dockerfile info # Dockerfile info
ENV_DOCKERFILE="Dockerfile" ENV_DOCKERFILE="Dockerfile"
ENV_IMAGE_NAME="bind" # ENV_REGISTRY_REPO: Registry repository/image name
ENV_REGISTRY_REPO="bind"
ENV_USE_TEMPLATE="alpine" ENV_USE_TEMPLATE="alpine"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Maintainer info # Maintainer info
ENV_ORG_NAME="casjaysdevdocker" ENV_REGISTRY_ORG="casjaysdevdocker"
ENV_VENDOR="CasjaysDev" ENV_VENDOR="CasjaysDev"
ENV_AUTHOR="CasjaysDev" ENV_AUTHOR="CasjaysDev"
ENV_MAINTAINER="CasjaysDev <docker-admin@casjaysdev.pro>" ENV_MAINTAINER="CasjaysDev <docker-admin@casjaysdev.pro>"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# REPO info # Repository URLs (Full URLs)
# ENV_GIT_REPO_URL: Complete Git repository URL for source code
ENV_GIT_REPO_URL="https://github.com/casjaysdevdocker/bind" ENV_GIT_REPO_URL="https://github.com/casjaysdevdocker/bind"
ENV_REGISTRY_URL="https://hub.docker.com/r/casjaysdevdocker/bind" # ENV_REGISTRY_URL: Registry provider base URL (for example https://docker.io)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ENV_REGISTRY_URL="https://docker.io"
# Push image info # - - - - - - - - - - - - - - - - - - - - - - - - -
ENV_IMAGE_PUSH="casjaysdevdocker/bind" # Push Configuration
# ENV_REGISTRY_PUSH: Complete push destination derived from registry/org/repo
ENV_REGISTRY_PUSH="casjaysdevdocker/bind"
# ENV_IMAGE_TAG: Default tag for the image
ENV_IMAGE_TAG="latest" ENV_IMAGE_TAG="latest"
# ENV_ADD_TAGS: Additional tags, comma-separated (USE_DATE = auto date tag)
ENV_ADD_TAGS="" ENV_ADD_TAGS=""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Pull image info # Additional push destinations (if needed)
ENV_ADD_IMAGE_PUSH=""
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Pull Configuration
# ENV_PULL_URL: Source image to pull from (base image)
ENV_PULL_URL="casjaysdev/alpine" ENV_PULL_URL="casjaysdev/alpine"
# ENV_DISTRO_TAG: Tag for the pull source image
ENV_DISTRO_TAG="${IMAGE_VERSION}" ENV_DISTRO_TAG="${IMAGE_VERSION}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Env # Env
SERVICE_PORT="80" SERVICE_PORT="80"
EXPOSE_PORTS="53/tcp 53/udp" EXPOSE_PORTS="53/tcp 53/udp"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# IF using a lanuage such as go, php, rust, ruby, etc set the version here.
LANG_VERSION=""
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Versions # Versions
PHP_VERSION="php82" PHP_VERSION="php82"
NODE_VERSION="system" NODE_VERSION="system"
NODE_MANAGER="system" NODE_MANAGER="system"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Default directories # Default directories
WWW_ROOT_DIR="/usr/local/share/httpd/default" WWW_ROOT_DIR="/usr/local/share/httpd/default"
DEFAULT_FILE_DIR="/usr/local/share/template-files" DEFAULT_FILE_DIR="/usr/local/share/template-files"
DEFAULT_DATA_DIR="/usr/local/share/template-files/data" DEFAULT_DATA_DIR="/usr/local/share/template-files/data"
DEFAULT_CONF_DIR="/usr/local/share/template-files/config" DEFAULT_CONF_DIR="/usr/local/share/template-files/config"
DEFAULT_TEMPLATE_DIR="/usr/local/share/template-files/defaults" DEFAULT_TEMPLATE_DIR="/usr/local/share/template-files/defaults"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
ENV_PACKAGES="bind bind-tools bind-dnssec-root bind-plugins nginx \\${PHP_VERSION}-fpm tor" ENV_PACKAGES="bind bind-tools bind-dnssec-root bind-plugins nginx \${PHP_VERSION}-fpm tor"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -

2
.gitattributes vendored
View File

@@ -1,4 +1,4 @@
# Template generated on Fri May 10 12:52:12 PM EDT 2024 from https://github.com/alexkaratarakis/gitattributes" # Template generated on Sat Nov 29 11:57:12 AM EST 2025 from https://github.com/alexkaratarakis/gitattributes"
# Common settings that generally should always be used with your language specific settings # Common settings that generally should always be used with your language specific settings
# Auto detect text files and perform LF normalization # Auto detect text files and perform LF normalization
* text=auto * text=auto

View File

@@ -1,9 +1,9 @@
name: release-tag name: bind
on: push on: push
jobs: jobs:
release-image: release-bind:
runs-on: act_runner runs-on: act_runner
container: container:
image: catthehacker/ubuntu:act-latest image: catthehacker/ubuntu:act-latest
@@ -19,13 +19,20 @@ jobs:
- name: Get Meta - name: Get Meta
id: meta id: meta
run: | run: |
echo DATE_TAG=$(date +'%y%m') >> $GITHUB_OUTPUT repo_version="$(git describe --tags --always)"
echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT repo_version="${repo_version#v}"
echo DOCKER_ORG=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $1}') >> $GITHUB_OUTPUT docker_org="${GITHUB_REPOSITORY%%/*}"
echo DOCKER_TAG=$([ -n "$DOCKER_TAG" ] && echo ${DOCKER_TAG} || echo "latest") >> $GITHUB_OUTPUT repo_name="${GITHUB_REPOSITORY#*/}"
echo DOCKER_HUB=$([ -n "$DOCKER_HUB" ] && echo ${DOCKER_HUB} || echo "docker.io") >> $GITHUB_OUTPUT repo_name="${repo_name#docker-}"
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}' | sed 's|^docker-||g') >> $GITHUB_OUTPUT docker_tag="${DOCKER_TAG:-latest}"
echo "$DOCKER_HUB/$DOCKER_ORG/$REPO_NAME:$DOCKER_TAG" docker_hub="${DOCKER_HUB:-docker.io}"
printf 'DATE_TAG=%s\n' "$(date +'%y%m')" >> "$GITHUB_OUTPUT"
printf 'REPO_VERSION=%s\n' "$repo_version" >> "$GITHUB_OUTPUT"
printf 'DOCKER_ORG=%s\n' "$docker_org" >> "$GITHUB_OUTPUT"
printf 'DOCKER_TAG=%s\n' "$docker_tag" >> "$GITHUB_OUTPUT"
printf 'DOCKER_HUB=%s\n' "$docker_hub" >> "$GITHUB_OUTPUT"
printf 'REPO_NAME=%s\n' "$repo_name" >> "$GITHUB_OUTPUT"
printf '%s\n' "$docker_hub/$docker_org/$repo_name:$docker_tag"
- name: Set up Docker BuildX - name: Set up Docker BuildX
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v2
@@ -46,7 +53,16 @@ jobs:
linux/amd64 linux/amd64
linux/arm64 linux/arm64
push: true push: true
tags: | # replace it with your local IP and tags build-args: |
IMAGE_NAME=${{ steps.meta.outputs.REPO_NAME }}
BUILD_DATE=$(date -u +'%Y%m%d%H%M')
BUILD_VERSION=$(date -u +'%Y%m%d%H%M')
GIT_COMMIT=${{ github.sha }}
TIMEZONE=America/New_York
LANGUAGE=en_US.UTF-8
LICENSE=WTFPL
TZ=America/New_York
tags: |
${{ steps.meta.outputs.DOCKER_HUB }}/${{ steps.meta.outputs.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.DATE_TAG }} ${{ steps.meta.outputs.DOCKER_HUB }}/${{ steps.meta.outputs.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.DATE_TAG }}
${{ steps.meta.outputs.DOCKER_HUB }}/${{ steps.meta.outputs.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.DOCKER_TAG }} ${{ steps.meta.outputs.DOCKER_HUB }}/${{ steps.meta.outputs.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.DOCKER_TAG }}

10
.gitignore vendored
View File

@@ -1,7 +1,10 @@
# gitignore created on 08/27/24 at 09:03 # gitignore created on 05/05/26 at 14:38
# Disable reminder in prompt # Disable reminder in prompt
ignoredirmessage ignoredirmessage
# ignore .build_failed files
**/.build_failed*
# OS generated files # OS generated files
### Linux ### ### Linux ###
*~ *~
@@ -83,7 +86,6 @@ $RECYCLE.BIN/
# ignore .build_failed files # ignore .build_failed files
**/.build_failed* **/.build_failed*
# ignore .bak files # ignore .bak files
**/*.bak **/*.bak
@@ -96,3 +98,7 @@ $RECYCLE.BIN/
# ignore .installed files # ignore .installed files
**/.installed **/.installed
# ignore work in progress files
**/*.rewrite.sh
**/*.refactor.sh

View File

@@ -1,8 +1,7 @@
# syntax=docker/dockerfile:1
# Docker image for bind using the alpine template # Docker image for bind using the alpine template
ARG IMAGE_NAME="bind" ARG IMAGE_NAME="bind"
ARG PHP_SERVER="bind" ARG PHP_SERVER="bind"
ARG BUILD_DATE="202408270947" ARG BUILD_DATE="202605051439"
ARG LANGUAGE="en_US.UTF-8" ARG LANGUAGE="en_US.UTF-8"
ARG TIMEZONE="America/New_York" ARG TIMEZONE="America/New_York"
ARG WWW_ROOT_DIR="/usr/local/share/httpd/default" ARG WWW_ROOT_DIR="/usr/local/share/httpd/default"
@@ -10,6 +9,7 @@ ARG DEFAULT_FILE_DIR="/usr/local/share/template-files"
ARG DEFAULT_DATA_DIR="/usr/local/share/template-files/data" ARG DEFAULT_DATA_DIR="/usr/local/share/template-files/data"
ARG DEFAULT_CONF_DIR="/usr/local/share/template-files/config" ARG DEFAULT_CONF_DIR="/usr/local/share/template-files/config"
ARG DEFAULT_TEMPLATE_DIR="/usr/local/share/template-files/defaults" ARG DEFAULT_TEMPLATE_DIR="/usr/local/share/template-files/defaults"
ARG PATH="/usr/local/etc/docker/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ARG USER="root" ARG USER="root"
ARG SHELL_OPTS="set -e -o pipefail" ARG SHELL_OPTS="set -e -o pipefail"
@@ -52,11 +52,13 @@ ARG NODE_MANAGER
ARG PHP_VERSION ARG PHP_VERSION
ARG PHP_SERVER ARG PHP_SERVER
ARG SHELL_OPTS ARG SHELL_OPTS
ARG PATH
ARG PACK_LIST="bind bind-tools bind-dnssec-root bind-plugins nginx ${PHP_VERSION}-fpm tor " ARG PACK_LIST="bind bind-tools bind-dnssec-root bind-plugins nginx ${PHP_VERSION}-fpm tor tini shadow "
ENV ENV=~/.profile ENV ENV=~/.profile
ENV SHELL="/bin/sh" ENV SHELL="/bin/sh"
ENV PATH="${PATH}"
ENV TZ="${TIMEZONE}" ENV TZ="${TIMEZONE}"
ENV TIMEZONE="${TZ}" ENV TIMEZONE="${TZ}"
ENV LANG="${LANGUAGE}" ENV LANG="${LANGUAGE}"
@@ -66,11 +68,21 @@ ENV HOSTNAME="casjaysdevdocker-bind"
USER ${USER} USER ${USER}
WORKDIR /root WORKDIR /root
COPY ./rootfs/usr/local/bin/. /usr/local/bin/ COPY ./rootfs/. /
RUN set -e; \
echo "Updating the system and ensuring bash is installed"; \
pkmgr update;pkmgr install bash
RUN set -e; \ RUN set -e; \
echo "Setting up prerequisites"; \ echo "Setting up prerequisites"; \
true apk --no-cache add bash; \
SH_CMD="$(which sh 2>/dev/null||command -v sh 2>/dev/null)"; \
BASH_CMD="$(which bash 2>/dev/null||command -v bash 2>/dev/null)"; \
[ -x "$BASH_CMD" ] && symlink "$BASH_CMD" "/bin/sh" || true; \
[ -x "$BASH_CMD" ] && symlink "$BASH_CMD" "/usr/bin/sh" || true; \
[ -x "$BASH_CMD" ] && [ "$SH_CMD" != "/bin/sh"] && symlink "$BASH_CMD" "$SH_CMD" || true; \
[ -n "$BASH_CMD" ] && sed -i 's|root:x:.*|root:x:0:0:root:/root:'$BASH_CMD'|g' "/etc/passwd" || true
ENV SHELL="/bin/bash" ENV SHELL="/bin/bash"
SHELL [ "/bin/bash", "-c" ] SHELL [ "/bin/bash", "-c" ]
@@ -85,8 +97,11 @@ RUN echo "Initializing the system"; \
RUN echo "Creating and editing system files "; \ RUN echo "Creating and editing system files "; \
$SHELL_OPTS; \ $SHELL_OPTS; \
[ -f "/root/.profile" ] || touch "/root/.profile"; \ rm -Rf "/etc/apk/repositories"; \
mkdir -p "${DEFAULT_DATA_DIR}" "${DEFAULT_CONF_DIR}" "${DEFAULT_TEMPLATE_DIR}" "/root/docker/setup" "/etc/profile.d"; \ [ "$DISTRO_VERSION" = "latest" ] && DISTRO_VERSION="edge";[ "$DISTRO_VERSION" = "edge" ] || DISTRO_VERSION="v${DISTRO_VERSION}"; \
echo "http://dl-cdn.alpinelinux.org/alpine/${DISTRO_VERSION}/main" >>"/etc/apk/repositories"; \
echo "http://dl-cdn.alpinelinux.org/alpine/${DISTRO_VERSION}/community" >>"/etc/apk/repositories"; \
if [ "${DISTRO_VERSION}" = "edge" ]; then echo "http://dl-cdn.alpinelinux.org/alpine/${DISTRO_VERSION}/testing" >>"/etc/apk/repositories";fi; \
if [ -f "/root/docker/setup/01-system.sh" ];then echo "Running the system script";/root/docker/setup/01-system.sh||{ echo "Failed to execute /root/docker/setup/01-system.sh" >&2 && exit 10; };echo "Done running the system script";fi; \ if [ -f "/root/docker/setup/01-system.sh" ];then echo "Running the system script";/root/docker/setup/01-system.sh||{ echo "Failed to execute /root/docker/setup/01-system.sh" >&2 && exit 10; };echo "Done running the system script";fi; \
echo "" echo ""
@@ -104,7 +119,6 @@ RUN echo "Initializing packages before copying files to image"; \
if [ -f "/root/docker/setup/02-packages.sh" ];then echo "Running the packages script";/root/docker/setup/02-packages.sh||{ echo "Failed to execute /root/docker/setup/02-packages.sh" >&2 && exit 10; };echo "Done running the packages script";fi; \ if [ -f "/root/docker/setup/02-packages.sh" ];then echo "Running the packages script";/root/docker/setup/02-packages.sh||{ echo "Failed to execute /root/docker/setup/02-packages.sh" >&2 && exit 10; };echo "Done running the packages script";fi; \
echo "" echo ""
COPY ./rootfs/. /
COPY ./Dockerfile /root/docker/Dockerfile COPY ./Dockerfile /root/docker/Dockerfile
RUN echo "Updating system files "; \ RUN echo "Updating system files "; \
@@ -114,7 +128,7 @@ RUN echo "Updating system files "; \
echo 'hosts: files dns' >"/etc/nsswitch.conf"; \ echo 'hosts: files dns' >"/etc/nsswitch.conf"; \
[ "$PHP_VERSION" = "system" ] && PHP_VERSION="php" || true; \ [ "$PHP_VERSION" = "system" ] && PHP_VERSION="php" || true; \
PHP_BIN="$(command -v ${PHP_VERSION} 2>/dev/null || true)"; \ PHP_BIN="$(command -v ${PHP_VERSION} 2>/dev/null || true)"; \
PHP_FPM="$(ls /usr/*bin/php*fpm* 2>/dev/null || true)"; \ set -- /usr/*bin/php*fpm*; [ -e "$1" ] && PHP_FPM="$1" || PHP_FPM=""; \
pip_bin="$(command -v python3 2>/dev/null || command -v python2 2>/dev/null || command -v python 2>/dev/null || true)"; \ pip_bin="$(command -v python3 2>/dev/null || command -v python2 2>/dev/null || command -v python 2>/dev/null || true)"; \
py_version="$(command $pip_bin --version | sed 's|[pP]ython ||g' | awk -F '.' '{print $1$2}' | grep '[0-9]' || true)"; \ py_version="$(command $pip_bin --version | sed 's|[pP]ython ||g' | awk -F '.' '{print $1$2}' | grep '[0-9]' || true)"; \
[ "$py_version" -gt "310" ] && pip_opts="--break-system-packages " || pip_opts=""; \ [ "$py_version" -gt "310" ] && pip_opts="--break-system-packages " || pip_opts=""; \
@@ -124,7 +138,7 @@ RUN echo "Updating system files "; \
[ -n "$PHP_FPM" ] && [ -z "$(command -v php-fpm 2>/dev/null)" ] && ln -sf "$PHP_FPM" "/usr/bin/php-fpm" 2>/dev/null || true; \ [ -n "$PHP_FPM" ] && [ -z "$(command -v php-fpm 2>/dev/null)" ] && ln -sf "$PHP_FPM" "/usr/bin/php-fpm" 2>/dev/null || true; \
if [ -f "/etc/profile.d/color_prompt.sh.disabled" ]; then mv -f "/etc/profile.d/color_prompt.sh.disabled" "/etc/profile.d/color_prompt.sh";fi ; \ if [ -f "/etc/profile.d/color_prompt.sh.disabled" ]; then mv -f "/etc/profile.d/color_prompt.sh.disabled" "/etc/profile.d/color_prompt.sh";fi ; \
{ [ -f "/etc/bash/bashrc" ] && cp -Rf "/etc/bash/bashrc" "/root/.bashrc"; } || { [ -f "/etc/bashrc" ] && cp -Rf "/etc/bashrc" "/root/.bashrc"; } || { [ -f "/etc/bash.bashrc" ] && cp -Rf "/etc/bash.bashrc" "/root/.bashrc"; } || true; \ { [ -f "/etc/bash/bashrc" ] && cp -Rf "/etc/bash/bashrc" "/root/.bashrc"; } || { [ -f "/etc/bashrc" ] && cp -Rf "/etc/bashrc" "/root/.bashrc"; } || { [ -f "/etc/bash.bashrc" ] && cp -Rf "/etc/bash.bashrc" "/root/.bashrc"; } || true; \
if [ -z "$(command -v "apt-get" 2>/dev/null)" ];then grep -s -q 'alias quit' "/root/.bashrc" || printf '# Profile\n\n%s\n%s\n%s\n' '. /etc/profile' '. /root/.profile' "alias quit='exit 0 2>/dev/null'" >>"/root/.bashrc"; fi; \ if [ -z "$(command -v "apt-get" 2>/dev/null)" ];then grep -sh -q 'alias quit' "/root/.bashrc" || printf '# Profile\n\n%s\n%s\n%s\n' '. /etc/profile' '. /root/.profile' "alias quit='exit 0 2>/dev/null'" >>"/root/.bashrc"; fi; \
if [ "$PHP_VERSION" != "system" ] && [ -e "/etc/php" ] && [ -d "/etc/${PHP_VERSION}" ];then rm -Rf "/etc/php";fi; \ if [ "$PHP_VERSION" != "system" ] && [ -e "/etc/php" ] && [ -d "/etc/${PHP_VERSION}" ];then rm -Rf "/etc/php";fi; \
if [ "$PHP_VERSION" != "system" ] && [ -n "${PHP_VERSION}" ] && [ -d "/etc/${PHP_VERSION}" ];then ln -sf "/etc/${PHP_VERSION}" "/etc/php";fi; \ if [ "$PHP_VERSION" != "system" ] && [ -n "${PHP_VERSION}" ] && [ -d "/etc/${PHP_VERSION}" ];then ln -sf "/etc/${PHP_VERSION}" "/etc/php";fi; \
if [ -f "/root/docker/setup/03-files.sh" ];then echo "Running the files script";/root/docker/setup/03-files.sh||{ echo "Failed to execute /root/docker/setup/03-files.sh" >&2 && exit 10; };echo "Done running the files script";fi; \ if [ -f "/root/docker/setup/03-files.sh" ];then echo "Running the files script";/root/docker/setup/03-files.sh||{ echo "Failed to execute /root/docker/setup/03-files.sh" >&2 && exit 10; };echo "Done running the files script";fi; \
@@ -132,7 +146,7 @@ RUN echo "Updating system files "; \
RUN echo "Custom Settings"; \ RUN echo "Custom Settings"; \
$SHELL_OPTS; \ $SHELL_OPTS; \
echo "" echo ""
RUN echo "Setting up users and scripts "; \ RUN echo "Setting up users and scripts "; \
$SHELL_OPTS; \ $SHELL_OPTS; \
@@ -149,7 +163,7 @@ RUN echo "Setting OS Settings "; \
RUN echo "Custom Applications"; \ RUN echo "Custom Applications"; \
$SHELL_OPTS; \ $SHELL_OPTS; \
echo "" echo ""
RUN echo "Running custom commands"; \ RUN echo "Running custom commands"; \
if [ -f "/root/docker/setup/05-custom.sh" ];then echo "Running the custom script";/root/docker/setup/05-custom.sh||{ echo "Failed to execute /root/docker/setup/05-custom.sh" && exit 10; };echo "Done running the custom script";fi; \ if [ -f "/root/docker/setup/05-custom.sh" ];then echo "Running the custom script";/root/docker/setup/05-custom.sh||{ echo "Failed to execute /root/docker/setup/05-custom.sh" && exit 10; };echo "Done running the custom script";fi; \
@@ -172,13 +186,14 @@ RUN echo "Deleting unneeded files"; \
rm -rf /lib/systemd/system/sockets.target.wants/*udev* || true; \ rm -rf /lib/systemd/system/sockets.target.wants/*udev* || true; \
rm -rf /lib/systemd/system/sockets.target.wants/*initctl* || true; \ rm -rf /lib/systemd/system/sockets.target.wants/*initctl* || true; \
rm -Rf /usr/share/doc/* /var/tmp/* /var/cache/*/* /root/.cache/* /usr/share/info/* /tmp/* || true; \ rm -Rf /usr/share/doc/* /var/tmp/* /var/cache/*/* /root/.cache/* /usr/share/info/* /tmp/* || true; \
if [ -d "/lib/systemd/system/sysinit.target.wants" ];then cd "/lib/systemd/system/sysinit.target.wants" && rm -f $(ls | grep -v systemd-tmpfiles-setup);fi; \ if [ -d "/lib/systemd/system/sysinit.target.wants" ];then cd "/lib/systemd/system/sysinit.target.wants" && for want_file in *; do [ "$want_file" = "systemd-tmpfiles-setup" ] || rm -f "$want_file"; done; fi; \
if [ -f "/root/docker/setup/07-cleanup.sh" ];then echo "Running the cleanup script";/root/docker/setup/07-cleanup.sh||{ echo "Failed to execute /root/docker/setup/07-cleanup.sh" >&2 && exit 10; };echo "Done running the cleanup script";fi; \ if [ -f "/root/docker/setup/07-cleanup.sh" ];then echo "Running the cleanup script";/root/docker/setup/07-cleanup.sh||{ echo "Failed to execute /root/docker/setup/07-cleanup.sh" >&2 && exit 10; };echo "Done running the cleanup script";fi; \
echo "" echo ""
RUN echo "Init done" RUN echo "Init done"
FROM scratch FROM scratch
ARG TZ ARG TZ
ARG PATH
ARG USER ARG USER
ARG TIMEZONE ARG TIMEZONE
ARG LANGUAGE ARG LANGUAGE
@@ -188,6 +203,7 @@ ARG SERVICE_PORT
ARG EXPOSE_PORTS ARG EXPOSE_PORTS
ARG BUILD_VERSION ARG BUILD_VERSION
ARG IMAGE_VERSION ARG IMAGE_VERSION
ARG GIT_COMMIT
ARG WWW_ROOT_DIR ARG WWW_ROOT_DIR
ARG DEFAULT_FILE_DIR ARG DEFAULT_FILE_DIR
ARG DEFAULT_DATA_DIR ARG DEFAULT_DATA_DIR
@@ -208,24 +224,25 @@ LABEL maintainer="CasjaysDev <docker-admin@casjaysdev.pro>"
LABEL org.opencontainers.image.vendor="CasjaysDev" LABEL org.opencontainers.image.vendor="CasjaysDev"
LABEL org.opencontainers.image.authors="CasjaysDev" LABEL org.opencontainers.image.authors="CasjaysDev"
LABEL org.opencontainers.image.description="Containerized version of ${IMAGE_NAME}" LABEL org.opencontainers.image.description="Containerized version of ${IMAGE_NAME}"
LABEL org.opencontainers.image.name="${IMAGE_NAME}" LABEL org.opencontainers.image.title="${IMAGE_NAME}"
LABEL org.opencontainers.image.base.name="${IMAGE_NAME}" LABEL org.opencontainers.image.base.name="${IMAGE_NAME}"
LABEL org.opencontainers.image.license="${LICENSE}" LABEL org.opencontainers.image.authors="${LICENSE}"
LABEL org.opencontainers.image.build-date="${BUILD_DATE}" LABEL org.opencontainers.image.created="${BUILD_DATE}"
LABEL org.opencontainers.image.version="${BUILD_VERSION}" LABEL org.opencontainers.image.version="${BUILD_VERSION}"
LABEL org.opencontainers.image.schema-version="${BUILD_VERSION}" LABEL org.opencontainers.image.schema-version="${BUILD_VERSION}"
LABEL org.opencontainers.image.url="https://hub.docker.com/r/casjaysdevdocker/bind" LABEL org.opencontainers.image.url="https://docker.io/casjaysdevdocker/bind"
LABEL org.opencontainers.image.url.source="https://hub.docker.com/r/casjaysdevdocker/bind" LABEL org.opencontainers.image.source="https://docker.io/casjaysdevdocker/bind"
LABEL org.opencontainers.image.vcs-type="Git" LABEL org.opencontainers.image.vcs-type="Git"
LABEL org.opencontainers.image.vcs-ref="${BUILD_VERSION}" LABEL org.opencontainers.image.revision="${GIT_COMMIT}"
LABEL org.opencontainers.image.vcs-url="https://github.com/casjaysdevdocker/bind" LABEL org.opencontainers.image.source="https://github.com/casjaysdevdocker/bind"
LABEL org.opencontainers.image.documentation="https://github.com/casjaysdevdocker/bind" LABEL org.opencontainers.image.documentation="https://github.com/casjaysdevdocker/bind"
LABEL com.github.containers.toolbox="false" LABEL com.github.containers.toolbox="false"
ENV ENV=~/.bashrc ENV ENV=~/.bashrc
ENV USER="${USER}" ENV USER="${USER}"
ENV SHELL="/bin/bash" ENV PATH="${PATH}"
ENV TZ="${TIMEZONE}" ENV TZ="${TIMEZONE}"
ENV SHELL="/bin/bash"
ENV TIMEZONE="${TZ}" ENV TIMEZONE="${TZ}"
ENV LANG="${LANGUAGE}" ENV LANG="${LANGUAGE}"
ENV TERM="xterm-256color" ENV TERM="xterm-256color"
@@ -246,6 +263,8 @@ VOLUME [ "/config","/data" ]
EXPOSE ${SERVICE_PORT} ${ENV_PORTS} EXPOSE ${SERVICE_PORT} ${ENV_PORTS}
CMD [ "tail", "-f", "/dev/null" ] STOPSIGNAL SIGRTMIN+3
ENTRYPOINT [ "tini","--","/usr/local/bin/entrypoint.sh" ]
ENTRYPOINT [ "tini", "-p", "SIGTERM","--", "/usr/local/bin/entrypoint.sh" ]
HEALTHCHECK --start-period=10m --interval=5m --timeout=15s CMD [ "/usr/local/bin/entrypoint.sh", "healthcheck" ] HEALTHCHECK --start-period=10m --interval=5m --timeout=15s CMD [ "/usr/local/bin/entrypoint.sh", "healthcheck" ]

View File

@@ -1,7 +1,7 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004 Version 2, December 2004
Copyright (C) 2024 casjay <git-admin@casjaysdev.pro> Copyright (C) 2026 casjay <git-admin@casjaysdev.pro>
Everyone is permitted to copy and distribute verbatim or modified Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long copies of this license document, and changing it is allowed as long

View File

@@ -1,40 +1,45 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck shell=bash
##@Version : 202408270903-git # - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202605051438-git
# @@Author : CasjaysDev # @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro> # @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT # @@License : MIT
# @@ReadME : # @@Copyright : Copyright 2026 CasjaysDev
# @@Copyright : Copyright 2023 CasjaysDev # @@Created : Tue May 5 02:38:04 PM EDT 2026
# @@Created : Mon Aug 28 06:48:42 PM EDT 2023
# @@File : 00-init.sh # @@File : 00-init.sh
# @@Description : script to run init # @@Description : script to run init
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # @@Changelog : newScript
# shellcheck shell=bash # @@TODO : Refactor code
# shellcheck disable=SC2016 # @@Other : N/A
# shellcheck disable=SC2031 # @@Resource : N/A
# shellcheck disable=SC2120 # @@Terminal App : yes
# shellcheck disable=SC2155 # @@sudo/root : yes
# shellcheck disable=SC2199 # @@Template : templates/dockerfiles/init_scripts/00-init.sh
# shellcheck disable=SC2317 # - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options # Set bash options
set -o pipefail set -o pipefail
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS [ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Set env variables # Set env variables
exitCode=0 exitCode=0
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Predifined actions # Predefined actions
[ -d "/usr/local/share/template-files/data" ] && rm -Rf "/usr/local/share/template-files/data"/* if [ -d "/usr/local/share/template-files/data" ]; then rm -Rf "/usr/local/share/template-files/data"/*; fi
[ -d "/usr/local/share/template-files/config" ] && rm -Rf "/usr/local/share/template-files/config"/* if [ -d "/usr/local/share/template-files/config" ]; then rm -Rf "/usr/local/share/template-files/config"/*; fi
[ -d "/usr/local/share/template-files/defaults" ] && rm -Rf "/usr/local/share/template-files/defaults"/* if [ -d "/usr/local/share/template-files/defaults" ]; then rm -Rf "/usr/local/share/template-files/defaults"/*; fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Main script # Main script
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code # Set the exit code
exitCode=$? #exitCode=$?
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode exit $exitCode
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@@ -1,38 +1,43 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck shell=bash
##@Version : 202408270903-git # - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202605051438-git
# @@Author : CasjaysDev # @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro> # @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT # @@License : MIT
# @@ReadME : # @@Copyright : Copyright 2026 CasjaysDev
# @@Copyright : Copyright 2023 CasjaysDev # @@Created : Tue May 5 02:38:04 PM EDT 2026
# @@Created : Mon Aug 28 06:48:42 PM EDT 2023
# @@File : 01-system.sh # @@File : 01-system.sh
# @@Description : script to run system # @@Description : script to run system
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # @@Changelog : newScript
# shellcheck shell=bash # @@TODO : Refactor code
# shellcheck disable=SC2016 # @@Other : N/A
# shellcheck disable=SC2031 # @@Resource : N/A
# shellcheck disable=SC2120 # @@Terminal App : yes
# shellcheck disable=SC2155 # @@sudo/root : yes
# shellcheck disable=SC2199 # @@Template : templates/dockerfiles/init_scripts/01-system.sh
# shellcheck disable=SC2317 # - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options # Set bash options
set -o pipefail set -o pipefail
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS [ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Set env variables # Set env variables
exitCode=0 exitCode=0
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Predifined actions # Predefined actions
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Main script # Main script
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code # Set the exit code
exitCode=$? #exitCode=$?
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode exit $exitCode
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@@ -1,42 +1,51 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck shell=bash
##@Version : 202408270903-git # - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202605051438-git
# @@Author : CasjaysDev # @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro> # @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT # @@License : MIT
# @@ReadME : # @@Copyright : Copyright 2026 CasjaysDev
# @@Copyright : Copyright 2023 CasjaysDev # @@Created : Tue May 5 02:38:04 PM EDT 2026
# @@Created : Mon Aug 28 06:48:42 PM EDT 2023
# @@File : 02-packages.sh # @@File : 02-packages.sh
# @@Description : script to run packages # @@Description : script to run packages
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # @@Changelog : newScript
# shellcheck shell=bash # @@TODO : Refactor code
# shellcheck disable=SC2016 # @@Other : N/A
# shellcheck disable=SC2031 # @@Resource : N/A
# shellcheck disable=SC2120 # @@Terminal App : yes
# shellcheck disable=SC2155 # @@sudo/root : yes
# shellcheck disable=SC2199 # @@Template : templates/dockerfiles/init_scripts/02-packages.sh
# shellcheck disable=SC2317 # - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options # Set bash options
set -o pipefail set -o pipefail
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS [ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Set env variables # Set env variables
exitCode=0 exitCode=0
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Predifined actions # Predefined actions
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Main script # Main script
# wipe package-installed configs so the rootfs ones in /tmp/etc/* are
# the only files that end up under /etc/<service>/ after 03-files.sh runs.
rm -Rf /etc/tor/* rm -Rf /etc/tor/*
rm -Rf /etc/nginx/*
rm -Rf /etc/php*/*
rm -Rf /etc/bind.* /etc/named.* rm -Rf /etc/bind.* /etc/named.*
rm -Rf "/etc/bind"/* "/var/bind"/* rm -Rf "/etc/bind"/* "/var/bind"/*
rm -Rf "/etc/named"/* "/var/named"/* rm -Rf "/etc/named"/* "/var/named"/*
mkdir -p "/etc/bind/keys" "/var/bind/zones" "/var/bind/primary" "/var/bind/secondary" "/var/bind/stats" "/var/bind/dynamic" mkdir -p "/etc/bind/keys" "/var/bind/zones" "/var/bind/primary" "/var/bind/secondary" "/var/bind/stats" "/var/bind/dynamic"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code # Set the exit code
exitCode=$? #exitCode=$?
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode exit $exitCode
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@@ -1,36 +1,37 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck shell=bash
##@Version : 202408270903-git # - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202605051438-git
# @@Author : CasjaysDev # @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro> # @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT # @@License : MIT
# @@ReadME : # @@Copyright : Copyright 2026 CasjaysDev
# @@Copyright : Copyright 2023 CasjaysDev # @@Created : Tue May 5 02:38:04 PM EDT 2026
# @@Created : Mon Aug 28 06:48:42 PM EDT 2023
# @@File : 03-files.sh # @@File : 03-files.sh
# @@Description : script to run files # @@Description : script to run files
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # @@Changelog : newScript
# shellcheck shell=bash # @@TODO : Refactor code
# shellcheck disable=SC2016 # @@Other : N/A
# shellcheck disable=SC2031 # @@Resource : N/A
# shellcheck disable=SC2120 # @@Terminal App : yes
# shellcheck disable=SC2155 # @@sudo/root : yes
# shellcheck disable=SC2199 # @@Template : templates/dockerfiles/init_scripts/03-files.sh
# shellcheck disable=SC2317 # - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options # Set bash options
set -o pipefail set -o pipefail
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS [ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Set env variables # Set env variables
exitCode=0 exitCode=0
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Predifined actions # Predefined actions
if [ -d "/tmp/bin" ]; then if [ -d "/tmp/bin" ]; then
mkdir -p "/usr/local/bin" mkdir -p "/usr/local/bin"
for bin in "/tmp/bin"/*; do for bin in "/tmp/bin"/*; do
name="$(basename "$bin")" name="$(basename -- "$bin")"
echo "Installing $name to /usr/local/bin/$name" echo "Installing $name to /usr/local/bin/$name"
copy "$bin" "/usr/local/bin/$name" copy "$bin" "/usr/local/bin/$name"
chmod -f +x "/usr/local/bin/$name" chmod -f +x "/usr/local/bin/$name"
@@ -39,7 +40,7 @@ fi
unset bin unset bin
if [ -d "/tmp/var" ]; then if [ -d "/tmp/var" ]; then
for var in "/tmp/var"/*; do for var in "/tmp/var"/*; do
name="$(basename "$var")" name="$(basename -- "$var")"
echo "Installing $var to /var/$name" echo "Installing $var to /var/$name"
if [ -d "$var" ]; then if [ -d "$var" ]; then
mkdir -p "/var/$name" mkdir -p "/var/$name"
@@ -51,9 +52,8 @@ if [ -d "/tmp/var" ]; then
fi fi
unset var unset var
if [ -d "/tmp/etc" ]; then if [ -d "/tmp/etc" ]; then
mkdir -p "/usr/local/share/template-files/config"
for config in "/tmp/etc"/*; do for config in "/tmp/etc"/*; do
name="$(basename "$config")" name="$(basename -- "$config")"
echo "Installing $config to /etc/$name" echo "Installing $config to /etc/$name"
if [ -d "$config" ]; then if [ -d "$config" ]; then
mkdir -p "/etc/$name" mkdir -p "/etc/$name"
@@ -68,9 +68,8 @@ if [ -d "/tmp/etc" ]; then
fi fi
unset config unset config
if [ -d "/tmp/data" ]; then if [ -d "/tmp/data" ]; then
mkdir -p "/usr/local/share/template-files/data"
for data in "/tmp/data"/*; do for data in "/tmp/data"/*; do
name="$(basename "$data")" name="$(basename -- "$data")"
echo "Installing $data to /usr/local/share/template-files/data" echo "Installing $data to /usr/local/share/template-files/data"
if [ -d "$data" ]; then if [ -d "$data" ]; then
mkdir -p "/usr/local/share/template-files/data/$name" mkdir -p "/usr/local/share/template-files/data/$name"
@@ -81,11 +80,15 @@ if [ -d "/tmp/data" ]; then
done done
fi fi
unset data unset data
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Main script # Main script
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code # Set the exit code
exitCode=$? #exitCode=$?
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode exit $exitCode
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@@ -1,38 +1,43 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck shell=bash
##@Version : 202408270903-git # - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202605051438-git
# @@Author : CasjaysDev # @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro> # @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT # @@License : MIT
# @@ReadME : # @@Copyright : Copyright 2026 CasjaysDev
# @@Copyright : Copyright 2023 CasjaysDev # @@Created : Tue May 5 02:38:04 PM EDT 2026
# @@Created : Mon Aug 28 06:48:42 PM EDT 2023
# @@File : 04-users.sh # @@File : 04-users.sh
# @@Description : script to run users # @@Description : script to run users
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # @@Changelog : newScript
# shellcheck shell=bash # @@TODO : Refactor code
# shellcheck disable=SC2016 # @@Other : N/A
# shellcheck disable=SC2031 # @@Resource : N/A
# shellcheck disable=SC2120 # @@Terminal App : yes
# shellcheck disable=SC2155 # @@sudo/root : yes
# shellcheck disable=SC2199 # @@Template : templates/dockerfiles/init_scripts/04-users.sh
# shellcheck disable=SC2317 # - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options # Set bash options
set -o pipefail set -o pipefail
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS [ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Set env variables # Set env variables
exitCode=0 exitCode=0
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Predifined actions # Predefined actions
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Main script # Main script
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code # Set the exit code
exitCode=$? #exitCode=$?
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode exit $exitCode
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@@ -1,38 +1,43 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck shell=bash
##@Version : 202408270903-git # - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202605051438-git
# @@Author : CasjaysDev # @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro> # @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT # @@License : MIT
# @@ReadME : # @@Copyright : Copyright 2026 CasjaysDev
# @@Copyright : Copyright 2023 CasjaysDev # @@Created : Tue May 5 02:38:04 PM EDT 2026
# @@Created : Mon Aug 28 06:48:42 PM EDT 2023
# @@File : 05-custom.sh # @@File : 05-custom.sh
# @@Description : script to run custom # @@Description : script to run custom
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # @@Changelog : newScript
# shellcheck shell=bash # @@TODO : Refactor code
# shellcheck disable=SC2016 # @@Other : N/A
# shellcheck disable=SC2031 # @@Resource : N/A
# shellcheck disable=SC2120 # @@Terminal App : yes
# shellcheck disable=SC2155 # @@sudo/root : yes
# shellcheck disable=SC2199 # @@Template : templates/dockerfiles/init_scripts/05-custom.sh
# shellcheck disable=SC2317 # - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options # Set bash options
set -o pipefail set -o pipefail
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS [ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Set env variables # Set env variables
exitCode=0 exitCode=0
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Predifined actions # Predefined actions
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Main script # Main script
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code # Set the exit code
exitCode=$? #exitCode=$?
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode exit $exitCode
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@@ -1,38 +1,43 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck shell=bash
##@Version : 202408270903-git # - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202605051438-git
# @@Author : CasjaysDev # @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro> # @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT # @@License : MIT
# @@ReadME : # @@Copyright : Copyright 2026 CasjaysDev
# @@Copyright : Copyright 2023 CasjaysDev # @@Created : Tue May 5 02:38:04 PM EDT 2026
# @@Created : Mon Aug 28 06:48:42 PM EDT 2023
# @@File : 06-post.sh # @@File : 06-post.sh
# @@Description : script to run post # @@Description : script to run post
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # @@Changelog : newScript
# shellcheck shell=bash # @@TODO : Refactor code
# shellcheck disable=SC2016 # @@Other : N/A
# shellcheck disable=SC2031 # @@Resource : N/A
# shellcheck disable=SC2120 # @@Terminal App : yes
# shellcheck disable=SC2155 # @@sudo/root : yes
# shellcheck disable=SC2199 # @@Template : templates/dockerfiles/init_scripts/06-post.sh
# shellcheck disable=SC2317 # - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options # Set bash options
set -o pipefail set -o pipefail
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS [ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Set env variables # Set env variables
exitCode=0 exitCode=0
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Predifined actions # Predefined actions
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Main script # Main script
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code # Set the exit code
exitCode=$? #exitCode=$?
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode exit $exitCode
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@@ -1,40 +1,49 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck shell=bash
##@Version : 202408270903-git # - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202605051438-git
# @@Author : CasjaysDev # @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro> # @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT # @@License : MIT
# @@ReadME : # @@Copyright : Copyright 2026 CasjaysDev
# @@Copyright : Copyright 2023 CasjaysDev # @@Created : Tue May 5 02:38:04 PM EDT 2026
# @@Created : Mon Aug 28 06:48:42 PM EDT 2023
# @@File : 07-cleanup.sh # @@File : 07-cleanup.sh
# @@Description : script to run cleanup # @@Description : script to run cleanup
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # @@Changelog : newScript
# shellcheck shell=bash # @@TODO : Refactor code
# shellcheck disable=SC2016 # @@Other : N/A
# shellcheck disable=SC2031 # @@Resource : N/A
# shellcheck disable=SC2120 # @@Terminal App : yes
# shellcheck disable=SC2155 # @@sudo/root : yes
# shellcheck disable=SC2199 # @@Template : templates/dockerfiles/init_scripts/07-cleanup.sh
# shellcheck disable=SC2317 # - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options # Set bash options
set -o pipefail set -o pipefail
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS [ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Load functions
__find_and_remove() { [ -z "$1" ] || find "${2:-/etc}" -iname "$1" -exec rm -Rf {} \; 2>/dev/null; }
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set env variables # Set env variables
exitCode=0 exitCode=0
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Predifined actions # Predefined actions
[ ! -d "/tmp" ] || rm -Rf "/tmp"/* if [ -d "/tmp" ]; then rm -Rf "/tmp"/*; fi
[ ! -d "/var/bind" ] || rm -Rf "/var/bind"/* if [ -d "$HOME/.cache" ]; then rm -Rf "$HOME/.cache"; fi
[ ! -d "/var/named" ] || rm -Rf "/var/named"/* if [ -d "/var/bind" ]; then rm -Rf "/var/bind"/*; fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if [ -d "/var/named" ]; then rm -Rf "/var/named"/*; fi
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Main script # Main script
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code # Set the exit code
exitCode=$? #exitCode=$?
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode exit $exitCode
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@@ -1,5 +1,22 @@
# default options - https://bind9.readthedocs.io/en/latest/chapter3.html # default options - https://bind9.readthedocs.io/en/latest/chapter3.html
##################################################################### #####################################################################
# NOTE on client source IPs:
#
# If named's query log only shows the docker bridge gateway (e.g.
# 172.17.0.1) as the client, that is a Docker NAT artifact - the default
# userland docker-proxy rewrites the source IP of forwarded UDP/TCP.
# To see real external client IPs, run the container with EITHER:
#
# docker run --network=host ... (skip port publishing)
#
# - or configure dockerd with userland-proxy disabled in
# /etc/docker/daemon.json:
# { "userland-proxy": false }
# and restart docker. iptables DNAT then preserves source IPs.
#
# bind itself sees whatever the kernel hands it; it can't recover an IP
# the proxy already discarded.
#####################################################################
# rndc keys # rndc keys
key "dhcp-key" { algorithm hmac-sha512; secret "REPLACE_KEY_DHCP"; }; key "dhcp-key" { algorithm hmac-sha512; secret "REPLACE_KEY_DHCP"; };
key "rndc-key" { algorithm hmac-sha512; secret "REPLACE_KEY_RNDC"; }; key "rndc-key" { algorithm hmac-sha512; secret "REPLACE_KEY_RNDC"; };
@@ -18,6 +35,12 @@ acl "forward" { 1.1.1.1; 8.8.8.8; 4.4.4.4; };
controls { inet 127.0.0.1 allow { trusted; } keys { "rndc-key"; }; }; controls { inet 127.0.0.1 allow { trusted; } keys { "rndc-key"; }; };
##################################################################### #####################################################################
options { options {
directory "REPLACE_VAR_DIR";
pid-file "REPLACE_RUN_DIR/named.pid";
managed-keys-directory "REPLACE_ETC_DIR/keys";
dump-file "REPLACE_DATA_DIR/stats/dump.txt";
statistics-file "REPLACE_DATA_DIR/stats/stats.txt";
memstatistics-file "REPLACE_DATA_DIR/stats/mem.txt";
version "9"; version "9";
listen-on { any; }; listen-on { any; };
listen-on-v6 { any; }; listen-on-v6 { any; };
@@ -37,12 +60,7 @@ options {
allow-query-cache { any; }; allow-query-cache { any; };
auth-nxdomain no; auth-nxdomain no;
dnssec-validation auto; dnssec-validation auto;
directory "REPLACE_VAR_DIR"; validate-except { "onion"; "exit"; };
managed-keys-directory "REPLACE_ETC_DIR/keys";
pid-file "REPLACE_RUN_DIR/named.pid";
dump-file "REPLACE_DATA_DIR/stats/dump.txt";
statistics-file "REPLACE_DATA_DIR/stats/stats.txt";
memstatistics-file "REPLACE_DATA_DIR/stats/mem.txt";
forwarders { 1.1.1.1; 8.8.8.8; 4.4.4.4; }; forwarders { 1.1.1.1; 8.8.8.8; 4.4.4.4; };
}; };
##################################################################### #####################################################################
@@ -86,6 +104,11 @@ zone "." {
# ********** end root info ********** # ********** end root info **********
##################################################################### #####################################################################
# ********** begin tor forwarding ********** # ********** begin tor forwarding **********
zone "exit" {
type forward;
forward only;
forwarders { 127.0.0.1 port 9053; };
};
zone "onion" { zone "onion" {
type forward; type forward;
forward only; forward only;

View File

@@ -1,26 +0,0 @@
# nginx fastcgi_params
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https if_not_empty;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

View File

@@ -18,6 +18,115 @@ http {
access_log /data/logs/nginx/nginx.access.log; access_log /data/logs/nginx/nginx.access.log;
map $http_upgrade $connection_upgrade { default upgrade; '' close; } map $http_upgrade $connection_upgrade { default upgrade; '' close; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Reverse-proxy header normalization
#
# Derive the real request scheme / host / port / prefix from upstream
# headers, falling back to the local request if the header is absent.
# Supports headers set by apache, haproxy, nginx, caddy, traefik, aws
# elb/alb, gcp lb, cloudflare, fastly, akamai, varnish, kubernetes
# ingress, and any RFC 7239 compliant proxy.
#
# Available downstream as $real_scheme, $real_host, $real_port,
# $real_https, $real_prefix - and passed to fastcgi/PHP via
# REQUEST_SCHEME, HTTP_HOST, SERVER_PORT, HTTPS, X-Forwarded-Prefix.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# X-Forwarded-Proto (or fall back to local scheme)
map $http_x_forwarded_proto $real_scheme {
default $http_x_forwarded_proto;
"" $scheme;
}
# HTTPS flag for CGI/PHP, derived from real scheme
map $real_scheme $real_https {
https on;
default "";
}
# X-Forwarded-Host / Forwarded host= (or fall back to Host)
map $http_x_forwarded_host $real_host {
default $http_x_forwarded_host;
"" $http_host;
}
# X-Forwarded-Port (or fall back to server port)
map $http_x_forwarded_port $real_port {
default $http_x_forwarded_port;
"" $server_port;
}
# X-Forwarded-Prefix / X-Script-Name (path-based routing); empty if absent
map $http_x_forwarded_prefix $real_prefix {
default $http_x_forwarded_prefix;
"" "";
}
# Don't let nginx emit absolute redirects with the internal scheme/host;
# send relative redirects that the browser resolves against its real URL.
absolute_redirect off;
port_in_redirect off;
server_name_in_redirect off;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Real client IP detection (apache, haproxy, nginx, caddy, traefik,
# aws elb/alb, gcp lb, cloudflare, fastly, etc.)
#
# set_real_ip_from declares which upstream IPs are trusted; nginx then
# walks X-Forwarded-For right-to-left, skipping any address inside a
# trusted CIDR, until it finds the first untrusted address - that becomes
# $remote_addr (also REMOTE_ADDR for fastcgi/PHP, and what shows up in
# access logs and any allow/deny / rate-limit / geoip rules).
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# loopback
set_real_ip_from 127.0.0.0/8;
set_real_ip_from ::1/128;
# RFC1918 private networks (covers internal proxy/LB, docker bridges,
# kubernetes pod/service networks, vpn ranges, etc.)
set_real_ip_from 10.0.0.0/8;
set_real_ip_from 172.16.0.0/12;
set_real_ip_from 192.168.0.0/16;
# RFC6598 carrier-grade NAT (sometimes used by cloud LBs)
set_real_ip_from 100.64.0.0/10;
# Link-local
set_real_ip_from 169.254.0.0/16;
set_real_ip_from fe80::/10;
# IPv6 unique-local
set_real_ip_from fc00::/7;
# Cloudflare IPv4 (https://www.cloudflare.com/ips-v4)
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 104.16.0.0/13;
set_real_ip_from 104.24.0.0/14;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 131.0.72.0/22;
# Cloudflare IPv6 (https://www.cloudflare.com/ips-v6)
set_real_ip_from 2400:cb00::/32;
set_real_ip_from 2606:4700::/32;
set_real_ip_from 2803:f800::/32;
set_real_ip_from 2405:b500::/32;
set_real_ip_from 2405:8100::/32;
set_real_ip_from 2a06:98c0::/29;
set_real_ip_from 2c0f:f248::/32;
# X-Forwarded-For is the de-facto standard set by all major proxies and
# CDNs. If you sit ONLY behind Cloudflare and want their authoritative
# header, change this to: real_ip_header CF-Connecting-IP;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
server { server {
listen REPLACE_SERVER_PORT; listen REPLACE_SERVER_PORT;
root REPLACE_SERVER_WWW_DIR; root REPLACE_SERVER_WWW_DIR;
@@ -84,11 +193,23 @@ http {
fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port; fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port; # Use the proxy-resolved values so $_SERVER reflects the actual
fastcgi_param SERVER_NAME $server_name; # client-facing request, not the internal proxy hop.
fastcgi_param HTTPS $https if_not_empty; fastcgi_param SERVER_PORT $real_port;
fastcgi_param SERVER_NAME $real_host;
fastcgi_param HTTP_HOST $real_host;
fastcgi_param REQUEST_SCHEME $real_scheme;
fastcgi_param HTTPS $real_https if_not_empty;
fastcgi_param QUERY_STRING $query_string; fastcgi_param QUERY_STRING $query_string;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# Pass the original forwarded headers through so apps that read
# them directly (instead of REMOTE_ADDR/etc.) still work.
fastcgi_param HTTP_X_FORWARDED_FOR $proxy_add_x_forwarded_for;
fastcgi_param HTTP_X_FORWARDED_PROTO $real_scheme;
fastcgi_param HTTP_X_FORWARDED_HOST $real_host;
fastcgi_param HTTP_X_FORWARDED_PORT $real_port;
fastcgi_param HTTP_X_FORWARDED_PREFIX $real_prefix;
fastcgi_param HTTP_X_REAL_IP $remote_addr;
fastcgi_pass 127.0.0.1:9000; fastcgi_pass 127.0.0.1:9000;
} }

View File

@@ -1,13 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck shell=bash # shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202511301726-git ##@Version : 202602061352-git
# @@Author : Jason Hempstead # @@Author : Jason Hempstead
# @@Contact : jason@casjaysdev.pro # @@Contact : jason@casjaysdev.pro
# @@License : WTFPL # @@License : WTFPL
# @@ReadME : entrypoint.sh --help # @@ReadME : entrypoint.sh --help
# @@Copyright : Copyright: (c) 2025 Jason Hempstead, Casjays Developments # @@Copyright : Copyright: (c) 2026 Jason Hempstead, Casjays Developments
# @@Created : Sunday, Nov 30, 2025 18:37 EST # @@Created : Tuesday, May 05, 2026 14:38 EDT
# @@File : entrypoint.sh # @@File : entrypoint.sh
# @@Description : Entrypoint file for bind # @@Description : Entrypoint file for bind
# @@Changelog : New script # @@Changelog : New script
@@ -21,56 +21,22 @@
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329 # shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# run trap command on exit # run trap command on exit
trap '__trap_exit_handler' EXIT trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' INT TERM PWR
trap '__trap_signal_handler' INT TERM PWR
# - - - - - - - - - - - - - - - - - - - - - - - - -
__trap_exit_handler() {
local retVal=$?
if [ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ]; then
rm -Rf "$SERVICE_PID_FILE" 2>/dev/null || true
fi
exit $retVal
}
# - - - - - - - - - - - - - - - - - - - - - - - - -
__trap_signal_handler() {
local retVal=$?
echo "Container received shutdown signal"
if [ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ]; then
rm -Rf "$SERVICE_PID_FILE" 2>/dev/null || true
fi
exit $retVal
}
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html # setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
if [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ]; then [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
export DEBUGGER_OPTIONS="$(<"/config/.debug")" { [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; } && echo "Enabling debugging" && set -o pipefail -x$DEBUGGER_OPTIONS && export DEBUGGER="on" || set -o pipefail
else
DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
fi
if [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; then
echo "Enabling debugging"
set -o pipefail -x$DEBUGGER_OPTIONS
export DEBUGGER="on"
else
set -o pipefail
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
PATH="/usr/local/etc/docker/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin" PATH="/usr/local/etc/docker/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options # Set bash options
SCRIPT_FILE="$0" SCRIPT_FILE="$0"
CONTAINER_NAME="bind" CONTAINER_NAME="bind"
SCRIPT_NAME="$(basename -- "$SCRIPT_FILE" 2>/dev/null)" SCRIPT_NAME="${SCRIPT_FILE##*/}"
CONTAINER_NAME="${ENV_CONTAINER_NAME:-$CONTAINER_NAME}" CONTAINER_NAME="${ENV_CONTAINER_NAME:-$CONTAINER_NAME}"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# remove whitespaces from beginning argument # remove whitespaces from beginning argument
while :; do while :; do [ "$1" = " " ] && shift 1 || break; done
if [ "$1" = " " ]; then
shift 1
else
break
fi
done
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
[ "$1" = "$SCRIPT_FILE" ] && shift 1 [ "$1" = "$SCRIPT_FILE" ] && shift 1
[ "$1" = "$SCRIPT_NAME" ] && shift 1 [ "$1" = "$SCRIPT_NAME" ] && shift 1
@@ -204,7 +170,7 @@ export ENTRYPOINT_DATA_INIT_FILE="${ENTRYPOINT_DATA_INIT_FILE:-/data/.docker_has
export ENTRYPOINT_CONFIG_INIT_FILE="${ENTRYPOINT_CONFIG_INIT_FILE:-/config/.docker_has_run}" export ENTRYPOINT_CONFIG_INIT_FILE="${ENTRYPOINT_CONFIG_INIT_FILE:-/config/.docker_has_run}"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
if [ -n "$CONTAINER_WEB_SERVER_WWW_REPO" ]; then if [ -n "$CONTAINER_WEB_SERVER_WWW_REPO" ]; then
www_temp_dir="/tmp/git/$(basename -- "$CONTAINER_WEB_SERVER_WWW_REPO")" www_temp_dir="/tmp/git/${CONTAINER_WEB_SERVER_WWW_REPO##*/}"
rm -Rf "${WWW_ROOT_DIR:?}"/* "${www_temp_dir:?}"/* 2>/dev/null || true rm -Rf "${WWW_ROOT_DIR:?}"/* "${www_temp_dir:?}"/* 2>/dev/null || true
mkdir -p "$WWW_ROOT_DIR" "$www_temp_dir" 2>/dev/null || true mkdir -p "$WWW_ROOT_DIR" "$www_temp_dir" 2>/dev/null || true
git clone -q "$CONTAINER_WEB_SERVER_WWW_REPO" "$www_temp_dir" 2>/dev/null || true git clone -q "$CONTAINER_WEB_SERVER_WWW_REPO" "$www_temp_dir" 2>/dev/null || true
@@ -401,7 +367,7 @@ if [ "$ENTRYPOINT_FIRST_RUN" != "no" ]; then
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# import hosts file into container # import hosts file into container
if [ -f "/usr/local/etc/hosts" ] && [ "$UPDATE_FILE_HOSTS" = "yes" ]; then if [ -f "/usr/local/etc/hosts" ] && [ "$UPDATE_FILE_HOSTS" = "yes" ]; then
cat "/usr/local/etc/hosts" 2>/dev/null | grep -vF "$HOSTNAME" >>"/etc/hosts" 2>/dev/null || true grep -vF "$HOSTNAME" "/usr/local/etc/hosts" 2>/dev/null >>"/etc/hosts" 2>/dev/null || true
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# import resolv.conf file into container # import resolv.conf file into container
@@ -428,72 +394,77 @@ if [ -f "/usr/local/bin/.gitkeep" ]; then
rm -Rf "/usr/local/bin/.gitkeep" 2>/dev/null || true rm -Rf "/usr/local/bin/.gitkeep" 2>/dev/null || true
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Setup bin directory - /config/bin > /usr/local/bin # Only run initialization on first run or when directories are not initialized
__initialize_custom_bin_dir if [ "$ENTRYPOINT_FIRST_RUN" != "no" ] || [ "$CONFIG_DIR_INITIALIZED" = "no" ] || [ "$DATA_DIR_INITIALIZED" = "no" ]; then
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Copy default system configs - /usr/local/share/template-files/defaults > /config/ # Setup bin directory - /config/bin > /usr/local/bin
__initialize_default_templates __initialize_custom_bin_dir
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Copy custom config files - /usr/local/share/template-files/config > /config/ # Copy default system configs - /usr/local/share/template-files/defaults > /config/
__initialize_config_dir if [ "$CONFIG_DIR_INITIALIZED" = "no" ]; then
# - - - - - - - - - - - - - - - - - - - - - - - - - __initialize_default_templates
# Copy custom data files - /usr/local/share/template-files/data > /data/ fi
__initialize_data_dir # - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - # Copy custom config files - /usr/local/share/template-files/config > /config/
__initialize_ssl_certs if [ "$CONFIG_DIR_INITIALIZED" = "no" ]; then
# - - - - - - - - - - - - - - - - - - - - - - - - - __initialize_config_dir
if [ -f "$ENTRYPOINT_INIT_FILE" ]; then fi
ENTRYPOINT_FIRST_RUN="no" # - - - - - - - - - - - - - - - - - - - - - - - - -
fi # Copy custom data files - /usr/local/share/template-files/data > /data/
# - - - - - - - - - - - - - - - - - - - - - - - - - if [ "$DATA_DIR_INITIALIZED" = "no" ]; then
if [ -d "/config" ]; then __initialize_data_dir
echo "Initialized on: $INIT_DATE" >"$ENTRYPOINT_INIT_FILE" 2>/dev/null || true fi
fi # - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - # Initialize SSL certificates
# Check if this is a new container __initialize_ssl_certs
if [ -f "$ENTRYPOINT_DATA_INIT_FILE" ]; then # - - - - - - - - - - - - - - - - - - - - - - - - -
DATA_DIR_INITIALIZED="yes" # Mark directories as initialized (only write if not already initialized)
fi if [ -d "/config" ] && [ "$CONFIG_DIR_INITIALIZED" = "no" ]; then
# - - - - - - - - - - - - - - - - - - - - - - - - - echo "Initialized on: $INIT_DATE" >"$ENTRYPOINT_CONFIG_INIT_FILE" 2>/dev/null || true
if [ -d "/data" ]; then CONFIG_DIR_INITIALIZED="yes"
echo "Initialized on: $INIT_DATE" >"$ENTRYPOINT_DATA_INIT_FILE" 2>/dev/null || true fi
fi # - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - if [ -d "/data" ] && [ "$DATA_DIR_INITIALIZED" = "no" ]; then
if [ -f "$ENTRYPOINT_CONFIG_INIT_FILE" ]; then echo "Initialized on: $INIT_DATE" >"$ENTRYPOINT_DATA_INIT_FILE" 2>/dev/null || true
CONFIG_DIR_INITIALIZED="yes" DATA_DIR_INITIALIZED="yes"
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
if [ -d "/config" ]; then if [ -d "/config" ] && [ ! -f "$ENTRYPOINT_INIT_FILE" ]; then
echo "Initialized on: $INIT_DATE" >"$ENTRYPOINT_CONFIG_INIT_FILE" 2>/dev/null || true echo "Initialized on: $INIT_DATE" >"$ENTRYPOINT_INIT_FILE" 2>/dev/null || true
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
if [ "$ENTRYPOINT_FIRST_RUN" != "no" ]; then
# setup the smtp server # setup the smtp server
__setup_mta __setup_mta
# - - - - - - - - - - - - - - - - - - - - - - - - -
ENTRYPOINT_FIRST_RUN="no"
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# if no pid assume container restart - clean stale files on restart # if no pid assume container restart - clean stale files on restart
if [ -f "$ENTRYPOINT_PID_FILE" ]; then if [ -f "$ENTRYPOINT_PID_FILE" ]; then
START_SERVICES="no" # Check if the PID in the file is still running
touch "$ENTRYPOINT_PID_FILE" entrypoint_pid=$(cat "$ENTRYPOINT_PID_FILE" 2>/dev/null || echo "")
if [ -n "$entrypoint_pid" ] && kill -0 "$entrypoint_pid" 2>/dev/null; then
# Process is still running, don't restart services
START_SERVICES="no"
touch "$ENTRYPOINT_PID_FILE"
else
# PID file exists but process is dead - this is a restart
START_SERVICES="yes"
# Clean any stale PID files on restart
rm -f /run/.start_init_scripts.pid /run/init.d/*.pid /run/*.pid 2>/dev/null || true
fi
else else
START_SERVICES=yes START_SERVICES=yes
# Clean any stale PID files on first run # Clean any stale PID files on first run
rm -f /run/__start_init_scripts.pid /run/init.d/*.pid /run/*.pid 2>/dev/null || true rm -f /run/.start_init_scripts.pid /run/init.d/*.pid /run/*.pid 2>/dev/null || true
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
if [ "$ENTRYPOINT_MESSAGE" = "yes" ]; then [ "$ENTRYPOINT_MESSAGE" = "yes" ] && __printf_space "40" "The containers ip address is:" "$CONTAINER_IP4_ADDRESS"
__printf_space "40" "The containers ip address is:" "$CONTAINER_IP4_ADDRESS"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Show configured listing processes # Show configured listing processes
if [ "$ENTRYPOINT_MESSAGE" = "yes" ] && [ -n "$ENV_PORTS" ]; then if [ "$ENTRYPOINT_MESSAGE" = "yes" ] && [ -n "$ENV_PORTS" ]; then
show_port="" show_port=""
for port in $ENV_PORTS; do for port in $ENV_PORTS; do [ -n "$port" ] && show_port+="$(printf '%s ' "${port// /}") "; done
if [ -n "$port" ]; then
show_port+="$(printf '%s ' "${port// /}") "
fi
done
__printf_space "40" "The following ports are open:" "$show_port" __printf_space "40" "The following ports are open:" "$show_port"
unset port show_port unset port show_port
fi fi
@@ -528,6 +499,9 @@ if [ "$START_SERVICES" = "yes" ] || [ -z "$1" ]; then
echo "$$" >"$ENTRYPOINT_PID_FILE" echo "$$" >"$ENTRYPOINT_PID_FILE"
__start_init_scripts "/usr/local/etc/docker/init.d" __start_init_scripts "/usr/local/etc/docker/init.d"
CONTAINER_INIT="${CONTAINER_INIT:-no}" CONTAINER_INIT="${CONTAINER_INIT:-no}"
# Services started successfully - enter monitoring mode
__no_exit
exit $?
fi fi
START_SERVICES="no" START_SERVICES="no"
fi fi
@@ -537,7 +511,7 @@ export START_SERVICES CONTAINER_INIT ENTRYPOINT_PID_FILE
case "$1" in case "$1" in
init) init)
shift 1 shift 1
echo "Container has been Initialized" __log_info "Container has been initialized"
exit 0 exit 0
;; ;;
tail) tail)
@@ -568,7 +542,7 @@ logs)
clean) clean)
log_files="$(find "/data/logs" -type f)" log_files="$(find "/data/logs" -type f)"
for log in "${log_files[@]}"; do for log in "${log_files[@]}"; do
echo "clearing $log" __log_info "Clearing log file: $log"
printf '' >$log printf '' >$log
done done
;; ;;
@@ -581,7 +555,7 @@ logs)
cron) cron)
shift 1 shift 1
__cron "$@" & __cron "$@" &
echo "cron script is running with pid: $!" __log_info "Cron script is running with PID: $!"
exit exit
;; ;;
# backup data and config dirs # backup data and config dirs
@@ -609,7 +583,7 @@ healthcheck)
[ "$healthEnabled" = "yes" ] || exit 0 [ "$healthEnabled" = "yes" ] || exit 0
if [ -d "/run/healthcheck" ] && [ "$(ls -A "/run/healthcheck" | wc -l)" -ne 0 ]; then if [ -d "/run/healthcheck" ] && [ "$(ls -A "/run/healthcheck" | wc -l)" -ne 0 ]; then
for service in /run/healthcheck/*; do for service in /run/healthcheck/*; do
name=$(basename -- $service) name="${service##*/}"
services+="$name " services+="$name "
done done
fi fi
@@ -697,11 +671,7 @@ start)
export PATH="/usr/local/etc/docker/init.d:$PATH" export PATH="/usr/local/etc/docker/init.d:$PATH"
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
scripts="$(ls -A "/usr/local/etc/docker/init.d")" scripts="$(ls -A "/usr/local/etc/docker/init.d")"
if [ -n "$scripts" ]; then [ -n "$scripts" ] && echo "$scripts" || echo "No scripts found in: /usr/local/etc/docker/init.d"
echo "$scripts"
else
echo "No scripts found in: /usr/local/etc/docker/init.d"
fi
exit exit
elif [ "$1" = "all" ]; then elif [ "$1" = "all" ]; then
shift $# shift $#
@@ -720,11 +690,7 @@ start)
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
if [ ! -f "$ENTRYPOINT_PID_FILE" ]; then if [ ! -f "$ENTRYPOINT_PID_FILE" ]; then
echo "$$" >"$ENTRYPOINT_PID_FILE" echo "$$" >"$ENTRYPOINT_PID_FILE"
if [ "$START_SERVICES" = "no" ] && [ "$CONTAINER_INIT" = "yes" ]; then [ "$START_SERVICES" = "no" ] && [ "$CONTAINER_INIT" = "yes" ] || __start_init_scripts "/usr/local/etc/docker/init.d"
:
else
__start_init_scripts "/usr/local/etc/docker/init.d"
fi
fi fi
__no_exit __no_exit
else else

View File

@@ -103,7 +103,7 @@ install)
[ -n "$1" ] || exit 0 [ -n "$1" ] || exit 0
[ "$USER_UID" -eq 0 ] || [ "$USER" = "root" ] || pkmgr_install_cmd="sudo $pkmgr_install_cmd" [ "$USER_UID" -eq 0 ] || [ "$USER" = "root" ] || pkmgr_install_cmd="sudo $pkmgr_install_cmd"
if [ -f "$1" ]; then if [ -f "$1" ]; then
install_list="$(cat "$1")" install_list="$(tr '\n' ' ' < "$1")"
else else
install_list="$*" install_list="$*"
fi fi
@@ -140,3 +140,4 @@ clean)
esac esac
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# end # end

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck shell=bash # shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202511301726-git ##@Version : 202602061352-git
# @@Author : Jason Hempstead # @@Author : Jason Hempstead
# @@Contact : git-admin@casjaysdev.pro # @@Contact : git-admin@casjaysdev.pro
# @@License : LICENSE.md # @@License : LICENSE.md
@@ -33,6 +33,19 @@ fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
__remove_extra_spaces() { sed 's/\( \)*/\1/g;s|^ ||g'; } __remove_extra_spaces() { sed 's/\( \)*/\1/g;s|^ ||g'; }
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
__log_debug() {
[ "$DEBUGGER" = "on" ] && echo "[DEBUG] $*" >&2
}
__log_info() {
echo "[INFO] $*"
}
__log_warn() {
echo "[WARN] $*" >&2
}
__log_error() {
echo "[ERROR] $*" >&2
}
# - - - - - - - - - - - - - - - - - - - - - - - - -
__printf_space() { __printf_space() {
local pad=$(printf '%0.1s' " "{1..60}) local pad=$(printf '%0.1s' " "{1..60})
local padlength=$1 local padlength=$1
@@ -47,13 +60,21 @@ __printf_space() {
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
__mkdir() { __mkdir() {
if [ -n "$1" ]; then if [ -n "$1" ]; then
mkdir -p "$@" 2>/dev/null || true if ! mkdir -p "$@" 2>/dev/null; then
[ "$DEBUGGER" = "on" ] && echo "Warning: Failed to create directory: $*" >&2
return 1
fi
fi fi
return 0
} }
__rm() { __rm() {
if [ -n "$1" ] && [ -e "$1" ]; then if [ -n "$1" ] && [ -e "$1" ]; then
rm -Rf "${1:?}" 2>/dev/null || true if ! rm -Rf "${1:?}" 2>/dev/null; then
[ "$DEBUGGER" = "on" ] && echo "Warning: Failed to remove: $1" >&2
return 1
fi
fi fi
return 0
} }
__grep_test() { __grep_test() {
if grep -sh "$1" "$2" 2>/dev/null | grep -qwF "${3:-$1}"; then if grep -sh "$1" "$2" 2>/dev/null | grep -qwF "${3:-$1}"; then
@@ -63,9 +84,10 @@ __grep_test() {
fi fi
} }
__netstat() { __netstat() {
if [ -f "$(type -P netstat 2>/dev/null)" ]; then if [ -n "$(command -v netstat 2>/dev/null)" ]; then
netstat "$@" 2>/dev/null netstat "$@" 2>/dev/null
else else
[ "$DEBUGGER" = "on" ] && echo "Warning: netstat command not found" >&2
return 10 return 10
fi fi
} }
@@ -227,11 +249,16 @@ __is_running() {
} }
__get_pid() { __get_pid() {
local result="" local result=""
if [ -z "$1" ]; then
[ "$DEBUGGER" = "on" ] && echo "Warning: __get_pid called without process name" >&2
return 1
fi
result="$(ps -ax --no-header 2>/dev/null | sed 's/^[[:space:]]*//g;s|;||g;s|:||g' | awk '{print $1,$5}' | sed 's|:||g' | grep "$1$" | grep -v 'grep' | awk -F' ' '{print $1}' | grep '[0-9]' | sort -uV | head -n1 | grep '.' 2>/dev/null || echo '')" result="$(ps -ax --no-header 2>/dev/null | sed 's/^[[:space:]]*//g;s|;||g;s|:||g' | awk '{print $1,$5}' | sed 's|:||g' | grep "$1$" | grep -v 'grep' | awk -F' ' '{print $1}' | grep '[0-9]' | sort -uV | head -n1 | grep '.' 2>/dev/null || echo '')"
if [ -n "$result" ]; then if [ -n "$result" ]; then
echo "$result" echo "$result"
return 0 return 0
else else
[ "$DEBUGGER" = "on" ] && echo "Debug: No PID found for process: $1" >&2
return 1 return 1
fi fi
} }
@@ -253,11 +280,11 @@ __no_exit() {
local failed_services="" local failed_services=""
local failure_count=0 local failure_count=0
[ -f "/run/no_exit.pid" ] && return 0 [ -f "/run/.no_exit.pid" ] && return 0
exec bash -c " exec bash -c "
trap 'echo \"Container shutdown requested\"; rm -f /run/no_exit.pid /run/*.pid; exit 0' TERM INT trap 'echo \"Container shutdown requested\"; rm -f /run/.no_exit.pid /run/*.pid; exit 0' TERM INT
echo \$\$ > /run/no_exit.pid echo \$\$ > /run/.no_exit.pid
while true; do while true; do
if [ -n \"$monitor_services\" ] && [ \"$monitor_services\" != \"tini\" ]; then if [ -n \"$monitor_services\" ] && [ \"$monitor_services\" != \"tini\" ]; then
@@ -327,7 +354,7 @@ __find_pgsql_conf() { find -L '/var/lib' '/etc' -maxdepth 8 -type f -name 'postg
__find_couchdb_conf() { return; } __find_couchdb_conf() { return; }
__find_mongodb_conf() { return; } __find_mongodb_conf() { return; }
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
__random_password() { cat "/dev/urandom" | tr -dc '0-9a-zA-Z' | head -c${1:-16} && echo ""; } __random_password() { tr -dc '0-9a-zA-Z' < /dev/urandom | head -c${1:-16} && echo ""; }
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
__init_working_dir() { __init_working_dir() {
local service_name="$SERVICE_NAME" # get service name local service_name="$SERVICE_NAME" # get service name
@@ -632,7 +659,7 @@ __cron() {
fi fi
[ $# -eq 0 ] && echo "Usage: cron [interval] [command]" && exit 1 [ $# -eq 0 ] && echo "Usage: cron [interval] [command]" && exit 1
local command="$*" local command="$*"
local bin="$(basename "${CRON_NAME:-$1}")" local bin="${CRON_NAME:-$1}"; bin="${bin##*/}"
[ -d "/run/cron" ] || mkdir -p "/run/cron" [ -d "/run/cron" ] || mkdir -p "/run/cron"
echo "$pid" >"/run/cron/$bin.pid" echo "$pid" >"/run/cron/$bin.pid"
echo "$command" >"/run/cron/$bin.run" echo "$command" >"/run/cron/$bin.run"
@@ -777,16 +804,20 @@ __fix_permissions() {
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
__get_gid() { grep "^$1:" /etc/group 2>/dev/null | awk -F ':' '{print $3}' || return 1; } __get_gid() { grep "^$1:" /etc/group 2>/dev/null | awk -F ':' '{print $3}' || return 1; }
__get_uid() { grep "^$1:" /etc/passwd 2>/dev/null | awk -F ':' '{print $3}' || return 1; } __get_uid() { grep "^$1:" /etc/passwd 2>/dev/null | awk -F ':' '{print $3}' || return 1; }
__check_for_uid() { cat "/etc/passwd" 2>/dev/null | awk -F ':' '{print $3}' | sort -u | grep -q "^$1$" 2>/dev/null || return 1; } __check_for_uid() { awk -F ':' '{print $3}' /etc/passwd 2>/dev/null | sort -u | grep -q "^$1$" || return 1; }
__check_for_guid() { cat "/etc/group" 2>/dev/null | awk -F ':' '{print $3}' | sort -u | grep -q "^$1$" 2>/dev/null || return 1; } __check_for_guid() { awk -F ':' '{print $3}' /etc/group 2>/dev/null | sort -u | grep -q "^$1$" || return 1; }
__check_for_user() { cat "/etc/passwd" 2>/dev/null | awk -F ':' '{print $1}' | sort -u | grep -q "^$1$" 2>/dev/null || return 1; } __check_for_user() { awk -F ':' '{print $1}' /etc/passwd 2>/dev/null | sort -u | grep -q "^$1$" || return 1; }
__check_for_group() { cat "/etc/group" 2>/dev/null | awk -F ':' '{print $1}' | sort -u | grep -q "^$1$" 2>/dev/null || return 1; } __check_for_group() { awk -F ':' '{print $1}' /etc/group 2>/dev/null | sort -u | grep -q "^$1$" || return 1; }
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# check if process is already running # check if process is already running
__proc_check() { __proc_check() {
# Skip process check for one-shot/configuration services
if [ "$SERVICE_USES_PID" = "no" ]; then
return 1
fi
local cmd_bin cmd_name check_result local cmd_bin cmd_name check_result
cmd_bin="$(type -P "${1:-$EXEC_CMD_BIN}" 2>/dev/null || echo "${1:-$EXEC_CMD_BIN}")" cmd_bin="$(type -P "${1:-$EXEC_CMD_BIN}" 2>/dev/null || echo "${1:-$EXEC_CMD_BIN}")"
cmd_name="$(basename "${cmd_bin:-${1:-$EXEC_CMD_NAME}}" 2>/dev/null)" cmd_name="${cmd_bin:-${1:-$EXEC_CMD_NAME}}"; cmd_name="${cmd_name##*/}"
if [ -z "$cmd_name" ] || [ "$cmd_name" = "." ]; then if [ -z "$cmd_name" ] || [ "$cmd_name" = "." ]; then
return 1 return 1
fi fi
@@ -858,11 +889,11 @@ __create_service_user() {
return 0 return 0
fi fi
# Validate user/group name format (alphanumeric, underscore, hyphen; must start with letter or underscore) # 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 if [ -n "$create_user" ] && [[ ! "$create_user" =~ ^[a-z_][a-z0-9_-]*$ ]]; then
echo "Error: Invalid username format '$create_user' - must start with letter/underscore, contain only lowercase alphanumeric, underscore, or hyphen" >&2 echo "Error: Invalid username format '$create_user' - must start with letter/underscore, contain only lowercase alphanumeric, underscore, or hyphen" >&2
return 1 return 1
fi fi
if [ -n "$create_group" ] && ! echo "$create_group" | grep -qE '^[a-z_][a-z0-9_-]*$'; then if [ -n "$create_group" ] && [[ ! "$create_group" =~ ^[a-z_][a-z0-9_-]*$ ]]; then
echo "Error: Invalid group name format '$create_group' - must start with letter/underscore, contain only lowercase alphanumeric, underscore, or hyphen" >&2 echo "Error: Invalid group name format '$create_group' - must start with letter/underscore, contain only lowercase alphanumeric, underscore, or hyphen" >&2
return 1 return 1
fi fi
@@ -892,11 +923,11 @@ __create_service_user() {
create_gid="$random_id" create_gid="$random_id"
fi fi
# Validate UID/GID are numeric and within valid range # Validate UID/GID are numeric and within valid range
if ! echo "$create_uid" | grep -qE '^[0-9]+$' || [ "$create_uid" -lt 1 ] || [ "$create_uid" -gt 65534 ]; then if [[ ! "$create_uid" =~ ^[0-9]+$ ]] || [ "$create_uid" -lt 1 ] || [ "$create_uid" -gt 65534 ]; then
echo "Error: Invalid UID '$create_uid' - must be a number between 1 and 65534" >&2 echo "Error: Invalid UID '$create_uid' - must be a number between 1 and 65534" >&2
return 1 return 1
fi fi
if ! echo "$create_gid" | grep -qE '^[0-9]+$' || [ "$create_gid" -lt 1 ] || [ "$create_gid" -gt 65534 ]; then if [[ ! "$create_gid" =~ ^[0-9]+$ ]] || [ "$create_gid" -lt 1 ] || [ "$create_gid" -gt 65534 ]; then
echo "Error: Invalid GID '$create_gid' - must be a number between 1 and 65534" >&2 echo "Error: Invalid GID '$create_gid' - must be a number between 1 and 65534" >&2
return 1 return 1
fi fi
@@ -1029,13 +1060,13 @@ __start_init_scripts() {
local retstatus="0" local retstatus="0"
local initStatus="0" local initStatus="0"
local critical_failures="0" local critical_failures="0"
local pidFile="/run/__start_init_scripts.pid" local pidFile="/run/.start_init_scripts.pid"
local init_dir="${1:-/usr/local/etc/docker/init.d}" local init_dir="${1:-/usr/local/etc/docker/init.d}"
local init_count="$(ls -A "$init_dir"/* 2>/dev/null | grep -v '\.sample' | wc -l)" local init_count="$(ls -A "$init_dir"/* 2>/dev/null | grep -v '\.sample' | wc -l)"
local exit_on_failure="${EXIT_ON_SERVICE_FAILURE:-true}" local exit_on_failure="${EXIT_ON_SERVICE_FAILURE:-true}"
# Clean stale PID files from previous runs # Clean stale PID files from previous runs
if [ ! -f "/run/__start_init_scripts.pid" ]; then if [ ! -f "/run/.start_init_scripts.pid" ]; then
echo "🧹 Cleaning stale PID files from previous container run" echo "🧹 Cleaning stale PID files from previous container run"
rm -f /run/*.pid /run/init.d/*.pid 2>/dev/null || true rm -f /run/*.pid /run/init.d/*.pid 2>/dev/null || true
fi fi
@@ -1059,9 +1090,9 @@ __start_init_scripts() {
for init in "$init_dir"/*.sh; do for init in "$init_dir"/*.sh; do
if [ -x "$init" ]; then if [ -x "$init" ]; then
touch "$pidFile" touch "$pidFile"
name="$(basename "$init")" name="${init##*/}"
service="$(printf '%s' "$name" | sed 's/^[^-]*-//;s|.sh$||g')" service="$(printf '%s' "$name" | sed 's/^[^-]*-//;s|.sh$||g')"
__service_banner "🔧" "Executing service script:" "$(basename "$init")" __service_banner "🔧" "Executing service script:" "${init##*/}"
# Execute the init script and capture the exit code # Execute the init script and capture the exit code
if source "$init"; then if source "$init"; then
# Check if service was disabled first # Check if service was disabled first
@@ -1075,14 +1106,15 @@ __start_init_scripts() {
__service_banner "✅" "Service $service completed successfully -" "configuration service" __service_banner "✅" "Service $service completed successfully -" "configuration service"
else else
# Allow some time for service to initialize # Allow some time for service to initialize
sleep 2 sleep 1
# Check for service success indicators # Check for service success indicators
local expected_pid_file="/run/init.d/$service.pid" local expected_pid_file="/run/init.d/$service.pid"
set +e set +e
# Check if this is a configuration service (no daemon process expected)
if [ "$SERVICE_USES_PID" = "no" ]; then if [ "$SERVICE_USES_PID" = "no" ]; then
# Service doesn't use PID files - assume success unless explicitly failed # Configuration service - no daemon process expected
initStatus="0" initStatus="0"
__service_banner "✅" "Service $service completed successfully -" "no PID tracking required" __service_banner "✅" "Service $service completed successfully -" "configuration service"
else else
# Service uses PID tracking - verify actual running processes # Service uses PID tracking - verify actual running processes
retPID="" retPID=""
@@ -1327,7 +1359,7 @@ __initialize_database() {
__find_replace "REPLACE_DATABASE_ROOT_PASS" "$db_admin_pass" "$dir" __find_replace "REPLACE_DATABASE_ROOT_PASS" "$db_admin_pass" "$dir"
__find_replace "REPLACE_DATABASE_NAME" "$DATABASE_NAME" "$dir" __find_replace "REPLACE_DATABASE_NAME" "$DATABASE_NAME" "$dir"
__find_replace "REPLACE_DATABASE_DIR" "$DATABASE_DIR" "$dir" __find_replace "REPLACE_DATABASE_DIR" "$DATABASE_DIR" "$dir"
if echo "$dir" | grep -q '^/etc'; then if [[ "$dir" == "/etc"* ]]; then
__find_replace "REPLACE_USER_NAME" "$db_normal_user" "/etc" __find_replace "REPLACE_USER_NAME" "$db_normal_user" "/etc"
__find_replace "REPLACE_USER_PASS" "$db_normal_pass" "/etc" __find_replace "REPLACE_USER_PASS" "$db_normal_pass" "/etc"
__find_replace "REPLACE_DATABASE_USER" "$db_normal_user" "/etc" __find_replace "REPLACE_DATABASE_USER" "$db_normal_user" "/etc"
@@ -1389,7 +1421,7 @@ __initialize_custom_bin_dir() {
echo "Setting up bin $SET_USR_BIN > $LOCAL_BIN_DIR" echo "Setting up bin $SET_USR_BIN > $LOCAL_BIN_DIR"
for create_bin_template in $SET_USR_BIN; do for create_bin_template in $SET_USR_BIN; do
if [ -n "$create_bin_template" ]; then if [ -n "$create_bin_template" ]; then
create_bin_name="$(basename "$create_bin_template")" create_bin_name="${create_bin_template##*/}"
if [ -e "$create_bin_template" ]; then if [ -e "$create_bin_template" ]; then
ln -sf "$create_bin_template" "$LOCAL_BIN_DIR/$create_bin_name" ln -sf "$create_bin_template" "$LOCAL_BIN_DIR/$create_bin_name"
fi fi
@@ -1400,51 +1432,85 @@ __initialize_custom_bin_dir() {
} }
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
__initialize_default_templates() { __initialize_default_templates() {
local errors=0
if [ -n "$DEFAULT_TEMPLATE_DIR" ]; then if [ -n "$DEFAULT_TEMPLATE_DIR" ]; then
if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -d "/config" ]; then if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -d "/config" ]; then
echo "Copying default config files $DEFAULT_TEMPLATE_DIR > /config" __log_info "Copying default config files $DEFAULT_TEMPLATE_DIR > /config"
if [ ! -d "$DEFAULT_TEMPLATE_DIR" ]; then
__log_warn "Template directory not found: $DEFAULT_TEMPLATE_DIR"
return 0
fi
for create_config_template in "$DEFAULT_TEMPLATE_DIR"/*; do for create_config_template in "$DEFAULT_TEMPLATE_DIR"/*; do
if [ -n "$create_config_template" ]; then if [ -e "$create_config_template" ]; then
create_template_name="$(basename "$create_config_template")" create_template_name="${create_config_template##*/}"
if [ -d "$create_config_template" ]; then if [ -d "$create_config_template" ]; then
mkdir -p "/config/$create_template_name/" mkdir -p "/config/$create_template_name/" || errors=$((errors + 1))
__is_dir_empty "/config/$create_template_name" && cp -Rf "$create_config_template/." "/config/$create_template_name/" 2>/dev/null if __is_dir_empty "/config/$create_template_name"; then
elif [ -e "$create_config_template" ]; then if ! cp -Rf "$create_config_template/." "/config/$create_template_name/" 2>/dev/null; then
[ -e "/config/$create_template_name" ] || cp -Rf "$create_config_template" "/config/$create_template_name" 2>/dev/null __log_warn "Failed to copy template directory: $create_template_name"
errors=$((errors + 1))
fi
fi
elif [ -f "$create_config_template" ]; then
if [ ! -e "/config/$create_template_name" ]; then
if ! cp -Rf "$create_config_template" "/config/$create_template_name" 2>/dev/null; then
__log_warn "Failed to copy template file: $create_template_name"
errors=$((errors + 1))
fi
fi
fi fi
fi fi
done done
unset create_config_template create_template_name unset create_config_template create_template_name
__log_debug "Template initialization completed with $errors errors"
fi fi
fi fi
return 0
} }
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
__initialize_config_dir() { __initialize_config_dir() {
local errors=0
if [ -n "$DEFAULT_CONF_DIR" ]; then if [ -n "$DEFAULT_CONF_DIR" ]; then
if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -d "/config" ]; then if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -d "/config" ]; then
echo "Copying custom config files: $DEFAULT_CONF_DIR > /config" __log_info "Copying custom config files: $DEFAULT_CONF_DIR > /config"
if [ ! -d "$DEFAULT_CONF_DIR" ]; then
__log_warn "Config directory not found: $DEFAULT_CONF_DIR"
return 0
fi
for create_config_template in "$DEFAULT_CONF_DIR"/*; do for create_config_template in "$DEFAULT_CONF_DIR"/*; do
create_config_name="$(basename "$create_config_template")" if [ -e "$create_config_template" ]; then
if [ -n "$create_config_template" ]; then create_config_name="${create_config_template##*/}"
if [ -d "$create_config_template" ]; then if [ -d "$create_config_template" ]; then
mkdir -p "/config/$create_config_name" mkdir -p "/config/$create_config_name" || errors=$((errors + 1))
__is_dir_empty "/config/$create_config_name" && cp -Rf "$create_config_template/." "/config/$create_config_name/" 2>/dev/null if __is_dir_empty "/config/$create_config_name"; then
elif [ -e "$create_config_template" ]; then if ! cp -Rf "$create_config_template/." "/config/$create_config_name/" 2>/dev/null; then
[ -e "/config/$create_config_name" ] || cp -Rf "$create_config_template" "/config/$create_config_name" 2>/dev/null __log_warn "Failed to copy config directory: $create_config_name"
errors=$((errors + 1))
fi
fi
elif [ -f "$create_config_template" ]; then
if [ ! -e "/config/$create_config_name" ]; then
if ! cp -Rf "$create_config_template" "/config/$create_config_name" 2>/dev/null; then
__log_warn "Failed to copy config file: $create_config_name"
errors=$((errors + 1))
fi
fi
fi fi
fi fi
done done
unset create_config_template create_config_name unset create_config_template create_config_name
__log_debug "Config initialization completed with $errors errors"
fi fi
fi fi
return 0
} }
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
__initialize_data_dir() { __initialize_data_dir() {
if [ -d "/data" ]; then if [ -d "/data" ]; then
if [ "$DATA_DIR_INITIALIZED" = "false" ] && [ -n "$DEFAULT_DATA_DIR" ]; then if [ "$DATA_DIR_INITIALIZED" = "false" ] && [ -n "$DEFAULT_DATA_DIR" ]; then
echo "Copying data files $DEFAULT_DATA_DIR > /data" __log_info "Copying data files $DEFAULT_DATA_DIR > /data"
for create_data_template in "$DEFAULT_DATA_DIR"/*; do for create_data_template in "$DEFAULT_DATA_DIR"/*; do
create_data_name="$(basename "$create_data_template")" create_data_name="${create_data_template##*/}"
if [ -n "$create_data_template" ]; then if [ -n "$create_data_template" ]; then
if [ -d "$create_data_template" ]; then if [ -d "$create_data_template" ]; then
mkdir -p "/data/$create_data_name" mkdir -p "/data/$create_data_name"
@@ -1480,7 +1546,7 @@ __is_htdocs_mounted() {
WWW_ROOT_DIR="${WWW_ROOT_DIR:-/data/htdocs}" WWW_ROOT_DIR="${WWW_ROOT_DIR:-/data/htdocs}"
[ -n "$ENV_WWW_ROOT_DIR" ] && WWW_ROOT_DIR="$ENV_WWW_ROOT_DIR" [ -n "$ENV_WWW_ROOT_DIR" ] && WWW_ROOT_DIR="$ENV_WWW_ROOT_DIR"
if [ -n "$IMPORT_FROM_GIT" ]; then if [ -n "$IMPORT_FROM_GIT" ]; then
if ! echo "$IMPORT_FROM_GIT" | grep -qE 'https://|http://|git://|ssh://'; then if [[ ! "$IMPORT_FROM_GIT" =~ (https://|http://|git://|ssh://) ]]; then
unset IMPORT_FROM_GIT unset IMPORT_FROM_GIT
fi fi
fi fi
@@ -1540,7 +1606,7 @@ __start_php_dev_server() {
find "/usr/local/share/httpd" -type f -not -path '.git*' -iname '*.php' -exec sed -i 's|[<].*SERVER_ADDR.*[>]|'${CONTAINER_IP4_ADDRESS:-127.0.0.1}'|g' {} \; 2>/dev/null find "/usr/local/share/httpd" -type f -not -path '.git*' -iname '*.php' -exec sed -i 's|[<].*SERVER_ADDR.*[>]|'${CONTAINER_IP4_ADDRESS:-127.0.0.1}'|g' {} \; 2>/dev/null
php -S 0.0.0.0:$PHP_DEV_SERVER_PORT -t "/usr/local/share/httpd" php -S 0.0.0.0:$PHP_DEV_SERVER_PORT -t "/usr/local/share/httpd"
fi fi
if ! echo "$1" | grep -q "^/usr/local/share/httpd"; then if [[ "$1" != "/usr/local/share/httpd"* ]]; then
find "$1" -type f -not -path '.git*' -iname '*.php' -exec sed -i 's|[<].*SERVER_ADDR.*[>]|'${CONTAINER_IP4_ADDRESS:-127.0.0.1}'|g' {} \; 2>/dev/null find "$1" -type f -not -path '.git*' -iname '*.php' -exec sed -i 's|[<].*SERVER_ADDR.*[>]|'${CONTAINER_IP4_ADDRESS:-127.0.0.1}'|g' {} \; 2>/dev/null
php -S 0.0.0.0:$PHP_DEV_SERVER_PORT -t "$1" php -S 0.0.0.0:$PHP_DEV_SERVER_PORT -t "$1"
fi fi
@@ -1602,7 +1668,7 @@ __backup() {
fi fi
local exitCodeP=0 local exitCodeP=0
local exitStatus=0 local exitStatus=0
local pidFile="/run/backup.pid" local pidFile="/run/.backup.pid"
local logDir="/data/log/backups" local logDir="/data/log/backups"
maxDays="${BACKUP_MAX_DAYS:-$maxDays}" maxDays="${BACKUP_MAX_DAYS:-$maxDays}"
cronTime="${BACKUP_RUN_CRON:-$cronTime}" cronTime="${BACKUP_RUN_CRON:-$cronTime}"
@@ -1682,7 +1748,7 @@ export LIGHTTPD_CONFIG_FILE="${LIGHTTPD_CONFIG_FILE:-$(__find_lighttpd_conf)}"
export MARIADB_CONFIG_FILE="${MARIADB_CONFIG_FILE:-$(__find_mysql_conf)}" export MARIADB_CONFIG_FILE="${MARIADB_CONFIG_FILE:-$(__find_mysql_conf)}"
export POSTGRES_CONFIG_FILE="${POSTGRES_CONFIG_FILE:-$(__find_pgsql_conf)}" export POSTGRES_CONFIG_FILE="${POSTGRES_CONFIG_FILE:-$(__find_pgsql_conf)}"
export MONGODB_CONFIG_FILE="${MONGODB_CONFIG_FILE:-$(__find_mongodb_conf)}" export MONGODB_CONFIG_FILE="${MONGODB_CONFIG_FILE:-$(__find_mongodb_conf)}"
export ENTRYPOINT_PID_FILE="${ENTRYPOINT_PID_FILE:-/run/init.d/entrypoint.pid}" export ENTRYPOINT_PID_FILE="${ENTRYPOINT_PID_FILE:-/run/.entrypoint.pid}"
export ENTRYPOINT_INIT_FILE="${ENTRYPOINT_INIT_FILE:-/config/.entrypoint.done}" export ENTRYPOINT_INIT_FILE="${ENTRYPOINT_INIT_FILE:-/config/.entrypoint.done}"
export ENTRYPOINT_DATA_INIT_FILE="${ENTRYPOINT_DATA_INIT_FILE:-/data/.docker_has_run}" export ENTRYPOINT_DATA_INIT_FILE="${ENTRYPOINT_DATA_INIT_FILE:-/data/.docker_has_run}"
export ENTRYPOINT_CONFIG_INIT_FILE="${ENTRYPOINT_CONFIG_INIT_FILE:-/config/.docker_has_run}" export ENTRYPOINT_CONFIG_INIT_FILE="${ENTRYPOINT_CONFIG_INIT_FILE:-/config/.docker_has_run}"

View File

@@ -1,14 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck shell=bash # shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202511301726-git ##@Version : 202602061352-git
# @@Author : Jason Hempstead # @@Author : Jason Hempstead
# @@Contact : jason@casjaysdev.pro # @@Contact : jason@casjaysdev.pro
# @@License : LICENSE.md # @@License : WTFPL
# @@ReadME : 01-tor.sh --help # @@ReadME : start-service.sh --help
# @@Copyright : Copyright: (c) 2025 Jason Hempstead, Casjays Developments # @@Copyright : Copyright: (c) 2026 Jason Hempstead, Casjays Developments
# @@Created : Sunday, Nov 30, 2025 18:46 EST # @@Created : Tuesday, May 05, 2026 14:38 EDT
# @@File : 01-tor.sh # @@File : start-service.sh
# @@Description : # @@Description :
# @@Changelog : New script # @@Changelog : New script
# @@TODO : Better documentation # @@TODO : Better documentation
@@ -26,28 +26,31 @@ set -e
trap '__trap_err_handler' ERR trap '__trap_err_handler' ERR
trap 'retVal=$?;if [ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ]; then rm -Rf "$SERVICE_PID_FILE"; fi;exit $retVal' SIGINT SIGTERM SIGPWR trap 'retVal=$?;if [ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ]; then rm -Rf "$SERVICE_PID_FILE"; fi;exit $retVal' SIGINT SIGTERM SIGPWR
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# ERR trap handler - only fail on critical errors # ERR trap handler - smart about critical vs non-critical errors
__trap_err_handler() { __trap_err_handler() {
local retVal=$? local retVal=$?
local line_number=$LINENO
local command="$BASH_COMMAND" local command="$BASH_COMMAND"
if [ $retVal -gt 0 ] && [ $retVal -ne 130 ] && [ $retVal -ne 141 ]; then # Ignore SIGPIPE and user interrupts
if [[ "$command" =~ (mkdir|touch|chmod|chown|ln|cp|mv|rm|echo|printf|cat|tee|sed|awk|grep) ]]; then [ $retVal -eq 130 ] || [ $retVal -eq 141 ] && return $retVal
echo "⚠️ Non-critical command failed (continuing): $command" >&2 # Non-critical: file operations, text processing, user/group operations
return 0 if [[ "$command" =~ (mkdir|touch|chmod|chown|chgrp|ln|cp|mv|rm|echo|printf|cat|tee|sed|awk|grep|find|sort|uniq|adduser|addgroup|usermod|groupmod|id|getent) ]]; then
else return 0
echo "❌ Fatal error occurred: Exit code $retVal at line $line_number in command: $command" >&2
if [ "$SERVICE_IS_RUNNING" != "yes" ]; then
kill -TERM 1 2>/dev/null || true
fi
fi
fi fi
return $retVal # Non-critical: conditional checks that might fail
if [[ "$command" =~ (test|\[|\[\[|kill -0|pgrep|pidof|ps) ]]; then
return 0
fi
# Critical error - but only fail if service hasn't started yet
if [ "$SERVICE_IS_RUNNING" != "yes" ]; then
echo "❌ Critical error (exit $retVal): $command" >&2
kill -TERM 1 2>/dev/null || exit $retVal
fi
return 0
} }
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
SCRIPT_FILE="$0" SCRIPT_FILE="$0"
SERVICE_NAME="tor" SERVICE_NAME="tor"
SCRIPT_NAME="$(basename -- "$SCRIPT_FILE" 2>/dev/null)" SCRIPT_NAME="${SCRIPT_FILE##*/}"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Function to exit appropriately based on context # Function to exit appropriately based on context
__script_exit() { __script_exit() {
@@ -70,18 +73,8 @@ if [ -n "$TOR_APPNAME_ENABLED" ]; then
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html # setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
if [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ]; then [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
export DEBUGGER_OPTIONS="$(<"/config/.debug")" { [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; } && echo "Enabling debugging" && set -xo pipefail -x$DEBUGGER_OPTIONS && export DEBUGGER="on" || set -o pipefail
else
DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
fi
if [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; then
echo "Enabling debugging"
set -xo pipefail -x$DEBUGGER_OPTIONS
export DEBUGGER="on"
else
set -o pipefail
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
export PATH="/usr/local/etc/docker/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin" export PATH="/usr/local/etc/docker/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -98,7 +91,7 @@ for set_env in "/root/env.sh" "/usr/local/etc/docker/env"/*.sh "/config/env"/*.s
done done
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# exit if __start_init_scripts function hasn't been Initialized # exit if __start_init_scripts function hasn't been Initialized
if [ ! -f "/run/__start_init_scripts.pid" ]; then if [ ! -f "/run/.start_init_scripts.pid" ]; then
echo "__start_init_scripts function hasn't been Initialized" >&2 echo "__start_init_scripts function hasn't been Initialized" >&2
SERVICE_IS_RUNNING="no" SERVICE_IS_RUNNING="no"
__script_exit 1 __script_exit 1
@@ -176,7 +169,7 @@ EXEC_CMD_BIN='tor'
EXEC_CMD_ARGS='-f $ETC_DIR/torrc' EXEC_CMD_ARGS='-f $ETC_DIR/torrc'
# execute script before # execute script before
EXEC_PRE_SCRIPT='' EXEC_PRE_SCRIPT=''
# Set to no if the service is not running otherwise leave blank # Set to 'no' for configuration services (no daemon process), leave blank for actual services
SERVICE_USES_PID='' SERVICE_USES_PID=''
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Is this service a web server # Is this service a web server
@@ -519,30 +512,31 @@ __run_start_script() {
if [ -z "$cmd" ]; then if [ -z "$cmd" ]; then
__post_execute 2>"/dev/stderr" | tee -p -a "/data/logs/init.txt" __post_execute 2>"/dev/stderr" | tee -p -a "/data/logs/init.txt"
retVal=$? retVal=$?
echo "Initializing $SCRIPT_NAME has completed" __log_info "Initialization of $SCRIPT_NAME has completed"
__script_exit $retVal __script_exit $retVal
else else
# ensure the command exists # ensure the command exists
if [ ! -x "$cmd" ]; then if [ ! -x "$cmd" ]; then
echo "$name is not a valid executable" __log_error "$name is not a valid executable"
return 2 return 2
fi fi
# check and exit if already running # check and exit if already running (respects SERVICE_USES_PID in __proc_check)
if __proc_check "$name" || __proc_check "$cmd"; then if __proc_check "$name" || __proc_check "$cmd"; then
__log_debug "Service $name is already running"
return 0 return 0
else else
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# show message if env exists # show message if env exists
if [ -n "$cmd" ]; then if [ -n "$cmd" ]; then
if [ -n "$SERVICE_USER" ]; then if [ -n "$SERVICE_USER" ]; then
echo "Setting up $cmd to run as $SERVICE_USER" __log_info "Setting up $cmd to run as $SERVICE_USER"
else else
SERVICE_USER="root" SERVICE_USER="root"
fi fi
if [ -n "$SERVICE_PORT" ]; then if [ -n "$SERVICE_PORT" ]; then
echo "$name will be running on port $SERVICE_PORT" __log_info "$name will be running on port $SERVICE_PORT"
else else
SERVICE_PORT="" SERVICE_PORT="9053"
fi fi
fi fi
if [ -n "$pre" ] && [ -n "$(command -v "$pre" 2>/dev/null)" ]; then if [ -n "$pre" ] && [ -n "$(command -v "$pre" 2>/dev/null)" ]; then
@@ -553,9 +547,9 @@ __run_start_script() {
message="Starting service: $name $args" message="Starting service: $name $args"
fi fi
if [ -n "$su_exec" ]; then if [ -n "$su_exec" ]; then
echo "using $su_exec" | tee -a -p "/data/logs/init.txt" __log_debug "Using $su_exec" | tee -a -p "/data/logs/init.txt"
fi fi
echo "$message" | tee -a -p "/data/logs/init.txt" __log_info "$message" | tee -a -p "/data/logs/init.txt"
su_cmd touch "$SERVICE_PID_FILE" su_cmd touch "$SERVICE_PID_FILE"
if [ "$RESET_ENV" = "yes" ]; then if [ "$RESET_ENV" = "yes" ]; then
env_command="$(echo "env -i HOME=\"$home\" LC_CTYPE=\"$lc_type\" PATH=\"$path\" HOSTNAME=\"$sysname\" USER=\"${SERVICE_USER:-$RUNAS_USER}\" $extra_env")" env_command="$(echo "env -i HOME=\"$home\" LC_CTYPE=\"$lc_type\" PATH=\"$path\" HOSTNAME=\"$sysname\" USER=\"${SERVICE_USER:-$RUNAS_USER}\" $extra_env")"
@@ -656,7 +650,7 @@ fi
# default exit code # default exit code
SERVICE_EXIT_CODE=0 SERVICE_EXIT_CODE=0
# application specific # application specific
EXEC_CMD_NAME="$(basename -- "$EXEC_CMD_BIN")" EXEC_CMD_NAME="${EXEC_CMD_BIN##*/}"
SERVICE_PID_FILE="/run/init.d/$EXEC_CMD_NAME.pid" SERVICE_PID_FILE="/run/init.d/$EXEC_CMD_NAME.pid"
SERVICE_PID_NUMBER="$(__pgrep "$EXEC_CMD_NAME" 2>/dev/null || echo '')" SERVICE_PID_NUMBER="$(__pgrep "$EXEC_CMD_NAME" 2>/dev/null || echo '')"
if type -P "$EXEC_CMD_BIN" &>/dev/null; then if type -P "$EXEC_CMD_BIN" &>/dev/null; then
@@ -923,9 +917,7 @@ __pre_execute
__fix_permissions "$SERVICE_USER" "$SERVICE_GROUP" __fix_permissions "$SERVICE_USER" "$SERVICE_GROUP"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# #
if ! __run_pre_execute_checks 2>/dev/stderr | tee -a -p "/data/logs/entrypoint.log" "/data/logs/init.txt"; then __run_pre_execute_checks 2>/dev/stderr | tee -a -p "/data/logs/entrypoint.log" "/data/logs/init.txt" || return 20
return 20
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
__run_start_script 2>>/dev/stderr | tee -p -a "/data/logs/entrypoint.log" __run_start_script 2>>/dev/stderr | tee -p -a "/data/logs/entrypoint.log"
errorCode=$? errorCode=$?

View File

@@ -1,14 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck shell=bash # shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202511301726-git ##@Version : 202602061352-git
# @@Author : Jason Hempstead # @@Author : Jason Hempstead
# @@Contact : jason@casjaysdev.pro # @@Contact : jason@casjaysdev.pro
# @@License : LICENSE.md # @@License : WTFPL
# @@ReadME : 02-named.sh --help # @@ReadME : start-service.sh --help
# @@Copyright : Copyright: (c) 2025 Jason Hempstead, Casjays Developments # @@Copyright : Copyright: (c) 2026 Jason Hempstead, Casjays Developments
# @@Created : Sunday, Nov 30, 2025 18:41 EST # @@Created : Tuesday, May 05, 2026 14:38 EDT
# @@File : 02-named.sh # @@File : start-service.sh
# @@Description : # @@Description :
# @@Changelog : New script # @@Changelog : New script
# @@TODO : Better documentation # @@TODO : Better documentation
@@ -26,28 +26,31 @@ set -e
trap '__trap_err_handler' ERR trap '__trap_err_handler' ERR
trap 'retVal=$?;if [ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ]; then rm -Rf "$SERVICE_PID_FILE"; fi;exit $retVal' SIGINT SIGTERM SIGPWR trap 'retVal=$?;if [ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ]; then rm -Rf "$SERVICE_PID_FILE"; fi;exit $retVal' SIGINT SIGTERM SIGPWR
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# ERR trap handler - only fail on critical errors # ERR trap handler - smart about critical vs non-critical errors
__trap_err_handler() { __trap_err_handler() {
local retVal=$? local retVal=$?
local line_number=$LINENO
local command="$BASH_COMMAND" local command="$BASH_COMMAND"
if [ $retVal -gt 0 ] && [ $retVal -ne 130 ] && [ $retVal -ne 141 ]; then # Ignore SIGPIPE and user interrupts
if [[ "$command" =~ (mkdir|touch|chmod|chown|ln|cp|mv|rm|echo|printf|cat|tee|sed|awk|grep) ]]; then [ $retVal -eq 130 ] || [ $retVal -eq 141 ] && return $retVal
echo "⚠️ Non-critical command failed (continuing): $command" >&2 # Non-critical: file operations, text processing, user/group operations
return 0 if [[ "$command" =~ (mkdir|touch|chmod|chown|chgrp|ln|cp|mv|rm|echo|printf|cat|tee|sed|awk|grep|find|sort|uniq|adduser|addgroup|usermod|groupmod|id|getent) ]]; then
else return 0
echo "❌ Fatal error occurred: Exit code $retVal at line $line_number in command: $command" >&2
if [ "$SERVICE_IS_RUNNING" != "yes" ]; then
kill -TERM 1 2>/dev/null || true
fi
fi
fi fi
return $retVal # Non-critical: conditional checks that might fail
if [[ "$command" =~ (test|\[|\[\[|kill -0|pgrep|pidof|ps) ]]; then
return 0
fi
# Critical error - but only fail if service hasn't started yet
if [ "$SERVICE_IS_RUNNING" != "yes" ]; then
echo "❌ Critical error (exit $retVal): $command" >&2
kill -TERM 1 2>/dev/null || exit $retVal
fi
return 0
} }
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
SCRIPT_FILE="$0" SCRIPT_FILE="$0"
SERVICE_NAME="named" SERVICE_NAME="named"
SCRIPT_NAME="$(basename -- "$SCRIPT_FILE" 2>/dev/null)" SCRIPT_NAME="${SCRIPT_FILE##*/}"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Function to exit appropriately based on context # Function to exit appropriately based on context
__script_exit() { __script_exit() {
@@ -70,18 +73,8 @@ if [ -n "$NAMED_APPNAME_ENABLED" ]; then
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html # setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
if [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ]; then [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
export DEBUGGER_OPTIONS="$(<"/config/.debug")" { [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; } && echo "Enabling debugging" && set -xo pipefail -x$DEBUGGER_OPTIONS && export DEBUGGER="on" || set -o pipefail
else
DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
fi
if [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; then
echo "Enabling debugging"
set -xo pipefail -x$DEBUGGER_OPTIONS
export DEBUGGER="on"
else
set -o pipefail
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
export PATH="/usr/local/etc/docker/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin" export PATH="/usr/local/etc/docker/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -98,7 +91,7 @@ for set_env in "/root/env.sh" "/usr/local/etc/docker/env"/*.sh "/config/env"/*.s
done done
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# exit if __start_init_scripts function hasn't been Initialized # exit if __start_init_scripts function hasn't been Initialized
if [ ! -f "/run/__start_init_scripts.pid" ]; then if [ ! -f "/run/.start_init_scripts.pid" ]; then
echo "__start_init_scripts function hasn't been Initialized" >&2 echo "__start_init_scripts function hasn't been Initialized" >&2
SERVICE_IS_RUNNING="no" SERVICE_IS_RUNNING="no"
__script_exit 1 __script_exit 1
@@ -182,7 +175,7 @@ EXEC_CMD_BIN='named'
EXEC_CMD_ARGS='-f -u $SERVICE_USER -c $ETC_DIR/named.conf' EXEC_CMD_ARGS='-f -u $SERVICE_USER -c $ETC_DIR/named.conf'
# execute script before # execute script before
EXEC_PRE_SCRIPT='' EXEC_PRE_SCRIPT=''
# Set to no if the service is not running otherwise leave blank # Set to 'no' for configuration services (no daemon process), leave blank for actual services
SERVICE_USES_PID='' SERVICE_USES_PID=''
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Is this service a web server # Is this service a web server
@@ -674,30 +667,31 @@ __run_start_script() {
if [ -z "$cmd" ]; then if [ -z "$cmd" ]; then
__post_execute 2>"/dev/stderr" | tee -p -a "/data/logs/init.txt" __post_execute 2>"/dev/stderr" | tee -p -a "/data/logs/init.txt"
retVal=$? retVal=$?
echo "Initializing $SCRIPT_NAME has completed" __log_info "Initialization of $SCRIPT_NAME has completed"
__script_exit $retVal __script_exit $retVal
else else
# ensure the command exists # ensure the command exists
if [ ! -x "$cmd" ]; then if [ ! -x "$cmd" ]; then
echo "$name is not a valid executable" __log_error "$name is not a valid executable"
return 2 return 2
fi fi
# check and exit if already running # check and exit if already running (respects SERVICE_USES_PID in __proc_check)
if __proc_check "$name" || __proc_check "$cmd"; then if __proc_check "$name" || __proc_check "$cmd"; then
__log_debug "Service $name is already running"
return 0 return 0
else else
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# show message if env exists # show message if env exists
if [ -n "$cmd" ]; then if [ -n "$cmd" ]; then
if [ -n "$SERVICE_USER" ]; then if [ -n "$SERVICE_USER" ]; then
echo "Setting up $cmd to run as $SERVICE_USER" __log_info "Setting up $cmd to run as $SERVICE_USER"
else else
SERVICE_USER="root" SERVICE_USER="root"
fi fi
if [ -n "$SERVICE_PORT" ]; then if [ -n "$SERVICE_PORT" ]; then
echo "$name will be running on port $SERVICE_PORT" __log_info "$name will be running on port $SERVICE_PORT"
else else
SERVICE_PORT="" SERVICE_PORT="53"
fi fi
fi fi
if [ -n "$pre" ] && [ -n "$(command -v "$pre" 2>/dev/null)" ]; then if [ -n "$pre" ] && [ -n "$(command -v "$pre" 2>/dev/null)" ]; then
@@ -708,9 +702,9 @@ __run_start_script() {
message="Starting service: $name $args" message="Starting service: $name $args"
fi fi
if [ -n "$su_exec" ]; then if [ -n "$su_exec" ]; then
echo "using $su_exec" | tee -a -p "/data/logs/init.txt" __log_debug "Using $su_exec" | tee -a -p "/data/logs/init.txt"
fi fi
echo "$message" | tee -a -p "/data/logs/init.txt" __log_info "$message" | tee -a -p "/data/logs/init.txt"
su_cmd touch "$SERVICE_PID_FILE" su_cmd touch "$SERVICE_PID_FILE"
if [ "$RESET_ENV" = "yes" ]; then if [ "$RESET_ENV" = "yes" ]; then
env_command="$(echo "env -i HOME=\"$home\" LC_CTYPE=\"$lc_type\" PATH=\"$path\" HOSTNAME=\"$sysname\" USER=\"${SERVICE_USER:-$RUNAS_USER}\" $extra_env")" env_command="$(echo "env -i HOME=\"$home\" LC_CTYPE=\"$lc_type\" PATH=\"$path\" HOSTNAME=\"$sysname\" USER=\"${SERVICE_USER:-$RUNAS_USER}\" $extra_env")"
@@ -811,7 +805,7 @@ fi
# default exit code # default exit code
SERVICE_EXIT_CODE=0 SERVICE_EXIT_CODE=0
# application specific # application specific
EXEC_CMD_NAME="$(basename -- "$EXEC_CMD_BIN")" EXEC_CMD_NAME="${EXEC_CMD_BIN##*/}"
SERVICE_PID_FILE="/run/init.d/$EXEC_CMD_NAME.pid" SERVICE_PID_FILE="/run/init.d/$EXEC_CMD_NAME.pid"
SERVICE_PID_NUMBER="$(__pgrep "$EXEC_CMD_NAME" 2>/dev/null || echo '')" SERVICE_PID_NUMBER="$(__pgrep "$EXEC_CMD_NAME" 2>/dev/null || echo '')"
if type -P "$EXEC_CMD_BIN" &>/dev/null; then if type -P "$EXEC_CMD_BIN" &>/dev/null; then
@@ -1078,9 +1072,7 @@ __pre_execute
__fix_permissions "$SERVICE_USER" "$SERVICE_GROUP" __fix_permissions "$SERVICE_USER" "$SERVICE_GROUP"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# #
if ! __run_pre_execute_checks 2>/dev/stderr | tee -a -p "/data/logs/entrypoint.log" "/data/logs/init.txt"; then __run_pre_execute_checks 2>/dev/stderr | tee -a -p "/data/logs/entrypoint.log" "/data/logs/init.txt" || return 20
return 20
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
__run_start_script 2>>/dev/stderr | tee -p -a "/data/logs/entrypoint.log" __run_start_script 2>>/dev/stderr | tee -p -a "/data/logs/entrypoint.log"
errorCode=$? errorCode=$?

View File

@@ -1,14 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck shell=bash # shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202511301726-git ##@Version : 202602061352-git
# @@Author : Jason Hempstead # @@Author : Jason Hempstead
# @@Contact : jason@casjaysdev.pro # @@Contact : jason@casjaysdev.pro
# @@License : LICENSE.md # @@License : WTFPL
# @@ReadME : 99-nginx.sh --help # @@ReadME : start-service.sh --help
# @@Copyright : Copyright: (c) 2025 Jason Hempstead, Casjays Developments # @@Copyright : Copyright: (c) 2026 Jason Hempstead, Casjays Developments
# @@Created : Sunday, Nov 30, 2025 18:46 EST # @@Created : Tuesday, May 05, 2026 14:38 EDT
# @@File : 99-nginx.sh # @@File : start-service.sh
# @@Description : # @@Description :
# @@Changelog : New script # @@Changelog : New script
# @@TODO : Better documentation # @@TODO : Better documentation
@@ -26,28 +26,31 @@ set -e
trap '__trap_err_handler' ERR trap '__trap_err_handler' ERR
trap 'retVal=$?;if [ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ]; then rm -Rf "$SERVICE_PID_FILE"; fi;exit $retVal' SIGINT SIGTERM SIGPWR trap 'retVal=$?;if [ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ]; then rm -Rf "$SERVICE_PID_FILE"; fi;exit $retVal' SIGINT SIGTERM SIGPWR
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# ERR trap handler - only fail on critical errors # ERR trap handler - smart about critical vs non-critical errors
__trap_err_handler() { __trap_err_handler() {
local retVal=$? local retVal=$?
local line_number=$LINENO
local command="$BASH_COMMAND" local command="$BASH_COMMAND"
if [ $retVal -gt 0 ] && [ $retVal -ne 130 ] && [ $retVal -ne 141 ]; then # Ignore SIGPIPE and user interrupts
if [[ "$command" =~ (mkdir|touch|chmod|chown|ln|cp|mv|rm|echo|printf|cat|tee|sed|awk|grep) ]]; then [ $retVal -eq 130 ] || [ $retVal -eq 141 ] && return $retVal
echo "⚠️ Non-critical command failed (continuing): $command" >&2 # Non-critical: file operations, text processing, user/group operations
return 0 if [[ "$command" =~ (mkdir|touch|chmod|chown|chgrp|ln|cp|mv|rm|echo|printf|cat|tee|sed|awk|grep|find|sort|uniq|adduser|addgroup|usermod|groupmod|id|getent) ]]; then
else return 0
echo "❌ Fatal error occurred: Exit code $retVal at line $line_number in command: $command" >&2
if [ "$SERVICE_IS_RUNNING" != "yes" ]; then
kill -TERM 1 2>/dev/null || true
fi
fi
fi fi
return $retVal # Non-critical: conditional checks that might fail
if [[ "$command" =~ (test|\[|\[\[|kill -0|pgrep|pidof|ps) ]]; then
return 0
fi
# Critical error - but only fail if service hasn't started yet
if [ "$SERVICE_IS_RUNNING" != "yes" ]; then
echo "❌ Critical error (exit $retVal): $command" >&2
kill -TERM 1 2>/dev/null || exit $retVal
fi
return 0
} }
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
SCRIPT_FILE="$0" SCRIPT_FILE="$0"
SERVICE_NAME="nginx" SERVICE_NAME="nginx"
SCRIPT_NAME="$(basename -- "$SCRIPT_FILE" 2>/dev/null)" SCRIPT_NAME="${SCRIPT_FILE##*/}"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Function to exit appropriately based on context # Function to exit appropriately based on context
__script_exit() { __script_exit() {
@@ -70,18 +73,8 @@ if [ -n "$NGINX_APPNAME_ENABLED" ]; then
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html # setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
if [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ]; then [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
export DEBUGGER_OPTIONS="$(<"/config/.debug")" { [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; } && echo "Enabling debugging" && set -xo pipefail -x$DEBUGGER_OPTIONS && export DEBUGGER="on" || set -o pipefail
else
DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
fi
if [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; then
echo "Enabling debugging"
set -xo pipefail -x$DEBUGGER_OPTIONS
export DEBUGGER="on"
else
set -o pipefail
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
export PATH="/usr/local/etc/docker/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin" export PATH="/usr/local/etc/docker/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -98,7 +91,7 @@ for set_env in "/root/env.sh" "/usr/local/etc/docker/env"/*.sh "/config/env"/*.s
done done
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# exit if __start_init_scripts function hasn't been Initialized # exit if __start_init_scripts function hasn't been Initialized
if [ ! -f "/run/__start_init_scripts.pid" ]; then if [ ! -f "/run/.start_init_scripts.pid" ]; then
echo "__start_init_scripts function hasn't been Initialized" >&2 echo "__start_init_scripts function hasn't been Initialized" >&2
SERVICE_IS_RUNNING="no" SERVICE_IS_RUNNING="no"
__script_exit 1 __script_exit 1
@@ -176,7 +169,7 @@ EXEC_CMD_BIN='nginx'
EXEC_CMD_ARGS='-c $ETC_DIR/nginx.conf' EXEC_CMD_ARGS='-c $ETC_DIR/nginx.conf'
# execute script before # execute script before
EXEC_PRE_SCRIPT='' EXEC_PRE_SCRIPT=''
# Set to no if the service is not running otherwise leave blank # Set to 'no' for configuration services (no daemon process), leave blank for actual services
SERVICE_USES_PID='' SERVICE_USES_PID=''
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Is this service a web server # Is this service a web server
@@ -243,7 +236,7 @@ ADD_APPLICATION_FILES=""
ADD_APPLICATION_DIRS="" ADD_APPLICATION_DIRS=""
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
APPLICATION_FILES="$LOG_DIR/$SERVICE_NAME.log" APPLICATION_FILES="$LOG_DIR/$SERVICE_NAME.log"
APPLICATION_DIRS="$RUN_DIR $ETC_DIR $CONF_DIR $LOG_DIR $TMP_DIR" APPLICATION_DIRS="$ETC_DIR $CONF_DIR $DATA_DIR $LOG_DIR $TMP_DIR $RUN_DIR $VAR_DIR"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Additional config dirs - will be Copied to /etc/$name # Additional config dirs - will be Copied to /etc/$name
ADDITIONAL_CONFIG_DIRS="" ADDITIONAL_CONFIG_DIRS=""
@@ -517,30 +510,31 @@ __run_start_script() {
if [ -z "$cmd" ]; then if [ -z "$cmd" ]; then
__post_execute 2>"/dev/stderr" | tee -p -a "/data/logs/init.txt" __post_execute 2>"/dev/stderr" | tee -p -a "/data/logs/init.txt"
retVal=$? retVal=$?
echo "Initializing $SCRIPT_NAME has completed" __log_info "Initialization of $SCRIPT_NAME has completed"
__script_exit $retVal __script_exit $retVal
else else
# ensure the command exists # ensure the command exists
if [ ! -x "$cmd" ]; then if [ ! -x "$cmd" ]; then
echo "$name is not a valid executable" __log_error "$name is not a valid executable"
return 2 return 2
fi fi
# check and exit if already running # check and exit if already running (respects SERVICE_USES_PID in __proc_check)
if __proc_check "$name" || __proc_check "$cmd"; then if __proc_check "$name" || __proc_check "$cmd"; then
__log_debug "Service $name is already running"
return 0 return 0
else else
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# show message if env exists # show message if env exists
if [ -n "$cmd" ]; then if [ -n "$cmd" ]; then
if [ -n "$SERVICE_USER" ]; then if [ -n "$SERVICE_USER" ]; then
echo "Setting up $cmd to run as $SERVICE_USER" __log_info "Setting up $cmd to run as $SERVICE_USER"
else else
SERVICE_USER="root" SERVICE_USER="root"
fi fi
if [ -n "$SERVICE_PORT" ]; then if [ -n "$SERVICE_PORT" ]; then
echo "$name will be running on port $SERVICE_PORT" __log_info "$name will be running on port $SERVICE_PORT"
else else
SERVICE_PORT="" SERVICE_PORT="80"
fi fi
fi fi
if [ -n "$pre" ] && [ -n "$(command -v "$pre" 2>/dev/null)" ]; then if [ -n "$pre" ] && [ -n "$(command -v "$pre" 2>/dev/null)" ]; then
@@ -551,9 +545,9 @@ __run_start_script() {
message="Starting service: $name $args" message="Starting service: $name $args"
fi fi
if [ -n "$su_exec" ]; then if [ -n "$su_exec" ]; then
echo "using $su_exec" | tee -a -p "/data/logs/init.txt" __log_debug "Using $su_exec" | tee -a -p "/data/logs/init.txt"
fi fi
echo "$message" | tee -a -p "/data/logs/init.txt" __log_info "$message" | tee -a -p "/data/logs/init.txt"
su_cmd touch "$SERVICE_PID_FILE" su_cmd touch "$SERVICE_PID_FILE"
if [ "$RESET_ENV" = "yes" ]; then if [ "$RESET_ENV" = "yes" ]; then
env_command="$(echo "env -i HOME=\"$home\" LC_CTYPE=\"$lc_type\" PATH=\"$path\" HOSTNAME=\"$sysname\" USER=\"${SERVICE_USER:-$RUNAS_USER}\" $extra_env")" env_command="$(echo "env -i HOME=\"$home\" LC_CTYPE=\"$lc_type\" PATH=\"$path\" HOSTNAME=\"$sysname\" USER=\"${SERVICE_USER:-$RUNAS_USER}\" $extra_env")"
@@ -654,7 +648,7 @@ fi
# default exit code # default exit code
SERVICE_EXIT_CODE=0 SERVICE_EXIT_CODE=0
# application specific # application specific
EXEC_CMD_NAME="$(basename -- "$EXEC_CMD_BIN")" EXEC_CMD_NAME="${EXEC_CMD_BIN##*/}"
SERVICE_PID_FILE="/run/init.d/$EXEC_CMD_NAME.pid" SERVICE_PID_FILE="/run/init.d/$EXEC_CMD_NAME.pid"
SERVICE_PID_NUMBER="$(__pgrep "$EXEC_CMD_NAME" 2>/dev/null || echo '')" SERVICE_PID_NUMBER="$(__pgrep "$EXEC_CMD_NAME" 2>/dev/null || echo '')"
if type -P "$EXEC_CMD_BIN" &>/dev/null; then if type -P "$EXEC_CMD_BIN" &>/dev/null; then
@@ -921,9 +915,7 @@ __pre_execute
__fix_permissions "$SERVICE_USER" "$SERVICE_GROUP" __fix_permissions "$SERVICE_USER" "$SERVICE_GROUP"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# #
if ! __run_pre_execute_checks 2>/dev/stderr | tee -a -p "/data/logs/entrypoint.log" "/data/logs/init.txt"; then __run_pre_execute_checks 2>/dev/stderr | tee -a -p "/data/logs/entrypoint.log" "/data/logs/init.txt" || return 20
return 20
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
__run_start_script 2>>/dev/stderr | tee -p -a "/data/logs/entrypoint.log" __run_start_script 2>>/dev/stderr | tee -p -a "/data/logs/entrypoint.log"
errorCode=$? errorCode=$?

View File

@@ -1,14 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck shell=bash # shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202511301726-git ##@Version : 202602061352-git
# @@Author : Jason Hempstead # @@Author : Jason Hempstead
# @@Contact : jason@casjaysdev.pro # @@Contact : jason@casjaysdev.pro
# @@License : LICENSE.md # @@License : WTFPL
# @@ReadME : 03-php-fpm.sh --help # @@ReadME : start-service.sh --help
# @@Copyright : Copyright: (c) 2025 Jason Hempstead, Casjays Developments # @@Copyright : Copyright: (c) 2026 Jason Hempstead, Casjays Developments
# @@Created : Sunday, Nov 30, 2025 18:46 EST # @@Created : Tuesday, May 05, 2026 14:38 EDT
# @@File : 03-php-fpm.sh # @@File : start-service.sh
# @@Description : # @@Description :
# @@Changelog : New script # @@Changelog : New script
# @@TODO : Better documentation # @@TODO : Better documentation
@@ -26,28 +26,31 @@ set -e
trap '__trap_err_handler' ERR trap '__trap_err_handler' ERR
trap 'retVal=$?;if [ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ]; then rm -Rf "$SERVICE_PID_FILE"; fi;exit $retVal' SIGINT SIGTERM SIGPWR trap 'retVal=$?;if [ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ]; then rm -Rf "$SERVICE_PID_FILE"; fi;exit $retVal' SIGINT SIGTERM SIGPWR
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# ERR trap handler - only fail on critical errors # ERR trap handler - smart about critical vs non-critical errors
__trap_err_handler() { __trap_err_handler() {
local retVal=$? local retVal=$?
local line_number=$LINENO
local command="$BASH_COMMAND" local command="$BASH_COMMAND"
if [ $retVal -gt 0 ] && [ $retVal -ne 130 ] && [ $retVal -ne 141 ]; then # Ignore SIGPIPE and user interrupts
if [[ "$command" =~ (mkdir|touch|chmod|chown|ln|cp|mv|rm|echo|printf|cat|tee|sed|awk|grep) ]]; then [ $retVal -eq 130 ] || [ $retVal -eq 141 ] && return $retVal
echo "⚠️ Non-critical command failed (continuing): $command" >&2 # Non-critical: file operations, text processing, user/group operations
return 0 if [[ "$command" =~ (mkdir|touch|chmod|chown|chgrp|ln|cp|mv|rm|echo|printf|cat|tee|sed|awk|grep|find|sort|uniq|adduser|addgroup|usermod|groupmod|id|getent) ]]; then
else return 0
echo "❌ Fatal error occurred: Exit code $retVal at line $line_number in command: $command" >&2
if [ "$SERVICE_IS_RUNNING" != "yes" ]; then
kill -TERM 1 2>/dev/null || true
fi
fi
fi fi
return $retVal # Non-critical: conditional checks that might fail
if [[ "$command" =~ (test|\[|\[\[|kill -0|pgrep|pidof|ps) ]]; then
return 0
fi
# Critical error - but only fail if service hasn't started yet
if [ "$SERVICE_IS_RUNNING" != "yes" ]; then
echo "❌ Critical error (exit $retVal): $command" >&2
kill -TERM 1 2>/dev/null || exit $retVal
fi
return 0
} }
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
SCRIPT_FILE="$0" SCRIPT_FILE="$0"
SERVICE_NAME="php-fpm" SERVICE_NAME="php-fpm"
SCRIPT_NAME="$(basename -- "$SCRIPT_FILE" 2>/dev/null)" SCRIPT_NAME="${SCRIPT_FILE##*/}"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Function to exit appropriately based on context # Function to exit appropriately based on context
__script_exit() { __script_exit() {
@@ -70,18 +73,8 @@ if [ -n "$PHP_FPM_APPNAME_ENABLED" ]; then
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html # setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
if [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ]; then [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
export DEBUGGER_OPTIONS="$(<"/config/.debug")" { [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; } && echo "Enabling debugging" && set -xo pipefail -x$DEBUGGER_OPTIONS && export DEBUGGER="on" || set -o pipefail
else
DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
fi
if [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; then
echo "Enabling debugging"
set -xo pipefail -x$DEBUGGER_OPTIONS
export DEBUGGER="on"
else
set -o pipefail
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
export PATH="/usr/local/etc/docker/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin" export PATH="/usr/local/etc/docker/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -98,7 +91,7 @@ for set_env in "/root/env.sh" "/usr/local/etc/docker/env"/*.sh "/config/env"/*.s
done done
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# exit if __start_init_scripts function hasn't been Initialized # exit if __start_init_scripts function hasn't been Initialized
if [ ! -f "/run/__start_init_scripts.pid" ]; then if [ ! -f "/run/.start_init_scripts.pid" ]; then
echo "__start_init_scripts function hasn't been Initialized" >&2 echo "__start_init_scripts function hasn't been Initialized" >&2
SERVICE_IS_RUNNING="no" SERVICE_IS_RUNNING="no"
__script_exit 1 __script_exit 1
@@ -176,7 +169,7 @@ EXEC_CMD_BIN='php-fpm'
EXEC_CMD_ARGS='--allow-to-run-as-root --fpm-config $ETC_DIR/php-fpm.conf' EXEC_CMD_ARGS='--allow-to-run-as-root --fpm-config $ETC_DIR/php-fpm.conf'
# execute script before # execute script before
EXEC_PRE_SCRIPT='' EXEC_PRE_SCRIPT=''
# Set to no if the service is not running otherwise leave blank # Set to 'no' for configuration services (no daemon process), leave blank for actual services
SERVICE_USES_PID='' SERVICE_USES_PID=''
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Is this service a web server # Is this service a web server
@@ -243,7 +236,7 @@ ADD_APPLICATION_FILES=""
ADD_APPLICATION_DIRS="" ADD_APPLICATION_DIRS=""
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
APPLICATION_FILES="$LOG_DIR/$SERVICE_NAME.log" APPLICATION_FILES="$LOG_DIR/$SERVICE_NAME.log"
APPLICATION_DIRS="$RUN_DIR $ETC_DIR $CONF_DIR $LOG_DIR $TMP_DIR" APPLICATION_DIRS="$ETC_DIR $CONF_DIR $DATA_DIR $LOG_DIR $TMP_DIR $RUN_DIR $VAR_DIR"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# Additional config dirs - will be Copied to /etc/$name # Additional config dirs - will be Copied to /etc/$name
ADDITIONAL_CONFIG_DIRS="" ADDITIONAL_CONFIG_DIRS=""
@@ -517,30 +510,31 @@ __run_start_script() {
if [ -z "$cmd" ]; then if [ -z "$cmd" ]; then
__post_execute 2>"/dev/stderr" | tee -p -a "/data/logs/init.txt" __post_execute 2>"/dev/stderr" | tee -p -a "/data/logs/init.txt"
retVal=$? retVal=$?
echo "Initializing $SCRIPT_NAME has completed" __log_info "Initialization of $SCRIPT_NAME has completed"
__script_exit $retVal __script_exit $retVal
else else
# ensure the command exists # ensure the command exists
if [ ! -x "$cmd" ]; then if [ ! -x "$cmd" ]; then
echo "$name is not a valid executable" __log_error "$name is not a valid executable"
return 2 return 2
fi fi
# check and exit if already running # check and exit if already running (respects SERVICE_USES_PID in __proc_check)
if __proc_check "$name" || __proc_check "$cmd"; then if __proc_check "$name" || __proc_check "$cmd"; then
__log_debug "Service $name is already running"
return 0 return 0
else else
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# show message if env exists # show message if env exists
if [ -n "$cmd" ]; then if [ -n "$cmd" ]; then
if [ -n "$SERVICE_USER" ]; then if [ -n "$SERVICE_USER" ]; then
echo "Setting up $cmd to run as $SERVICE_USER" __log_info "Setting up $cmd to run as $SERVICE_USER"
else else
SERVICE_USER="root" SERVICE_USER="root"
fi fi
if [ -n "$SERVICE_PORT" ]; then if [ -n "$SERVICE_PORT" ]; then
echo "$name will be running on port $SERVICE_PORT" __log_info "$name will be running on port $SERVICE_PORT"
else else
SERVICE_PORT="" SERVICE_PORT="9000"
fi fi
fi fi
if [ -n "$pre" ] && [ -n "$(command -v "$pre" 2>/dev/null)" ]; then if [ -n "$pre" ] && [ -n "$(command -v "$pre" 2>/dev/null)" ]; then
@@ -551,9 +545,9 @@ __run_start_script() {
message="Starting service: $name $args" message="Starting service: $name $args"
fi fi
if [ -n "$su_exec" ]; then if [ -n "$su_exec" ]; then
echo "using $su_exec" | tee -a -p "/data/logs/init.txt" __log_debug "Using $su_exec" | tee -a -p "/data/logs/init.txt"
fi fi
echo "$message" | tee -a -p "/data/logs/init.txt" __log_info "$message" | tee -a -p "/data/logs/init.txt"
su_cmd touch "$SERVICE_PID_FILE" su_cmd touch "$SERVICE_PID_FILE"
if [ "$RESET_ENV" = "yes" ]; then if [ "$RESET_ENV" = "yes" ]; then
env_command="$(echo "env -i HOME=\"$home\" LC_CTYPE=\"$lc_type\" PATH=\"$path\" HOSTNAME=\"$sysname\" USER=\"${SERVICE_USER:-$RUNAS_USER}\" $extra_env")" env_command="$(echo "env -i HOME=\"$home\" LC_CTYPE=\"$lc_type\" PATH=\"$path\" HOSTNAME=\"$sysname\" USER=\"${SERVICE_USER:-$RUNAS_USER}\" $extra_env")"
@@ -654,7 +648,7 @@ fi
# default exit code # default exit code
SERVICE_EXIT_CODE=0 SERVICE_EXIT_CODE=0
# application specific # application specific
EXEC_CMD_NAME="$(basename -- "$EXEC_CMD_BIN")" EXEC_CMD_NAME="${EXEC_CMD_BIN##*/}"
SERVICE_PID_FILE="/run/init.d/$EXEC_CMD_NAME.pid" SERVICE_PID_FILE="/run/init.d/$EXEC_CMD_NAME.pid"
SERVICE_PID_NUMBER="$(__pgrep "$EXEC_CMD_NAME" 2>/dev/null || echo '')" SERVICE_PID_NUMBER="$(__pgrep "$EXEC_CMD_NAME" 2>/dev/null || echo '')"
if type -P "$EXEC_CMD_BIN" &>/dev/null; then if type -P "$EXEC_CMD_BIN" &>/dev/null; then
@@ -921,9 +915,7 @@ __pre_execute
__fix_permissions "$SERVICE_USER" "$SERVICE_GROUP" __fix_permissions "$SERVICE_USER" "$SERVICE_GROUP"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# #
if ! __run_pre_execute_checks 2>/dev/stderr | tee -a -p "/data/logs/entrypoint.log" "/data/logs/init.txt"; then __run_pre_execute_checks 2>/dev/stderr | tee -a -p "/data/logs/entrypoint.log" "/data/logs/init.txt" || return 20
return 20
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
__run_start_script 2>>/dev/stderr | tee -p -a "/data/logs/entrypoint.log" __run_start_script 2>>/dev/stderr | tee -p -a "/data/logs/entrypoint.log"
errorCode=$? errorCode=$?

View File

@@ -113,10 +113,10 @@ DATABASE_DIR_COUCHDB="${DATABASE_DIR_COUCHDB:-$DATABASE_BASE_DIR/couchdb}"
DATABASE_DIR_SUPABASE="${DATABASE_DIR_SUPABASE:-$DATABASE_BASE_DIR/supabase}" DATABASE_DIR_SUPABASE="${DATABASE_DIR_SUPABASE:-$DATABASE_BASE_DIR/supabase}"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# docker env # docker env
DOCKER_HOST="unix://var/run/docker.sock" DOCKER_HOST="unix:///run/docker.sock"
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# File locations # File locations
ENTRYPOINT_PID_FILE="${ENTRYPOINT_PID_FILE:-/run/init.d/entrypoint.pid}" ENTRYPOINT_PID_FILE="${ENTRYPOINT_PID_FILE:-/run/.entrypoint.pid}"
ENTRYPOINT_INIT_FILE="${ENTRYPOINT_INIT_FILE:-/config/.entrypoint.done}" ENTRYPOINT_INIT_FILE="${ENTRYPOINT_INIT_FILE:-/config/.entrypoint.done}"
ENTRYPOINT_DATA_INIT_FILE="${ENTRYPOINT_DATA_INIT_FILE:-/data/.docker_has_run}" ENTRYPOINT_DATA_INIT_FILE="${ENTRYPOINT_DATA_INIT_FILE:-/data/.docker_has_run}"
ENTRYPOINT_CONFIG_INIT_FILE="${ENTRYPOINT_CONFIG_INIT_FILE:-/config/.docker_has_run}" ENTRYPOINT_CONFIG_INIT_FILE="${ENTRYPOINT_CONFIG_INIT_FILE:-/config/.docker_has_run}"

View File

@@ -1,6 +1,6 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
# File locations # File locations
ENTRYPOINT_PID_FILE="${ENTRYPOINT_PID_FILE:-/run/init.d/entrypoint.pid}" ENTRYPOINT_PID_FILE="${ENTRYPOINT_PID_FILE:-/run/.entrypoint.pid}"
ENTRYPOINT_INIT_FILE="${ENTRYPOINT_INIT_FILE:-/config/.entrypoint.done}" ENTRYPOINT_INIT_FILE="${ENTRYPOINT_INIT_FILE:-/config/.entrypoint.done}"
ENTRYPOINT_DATA_INIT_FILE="${ENTRYPOINT_DATA_INIT_FILE:-/data/.docker_has_run}" ENTRYPOINT_DATA_INIT_FILE="${ENTRYPOINT_DATA_INIT_FILE:-/data/.docker_has_run}"
ENTRYPOINT_CONFIG_INIT_FILE="${ENTRYPOINT_CONFIG_INIT_FILE:-/config/.docker_has_run}" ENTRYPOINT_CONFIG_INIT_FILE="${ENTRYPOINT_CONFIG_INIT_FILE:-/config/.docker_has_run}"