mirror of
				https://github.com/casjaysdevdocker/bind
				synced 2025-11-04 07:02:23 -05:00 
			
		
		
		
	🗃️ Committing everything that changed 🗃️
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				release-tag / release-image (push) Failing after 12h7m42s
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	release-tag / release-image (push) Failing after 12h7m42s
				
			Dockerfile .env.scripts .gitattributes .gitignore rootfs/.gitea/ rootfs/usr/local/bin/entrypoint.sh rootfs/usr/local/bin/pkmgr rootfs/usr/local/etc/docker/functions/entrypoint.sh rootfs/usr/local/share/template-files/config/env/default.sample
This commit is contained in:
		
							
								
								
									
										10
									
								
								.env.scripts
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								.env.scripts
									
									
									
									
									
								
							@@ -1,10 +1,10 @@
 | 
				
			|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
##@Version           :  202408270947-git
 | 
					##@Version           :  202509161146-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 2025 CasjaysDev
 | 
				
			||||||
# @@Created          :  Tue Aug 27 09:47:41 AM EDT 2024
 | 
					# @@Created          :  Tue Sep 16 11:46:25 AM EDT 2025
 | 
				
			||||||
# @@File             :  .env.scripts
 | 
					# @@File             :  .env.scripts
 | 
				
			||||||
# @@Description      :  Variables for gen-dockerfile and buildx scripts
 | 
					# @@Description      :  Variables for gen-dockerfile and buildx scripts
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
@@ -34,6 +34,8 @@ ENV_IMAGE_PUSH="casjaysdevdocker/bind"
 | 
				
			|||||||
ENV_IMAGE_TAG="latest"
 | 
					ENV_IMAGE_TAG="latest"
 | 
				
			||||||
ENV_ADD_TAGS=""
 | 
					ENV_ADD_TAGS=""
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
 | 
					ENV_ADD_IMAGE_PUSH=""
 | 
				
			||||||
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# Pull image info
 | 
					# Pull image info
 | 
				
			||||||
ENV_PULL_URL="casjaysdev/alpine"
 | 
					ENV_PULL_URL="casjaysdev/alpine"
 | 
				
			||||||
ENV_DISTRO_TAG="${IMAGE_VERSION}"
 | 
					ENV_DISTRO_TAG="${IMAGE_VERSION}"
 | 
				
			||||||
@@ -54,5 +56,5 @@ 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 \php82-fpm tor"
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							@@ -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 Thu Sep  4 10:41:50 PM EDT 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
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										7
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
# gitignore created on 08/27/24 at 09:03
 | 
					# gitignore created on 09/16/25 at 11:46
 | 
				
			||||||
# Disable reminder in prompt
 | 
					# Disable reminder in prompt
 | 
				
			||||||
ignoredirmessage
 | 
					ignoredirmessage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -96,3 +96,8 @@ $RECYCLE.BIN/
 | 
				
			|||||||
# ignore .installed files
 | 
					# ignore .installed files
 | 
				
			||||||
**/.installed
 | 
					**/.installed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# ignore work in progress files
 | 
				
			||||||
 | 
					**/*.rewrite.sh
 | 
				
			||||||
 | 
					**/*.refactor.sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										41
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								Dockerfile
									
									
									
									
									
								
							@@ -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="202509161146"
 | 
				
			||||||
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 \php82-fpm tor "
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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}"
 | 
				
			||||||
@@ -68,6 +70,10 @@ WORKDIR /root
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
COPY ./rootfs/usr/local/bin/. /usr/local/bin/
 | 
					COPY ./rootfs/usr/local/bin/. /usr/local/bin/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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
 | 
					  true
 | 
				
			||||||
@@ -86,7 +92,6 @@ 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"; \
 | 
					  [ -f "/root/.profile" ] || touch "/root/.profile"; \
 | 
				
			||||||
  mkdir -p "${DEFAULT_DATA_DIR}" "${DEFAULT_CONF_DIR}" "${DEFAULT_TEMPLATE_DIR}" "/root/docker/setup" "/etc/profile.d"; \
 | 
					 | 
				
			||||||
  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 ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -118,13 +123,12 @@ RUN echo "Updating system files "; \
 | 
				
			|||||||
  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=""; \
 | 
				
			||||||
  if [ -n "$pip_bin" ];then $pip_bin -m pip install --break-system-packages certbot-dns-rfc2136 certbot-dns-duckdns certbot-dns-cloudflare certbot-nginx $pip_opts || true;fi; \
 | 
					 | 
				
			||||||
  [ -f "/usr/share/zoneinfo/${TZ}" ] && ln -sf "/usr/share/zoneinfo/${TZ}" "/etc/localtime" || true; \
 | 
					  [ -f "/usr/share/zoneinfo/${TZ}" ] && ln -sf "/usr/share/zoneinfo/${TZ}" "/etc/localtime" || true; \
 | 
				
			||||||
  [ -n "$PHP_BIN" ] && [ -z "$(command -v php 2>/dev/null)" ] && ln -sf "$PHP_BIN" "/usr/bin/php" 2>/dev/null || true; \
 | 
					  [ -n "$PHP_BIN" ] && [ -z "$(command -v php 2>/dev/null)" ] && ln -sf "$PHP_BIN" "/usr/bin/php" 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; \
 | 
					  [ -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 +136,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 +153,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; \
 | 
				
			||||||
@@ -179,6 +183,7 @@ RUN echo "Deleting unneeded files"; \
 | 
				
			|||||||
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
 | 
				
			||||||
@@ -208,24 +213,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="docker.io"
 | 
				
			||||||
LABEL org.opencontainers.image.url.source="https://hub.docker.com/r/casjaysdevdocker/bind"
 | 
					LABEL org.opencontainers.image.source="docker.io"
 | 
				
			||||||
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="${BUILD_VERSION}"
 | 
				
			||||||
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 +252,5 @@ VOLUME [ "/config","/data" ]
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
EXPOSE ${SERVICE_PORT} ${ENV_PORTS}
 | 
					EXPOSE ${SERVICE_PORT} ${ENV_PORTS}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CMD [ "tail", "-f", "/dev/null" ]
 | 
					ENTRYPOINT [ "tini","--","/usr/local/bin/entrypoint.sh" "start" ]
 | 
				
			||||||
ENTRYPOINT [ "tini","--","/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" ]
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										51
									
								
								rootfs/.gitea/workflows/docker.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								rootfs/.gitea/workflows/docker.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,51 @@
 | 
				
			|||||||
 | 
					name: bind
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					on: push
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					jobs:
 | 
				
			||||||
 | 
					  release-bind:
 | 
				
			||||||
 | 
					    runs-on: act_runner
 | 
				
			||||||
 | 
					    container:
 | 
				
			||||||
 | 
					      image: catthehacker/ubuntu:act-latest
 | 
				
			||||||
 | 
					    env:
 | 
				
			||||||
 | 
					      RUNNER_TOOL_CACHE: /toolcache
 | 
				
			||||||
 | 
					    steps:
 | 
				
			||||||
 | 
					      - name: Checkout
 | 
				
			||||||
 | 
					        uses: actions/checkout@v3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      - name: Set up QEMU
 | 
				
			||||||
 | 
					        uses: docker/setup-qemu-action@v2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      - name: Get Meta
 | 
				
			||||||
 | 
					        id: meta
 | 
				
			||||||
 | 
					        run: |
 | 
				
			||||||
 | 
					          echo DATE_TAG=$(date +'%y%m') >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					          echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					          echo DOCKER_ORG=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $1}') >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					          echo DOCKER_TAG=$([ -n "$DOCKER_TAG" ] && echo ${DOCKER_TAG} || echo "latest") >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					          echo DOCKER_HUB=$([ -n "$DOCKER_HUB" ] && echo ${DOCKER_HUB} || echo "docker.io") >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					          echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}' | sed 's|^docker-||g') >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					          echo "$DOCKER_HUB/$DOCKER_ORG/$REPO_NAME:$DOCKER_TAG"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      - name: Set up Docker BuildX
 | 
				
			||||||
 | 
					        uses: docker/setup-buildx-action@v2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      - name: Login to DockerHub
 | 
				
			||||||
 | 
					        uses: docker/login-action@v2
 | 
				
			||||||
 | 
					        with:
 | 
				
			||||||
 | 
					          password: ${{ secrets.DOCKER_TOKEN }}
 | 
				
			||||||
 | 
					          username: ${{ secrets.DOCKER_USERNAME }}
 | 
				
			||||||
 | 
					          registry: ${{ steps.meta.outputs.DOCKER_HUB }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      - name: Build and push
 | 
				
			||||||
 | 
					        uses: docker/build-push-action@v4
 | 
				
			||||||
 | 
					        with:
 | 
				
			||||||
 | 
					          context: .
 | 
				
			||||||
 | 
					          file: ./Dockerfile
 | 
				
			||||||
 | 
					          platforms: |
 | 
				
			||||||
 | 
					            linux/amd64
 | 
				
			||||||
 | 
					            linux/arm64
 | 
				
			||||||
 | 
					          push: true
 | 
				
			||||||
 | 
					          tags: | # replace it with your local IP and 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.DOCKER_TAG }}
 | 
				
			||||||
@@ -1,29 +1,30 @@
 | 
				
			|||||||
#!/usr/bin/env bash
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
# shellcheck shell=bash
 | 
					# shellcheck shell=bash
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
##@Version           :  202408270903-git
 | 
					##@Version           :  202509161146-git
 | 
				
			||||||
# @@Author           :  Jason Hempstead
 | 
					# @@Author           :  Jason Hempstead
 | 
				
			||||||
# @@Contact          :  jason@casjaysdev.pro
 | 
					# @@Contact          :  jason@casjaysdev.pro
 | 
				
			||||||
# @@License          :  WTFPL
 | 
					# @@License          :  LICENSE.md
 | 
				
			||||||
# @@ReadME           :  entrypoint.sh --help
 | 
					# @@ReadME           :  entrypoint.sh --help
 | 
				
			||||||
# @@Copyright        :  Copyright: (c) 2024 Jason Hempstead, Casjays Developments
 | 
					# @@Copyright        :  Copyright: (c) 2025 Jason Hempstead, Casjays Developments
 | 
				
			||||||
# @@Created          :  Tuesday, Aug 27, 2024 09:03 EDT
 | 
					# @@Created          :  Tuesday, Sep 16, 2025 11:46 EDT
 | 
				
			||||||
# @@File             :  entrypoint.sh
 | 
					# @@File             :  entrypoint.sh
 | 
				
			||||||
# @@Description      :  Entrypoint file for bind
 | 
					# @@Description      :  Entrypoint file for bind
 | 
				
			||||||
# @@Changelog        :  New script
 | 
					# @@Changelog        :  New script
 | 
				
			||||||
# @@TODO             :  Better documentation
 | 
					# @@TODO             :  Better documentation
 | 
				
			||||||
# @@Other            :
 | 
					# @@Other            :  
 | 
				
			||||||
# @@Resource         :
 | 
					# @@Resource         :  
 | 
				
			||||||
# @@Terminal App     :  no
 | 
					# @@Terminal App     :  no
 | 
				
			||||||
# @@sudo/root        :  no
 | 
					# @@sudo/root        :  no
 | 
				
			||||||
# @@Template         :  other/docker-entrypoint
 | 
					# @@Template         :  other/docker-entrypoint
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# shellcheck disable=SC2016
 | 
					# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2120,SC2155,SC2199,SC2317,SC2329
 | 
				
			||||||
# shellcheck disable=SC2031
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# shellcheck disable=SC2120
 | 
					set -e
 | 
				
			||||||
# shellcheck disable=SC2155
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# shellcheck disable=SC2199
 | 
					# run trap command on exit
 | 
				
			||||||
# shellcheck disable=SC2317
 | 
					trap 'echo "❌ Fatal error, killing container"; kill -TERM 1' ERR
 | 
				
			||||||
 | 
					trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' SIGINT SIGTERM SIGPWR
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# 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
 | 
				
			||||||
[ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
 | 
					[ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
 | 
				
			||||||
@@ -34,7 +35,7 @@ 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="$(basename -- "$SCRIPT_FILE" 2>/dev/null)"
 | 
				
			||||||
CONTAINER_NAME="${ENV_CONTAINER_NAME:-$CONTAINER_NAME}"
 | 
					CONTAINER_NAME="${ENV_CONTAINER_NAME:-$CONTAINER_NAME}"
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# remove whitespaces from beginning argument
 | 
					# remove whitespaces from beginning argument
 | 
				
			||||||
@@ -56,7 +57,7 @@ case "$1" in
 | 
				
			|||||||
-h | --help)
 | 
					-h | --help)
 | 
				
			||||||
  shift 1
 | 
					  shift 1
 | 
				
			||||||
  echo 'Docker container for '$CONTAINER_NAME''
 | 
					  echo 'Docker container for '$CONTAINER_NAME''
 | 
				
			||||||
  echo "Usage: $CONTAINER_NAME [cron exec start init shell certbot ssl procs ports healthcheck backup command]"
 | 
					  echo "Usage: $CONTAINER_NAME [help tail cron exec start init shell certbot ssl procs ports healthcheck backup command]"
 | 
				
			||||||
  echo ""
 | 
					  echo ""
 | 
				
			||||||
  exit 0
 | 
					  exit 0
 | 
				
			||||||
  ;;
 | 
					  ;;
 | 
				
			||||||
@@ -77,24 +78,28 @@ unset set_env
 | 
				
			|||||||
# User to use to launch service - IE: postgres
 | 
					# User to use to launch service - IE: postgres
 | 
				
			||||||
RUNAS_USER="root" # normally root
 | 
					RUNAS_USER="root" # normally root
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# User and group in which the service switches to - IE: nginx,apache,mysql,postgres
 | 
					# Set user and group from env
 | 
				
			||||||
SERVICE_USER="named"  # execute command as another user
 | 
					SERVICE_USER="${PUID:-$SERVICE_USER}"
 | 
				
			||||||
SERVICE_GROUP="named" # Set the service group
 | 
					SERVICE_GROUP="${PGID:-$SERVICE_GROUP}"
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# Set user and group ID
 | 
					# Set user and group ID
 | 
				
			||||||
SERVICE_UID="0" # set the user id
 | 
					SERVICE_UID="${SERVICE_UID:-0}" # set the user id
 | 
				
			||||||
SERVICE_GID="0" # set the group id
 | 
					SERVICE_GID="${SERVICE_GID:-0}" # set the group id
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# Primary server port- will be added to server ports
 | 
					# User and group in which the service switches to - IE: nginx,apache,mysql,postgres
 | 
				
			||||||
WEB_SERVER_PORT="" # port : 80,443
 | 
					SERVICE_USER="${SERVICE_USER:-$bind}"  # execute command as another user
 | 
				
			||||||
 | 
					SERVICE_GROUP="${SERVICE_GROUP:-bind}" # Set the service group
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# Secondary ports
 | 
					# Secondary ports
 | 
				
			||||||
SERVER_PORTS="" # specifiy other ports
 | 
					SERVER_PORTS="" # specifiy other ports
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
 | 
					# Primary server port- will be added to server ports
 | 
				
			||||||
 | 
					WEB_SERVER_PORT="" # port : 80,443
 | 
				
			||||||
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# Healthcheck variables
 | 
					# Healthcheck variables
 | 
				
			||||||
HEALTH_ENABLED="yes"                     # enable healthcheck [yes/no]
 | 
					HEALTH_ENABLED="yes" # enable healthcheck [yes/no]
 | 
				
			||||||
SERVICES_LIST="tini,tor,named,php-fpm,nginx"
 | 
					SERVICES_LIST="tini" # comma seperated list of processes for the healthcheck
 | 
				
			||||||
HEALTH_ENDPOINTS=""                      # url endpoints: [http://localhost/health,http://localhost/test]
 | 
					HEALTH_ENDPOINTS=""  # url endpoints: [http://localhost/health,http://localhost/test]
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# Update path var
 | 
					# Update path var
 | 
				
			||||||
export PATH RUNAS_USER SERVICE_USER SERVICE_GROUP SERVICE_UID SERVICE_GID WWW_ROOT_DIR DATABASE_DIR
 | 
					export PATH RUNAS_USER SERVICE_USER SERVICE_GROUP SERVICE_UID SERVICE_GID WWW_ROOT_DIR DATABASE_DIR
 | 
				
			||||||
@@ -109,11 +114,15 @@ __run_message() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
################## END OF CONFIGURATION #####################
 | 
					################## END OF CONFIGURATION #####################
 | 
				
			||||||
 | 
					# Lets get containers ip address
 | 
				
			||||||
 | 
					IP4_ADDRESS="$(__get_ip4)"
 | 
				
			||||||
 | 
					IP6_ADDRESS="$(__get_ip6)"
 | 
				
			||||||
 | 
					CONTAINER_IP4_ADDRESS="${CONTAINER_IP4_ADDRESS:-$IP4_ADDRESS}"
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# Startup variables
 | 
					# Startup variables
 | 
				
			||||||
export INIT_DATE="${INIT_DATE:-$(date)}"
 | 
					export INIT_DATE="${INIT_DATE:-$(date)}"
 | 
				
			||||||
export CONTAINER_INIT="${CONTAINER_INIT:-no}"
 | 
					export CONTAINER_INIT="${CONTAINER_INIT:-no}"
 | 
				
			||||||
export START_SERVICES="${START_SERVICES:-yes}"
 | 
					export START_SERVICES="${START_SERVICES:-no}"
 | 
				
			||||||
export ENTRYPOINT_MESSAGE="${ENTRYPOINT_MESSAGE:-yes}"
 | 
					export ENTRYPOINT_MESSAGE="${ENTRYPOINT_MESSAGE:-yes}"
 | 
				
			||||||
export ENTRYPOINT_FIRST_RUN="${ENTRYPOINT_FIRST_RUN:-yes}"
 | 
					export ENTRYPOINT_FIRST_RUN="${ENTRYPOINT_FIRST_RUN:-yes}"
 | 
				
			||||||
export DATA_DIR_INITIALIZED="${DATA_DIR_INITIALIZED:-no}"
 | 
					export DATA_DIR_INITIALIZED="${DATA_DIR_INITIALIZED:-no}"
 | 
				
			||||||
@@ -124,19 +133,24 @@ export CONTAINER_NAME="${ENV_CONTAINER_NAME:-$CONTAINER_NAME}"
 | 
				
			|||||||
export LANG="${LANG:-C.UTF-8}"
 | 
					export LANG="${LANG:-C.UTF-8}"
 | 
				
			||||||
export LC_ALL="${LANG:-C.UTF-8}"
 | 
					export LC_ALL="${LANG:-C.UTF-8}"
 | 
				
			||||||
export TZ="${TZ:-${TIMEZONE:-America/New_York}}"
 | 
					export TZ="${TZ:-${TIMEZONE:-America/New_York}}"
 | 
				
			||||||
export HOSTNAME="${FULL_DOMAIN_NAME:-${SERVER_HOSTNAME:-$HOSTNAME}}"
 | 
					export HOSTNAME="$(hostname -s)"
 | 
				
			||||||
 | 
					export DOMAINNAME="$(hostname -d)"
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# Default directories
 | 
					# Default directories
 | 
				
			||||||
export SSL_DIR="${SSL_DIR:-/config/ssl}"
 | 
					export SSL_DIR="${SSL_DIR:-/config/ssl}"
 | 
				
			||||||
export SSL_CA="${SSL_CERT:-/config/ssl/ca.crt}"
 | 
					export SSL_CA="${SSL_CERT:-/config/ssl/ca.crt}"
 | 
				
			||||||
export SSL_KEY="${SSL_KEY:-/config/ssl/localhost.pem}"
 | 
					export SSL_KEY="${SSL_KEY:-/config/ssl/localhost.pem}"
 | 
				
			||||||
export SSL_CERT="${SSL_CERT:-/config/ssl/localhost.crt}"
 | 
					export SSL_CERT="${SSL_CERT:-/config/ssl/localhost.crt}"
 | 
				
			||||||
export BACKUP_DIR="${BACKUP_DIR:-/data/backups}"
 | 
					 | 
				
			||||||
export LOCAL_BIN_DIR="${LOCAL_BIN_DIR:-/usr/local/bin}"
 | 
					export LOCAL_BIN_DIR="${LOCAL_BIN_DIR:-/usr/local/bin}"
 | 
				
			||||||
export DEFAULT_DATA_DIR="${DEFAULT_DATA_DIR:-/usr/local/share/template-files/data}"
 | 
					export DEFAULT_DATA_DIR="${DEFAULT_DATA_DIR:-/usr/local/share/template-files/data}"
 | 
				
			||||||
export DEFAULT_CONF_DIR="${DEFAULT_CONF_DIR:-/usr/local/share/template-files/config}"
 | 
					export DEFAULT_CONF_DIR="${DEFAULT_CONF_DIR:-/usr/local/share/template-files/config}"
 | 
				
			||||||
export DEFAULT_TEMPLATE_DIR="${DEFAULT_TEMPLATE_DIR:-/usr/local/share/template-files/defaults}"
 | 
					export DEFAULT_TEMPLATE_DIR="${DEFAULT_TEMPLATE_DIR:-/usr/local/share/template-files/defaults}"
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
 | 
					# Backup settings
 | 
				
			||||||
 | 
					export BACKUP_MAX_DAYS="${BACKUP_MAX_DAYS:-}"
 | 
				
			||||||
 | 
					export BACKUP_RUN_CRON="${BACKUP_RUN_CRON:-}"
 | 
				
			||||||
 | 
					export BACKUP_DIR="${BACKUP_DIR:-/data/backups}"
 | 
				
			||||||
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# Additional
 | 
					# Additional
 | 
				
			||||||
export PHP_INI_DIR="${PHP_INI_DIR:-$(__find_php_ini)}"
 | 
					export PHP_INI_DIR="${PHP_INI_DIR:-$(__find_php_ini)}"
 | 
				
			||||||
export PHP_BIN_DIR="${PHP_BIN_DIR:-$(__find_php_bin)}"
 | 
					export PHP_BIN_DIR="${PHP_BIN_DIR:-$(__find_php_bin)}"
 | 
				
			||||||
@@ -150,10 +164,21 @@ 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}"
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
 | 
					if [ -n "$CONTAINER_WEB_SERVER_WWW_REPO" ]; then
 | 
				
			||||||
 | 
					  www_temp_dir="/tmp/git/$(basename -- "$CONTAINER_WEB_SERVER_WWW_REPO")"
 | 
				
			||||||
 | 
					  rm -Rf "${WWW_ROOT_DIR:?}"/* "${www_temp_dir:?}"/*
 | 
				
			||||||
 | 
					  mkdir -p "$WWW_ROOT_DIR" "$www_temp_dir"
 | 
				
			||||||
 | 
					  git clone -q "$CONTAINER_WEB_SERVER_WWW_REPO" "$www_temp_dir" 2>/dev/null
 | 
				
			||||||
 | 
					  rm -Rf "$www_temp_dir/.git" "$www_temp_dir"/.git*
 | 
				
			||||||
 | 
					  rsync -ra "$www_temp_dir/" "$WWW_ROOT_DIR" --delete >/dev/null 2>&1
 | 
				
			||||||
 | 
					  rm -Rf "$www_temp_dir"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# variables based on env/files
 | 
					# variables based on env/files
 | 
				
			||||||
[ -f "/config/enable/ssl" ] && SSL_ENABLED="yes"
 | 
					[ -f "/config/enable/ssl" ] && SSL_ENABLED="yes"
 | 
				
			||||||
[ -f "/config/enable/ssh" ] && SSH_ENABLED="yes"
 | 
					[ -f "/config/enable/ssh" ] && SSH_ENABLED="yes"
 | 
				
			||||||
[ "$WEB_SERVER_PORT" = "443" ] && SSL_ENABLED="yes"
 | 
					[ "$WEB_SERVER_PORT" = "443" ] && SSL_ENABLED="yes"
 | 
				
			||||||
 | 
					[ "$CONTAINER_WEB_SERVER_PROTOCOL" = "https" ] && SSL_ENABLED="yes"
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# export variables
 | 
					# export variables
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -181,7 +206,7 @@ ENV_PORTS="$(__format_variables "$ENV_PORTS" || false)"
 | 
				
			|||||||
WEB_SERVER_PORTS="$(__format_variables "$WEB_SERVER_PORTS" || false)"
 | 
					WEB_SERVER_PORTS="$(__format_variables "$WEB_SERVER_PORTS" || false)"
 | 
				
			||||||
ENV_PORTS="$(__format_variables "$SERVER_PORTS" "$WEB_SERVER_PORTS" "$ENV_PORTS" "$SERVER_PORTS" || false)"
 | 
					ENV_PORTS="$(__format_variables "$SERVER_PORTS" "$WEB_SERVER_PORTS" "$ENV_PORTS" "$SERVER_PORTS" || false)"
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
#
 | 
					# Remove the commas from env
 | 
				
			||||||
HEALTH_ENDPOINTS="${HEALTH_ENDPOINTS//,/ }"
 | 
					HEALTH_ENDPOINTS="${HEALTH_ENDPOINTS//,/ }"
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# create required directories
 | 
					# create required directories
 | 
				
			||||||
@@ -234,6 +259,8 @@ if [ -f "$ENTRYPOINT_PID_FILE" ]; then
 | 
				
			|||||||
  touch "$ENTRYPOINT_PID_FILE"
 | 
					  touch "$ENTRYPOINT_PID_FILE"
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
  echo "$$" >"$ENTRYPOINT_PID_FILE"
 | 
					  echo "$$" >"$ENTRYPOINT_PID_FILE"
 | 
				
			||||||
 | 
					  # Clean any stale PID files on first run
 | 
				
			||||||
 | 
					  rm -f /run/init.d/*.pid 2>/dev/null || true
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
if [ -f "$ENTRYPOINT_INIT_FILE" ]; then
 | 
					if [ -f "$ENTRYPOINT_INIT_FILE" ]; then
 | 
				
			||||||
  ENTRYPOINT_MESSAGE="no" ENTRYPOINT_FIRST_RUN="no"
 | 
					  ENTRYPOINT_MESSAGE="no" ENTRYPOINT_FIRST_RUN="no"
 | 
				
			||||||
@@ -246,9 +273,9 @@ if [ "$ENTRYPOINT_FIRST_RUN" != "no" ]; then
 | 
				
			|||||||
  fi
 | 
					  fi
 | 
				
			||||||
  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
  # Set reusable variables
 | 
					  # Set reusable variables
 | 
				
			||||||
  { { [ -w "/etc" ] && [ ! -e "/etc/hosts" ]; } || [ -w "/etc/hosts" ]; } && UPDATE_FILE_HOSTS="yes"
 | 
					  { { [ -w "/etc" ] && [ ! -f "/etc/hosts" ]; } || [ -w "/etc/hosts" ]; } && UPDATE_FILE_HOSTS="yes" && touch "/etc/hosts"
 | 
				
			||||||
  { { [ -w "/etc" ] && [ ! -e "/etc/timezone" ]; } || [ -w "/etc/timezone" ]; } && UPDATE_FILE_TZ="yes"
 | 
					  { { [ -w "/etc" ] && [ ! -f "/etc/timezone" ]; } || [ -w "/etc/timezone" ]; } && UPDATE_FILE_TZ="yes" && touch "/etc/timezone"
 | 
				
			||||||
  { { [ -w "/etc" ] && [ ! -e "/etc/resolv.conf" ]; } || [ -w "/etc/resolv.conf" ]; } && UPDATE_FILE_RESOLV="yes"
 | 
					  { { [ -w "/etc" ] && [ ! -f "/etc/resolv.conf" ]; } || [ -w "/etc/resolv.conf" ]; } && UPDATE_FILE_RESOLV="yes" && touch "/etc/resolv.conf"
 | 
				
			||||||
  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
  # Set timezone
 | 
					  # Set timezone
 | 
				
			||||||
  [ -n "$TZ" ] && [ "$UPDATE_FILE_TZ" = "yes" ] && echo "$TZ" >"/etc/timezone"
 | 
					  [ -n "$TZ" ] && [ "$UPDATE_FILE_TZ" = "yes" ] && echo "$TZ" >"/etc/timezone"
 | 
				
			||||||
@@ -265,23 +292,20 @@ if [ "$ENTRYPOINT_FIRST_RUN" != "no" ]; then
 | 
				
			|||||||
    fi
 | 
					    fi
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
  # add .home domain
 | 
					  # add .internal domain
 | 
				
			||||||
  if [ "$UPDATE_FILE_HOSTS" = "yes" ] && [ -n "$HOSTNAME" ]; then
 | 
					  if [ "$UPDATE_FILE_HOSTS" = "yes" ] && [ -n "$HOSTNAME" ]; then
 | 
				
			||||||
    __grep_test " $HOSTNAME" "/etc/hosts" || __printf_space "40" "${CONTAINER_IP4_ADDRESS:-127.0.0.1}" "$HOSTNAME" >>"/etc/hosts"
 | 
					    __grep_test " $HOSTNAME" "/etc/hosts" || __printf_space "40" "${CONTAINER_IP4_ADDRESS:-127.0.0.1}" "$HOSTNAME" >>"/etc/hosts"
 | 
				
			||||||
    __grep_test " ${HOSTNAME%%.*}.home" "/etc/hosts" || __printf_space "40" "${CONTAINER_IP4_ADDRESS:-127.0.0.1}" "${HOSTNAME%%.*}.home" >>"/etc/hosts"
 | 
					    __grep_test " ${HOSTNAME%%.*}.internal" "/etc/hosts" || __printf_space "40" "${CONTAINER_IP4_ADDRESS:-127.0.0.1}" "${HOSTNAME%%.*}.internal" >>"/etc/hosts"
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
  # add domainname
 | 
					  # add domainname
 | 
				
			||||||
  if [ "$UPDATE_FILE_HOSTS" = "yes" ] && [ "$DOMAINNAME" != "home" ] && [ -n "$DOMAINNAME" ] && [ "$HOSTNAME.$DOMAINNAME" != "$DOMAINNAME" ]; then
 | 
					  if [ "$UPDATE_FILE_HOSTS" = "yes" ] && [ "$DOMAINNAME" != "internal" ] && [ -n "$DOMAINNAME" ] && [ "$HOSTNAME.$DOMAINNAME" != "$DOMAINNAME" ]; then
 | 
				
			||||||
    __grep_test " ${HOSTNAME%%.*}.$DOMAINNAME" "/etc/hosts" || __printf_space "40" "${CONTAINER_IP4_ADDRESS:-127.0.0.1}" "${HOSTNAME%%.*}.$DOMAINNAME" >>"/etc/hosts"
 | 
					    __grep_test " ${HOSTNAME%%.*}.$DOMAINNAME" "/etc/hosts" || __printf_space "40" "${CONTAINER_IP4_ADDRESS:-127.0.0.1}" "${HOSTNAME%%.*}.$DOMAINNAME" >>"/etc/hosts"
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
  # Set containers hostname
 | 
					  # Set containers hostname
 | 
				
			||||||
  [ -n "$HOSTNAME" ] && [ "$UPDATE_FILE_HOSTS" = "yes" ] && echo "$HOSTNAME" >"/etc/hostname"
 | 
					  [ -n "$HOSTNAME" ] && [ "$UPDATE_FILE_HOSTS" = "yes" ] && echo "$HOSTNAME" >"/etc/hostname"
 | 
				
			||||||
  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
  # Set containers hostname with domain
 | 
					 | 
				
			||||||
  # [ -n "$DOMAINNAME" ] && [ "$UPDATE_FILE_HOSTS" = "yes" ] && echo "$HOSTNAME.$DOMAINNAME" >"/etc/hostname"
 | 
					 | 
				
			||||||
  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					 | 
				
			||||||
  if [ -f "/etc/hostname" ]; then
 | 
					  if [ -f "/etc/hostname" ]; then
 | 
				
			||||||
    [ -n "$(type -P hostname)" ] && hostname -F "/etc/hostname" &>/dev/null || HOSTNAME="$(<"/etc/hostname")"
 | 
					    [ -n "$(type -P hostname)" ] && hostname -F "/etc/hostname" &>/dev/null || HOSTNAME="$(<"/etc/hostname")"
 | 
				
			||||||
    export HOSTNAME
 | 
					    export HOSTNAME
 | 
				
			||||||
@@ -293,8 +317,8 @@ if [ "$ENTRYPOINT_FIRST_RUN" != "no" ]; then
 | 
				
			|||||||
  # import resolv.conf file into container
 | 
					  # import resolv.conf file into container
 | 
				
			||||||
  [ "$CUSTOM_DNS" != "yes" ] && [ -f "/usr/local/etc/resolv.conf" ] && [ "$UPDATE_FILE_RESOLV" = "yes" ] && cat "/usr/local/etc/resolv.conf" >"/etc/resolv.conf"
 | 
					  [ "$CUSTOM_DNS" != "yes" ] && [ -f "/usr/local/etc/resolv.conf" ] && [ "$UPDATE_FILE_RESOLV" = "yes" ] && cat "/usr/local/etc/resolv.conf" >"/etc/resolv.conf"
 | 
				
			||||||
  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
  if [ -d "/usr/local/etc/skel" ]; then
 | 
					  if [ -n "$HOME" ] && [ -d "/usr/local/etc/skel" ]; then
 | 
				
			||||||
    cp -Rf "/usr/local/etc/skel/." "$HOME/"
 | 
					    [ -d "$HOME" ] && cp -Rf "/usr/local/etc/skel/." "$HOME/"
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
@@ -320,20 +344,26 @@ __initialize_ssl_certs
 | 
				
			|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
if [ -f "$ENTRYPOINT_INIT_FILE" ]; then
 | 
					if [ -f "$ENTRYPOINT_INIT_FILE" ]; then
 | 
				
			||||||
  ENTRYPOINT_FIRST_RUN="no"
 | 
					  ENTRYPOINT_FIRST_RUN="no"
 | 
				
			||||||
elif [ -d "/config" ]; then
 | 
					fi
 | 
				
			||||||
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
 | 
					if [ -d "/config" ]; then
 | 
				
			||||||
  echo "Initialized on: $INIT_DATE" >"$ENTRYPOINT_INIT_FILE"
 | 
					  echo "Initialized on: $INIT_DATE" >"$ENTRYPOINT_INIT_FILE"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# Check if this is a new container
 | 
					# Check if this is a new container
 | 
				
			||||||
if [ -f "$ENTRYPOINT_DATA_INIT_FILE" ]; then
 | 
					if [ -f "$ENTRYPOINT_DATA_INIT_FILE" ]; then
 | 
				
			||||||
  DATA_DIR_INITIALIZED="yes"
 | 
					  DATA_DIR_INITIALIZED="yes"
 | 
				
			||||||
elif [ -d "/data" ]; then
 | 
					fi
 | 
				
			||||||
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
 | 
					if [ -d "/data" ]; then
 | 
				
			||||||
  echo "Initialized on: $INIT_DATE" >"$ENTRYPOINT_DATA_INIT_FILE"
 | 
					  echo "Initialized on: $INIT_DATE" >"$ENTRYPOINT_DATA_INIT_FILE"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
if [ -f "$ENTRYPOINT_CONFIG_INIT_FILE" ]; then
 | 
					if [ -f "$ENTRYPOINT_CONFIG_INIT_FILE" ]; then
 | 
				
			||||||
  CONFIG_DIR_INITIALIZED="yes"
 | 
					  CONFIG_DIR_INITIALIZED="yes"
 | 
				
			||||||
elif [ -d "/config" ]; then
 | 
					fi
 | 
				
			||||||
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
 | 
					if [ -d "/config" ]; then
 | 
				
			||||||
  echo "Initialized on: $INIT_DATE" >"$ENTRYPOINT_CONFIG_INIT_FILE"
 | 
					  echo "Initialized on: $INIT_DATE" >"$ENTRYPOINT_CONFIG_INIT_FILE"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
@@ -343,12 +373,12 @@ if [ "$ENTRYPOINT_FIRST_RUN" != "no" ]; then
 | 
				
			|||||||
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="yes"
 | 
					  START_SERVICES="yes"
 | 
				
			||||||
  # Clean stale pid files from previous container runs
 | 
					  # Clean stale pid files from previous container runs
 | 
				
			||||||
  rm -f /run/__start_init_scripts.pid /run/init.d/*.pid /run/*.pid
 | 
					  rm -f /run/__start_init_scripts.pid /run/init.d/*.pid /run/*.pid 2>/dev/null || true
 | 
				
			||||||
elif [ ! -f "/run/__start_init_scripts.pid" ]; then
 | 
					elif [ ! -f "/run/__start_init_scripts.pid" ]; then
 | 
				
			||||||
  START_SERVICES="yes" 
 | 
					  START_SERVICES="yes"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
[ "$ENTRYPOINT_MESSAGE" = "yes" ] && __printf_space "40" "Container ip address is:" "$CONTAINER_IP4_ADDRESS"
 | 
					[ "$ENTRYPOINT_MESSAGE" = "yes" ] && __printf_space "40" "Container ip address is:" "$CONTAINER_IP4_ADDRESS"
 | 
				
			||||||
@@ -377,11 +407,12 @@ __run_message
 | 
				
			|||||||
START_SERVICES="${START_SERVICES:-SYSTEM_INIT}"
 | 
					START_SERVICES="${START_SERVICES:-SYSTEM_INIT}"
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# Start all services if no pidfile
 | 
					# Start all services if no pidfile
 | 
				
			||||||
if [ "$START_SERVICES" = "yes" ] && [ "$1" != "backup" ] && [ "$1" != "healthcheck" ]; then
 | 
					if [ "$START_SERVICES" = "yes" ] && [ "$1" != "backup" ] && [ "$1" != "healthcheck" ] && [ "$1" != "cron" ] && [ "$1" != "tail" ] && [ "$1" != "logs" ] && [ "$1" != "cron" ]; then
 | 
				
			||||||
  [ "$1" = "start" ] && shift 1
 | 
					  [ "$1" = "start" ] && shift 1
 | 
				
			||||||
  [ "$1" = "all" ] && shift 1
 | 
					  [ "$1" = "all" ] && shift 1
 | 
				
			||||||
  [ "$1" = "init" ] && export CONTAINER_INIT="yes"
 | 
					  [ "$1" = "init" ] && export CONTAINER_INIT="yes"
 | 
				
			||||||
  echo "$$" >"$ENTRYPOINT_PID_FILE"
 | 
					  echo "$$" >"$ENTRYPOINT_PID_FILE"
 | 
				
			||||||
 | 
					  rm -Rf "/run"/*/*pid
 | 
				
			||||||
  __start_init_scripts "/usr/local/etc/docker/init.d"
 | 
					  __start_init_scripts "/usr/local/etc/docker/init.d"
 | 
				
			||||||
  START_SERVICES="no"
 | 
					  START_SERVICES="no"
 | 
				
			||||||
  CONTAINER_INIT="${CONTAINER_INIT:-no}"
 | 
					  CONTAINER_INIT="${CONTAINER_INIT:-no}"
 | 
				
			||||||
@@ -394,6 +425,25 @@ init)
 | 
				
			|||||||
  echo "Container has been Initialized"
 | 
					  echo "Container has been Initialized"
 | 
				
			||||||
  exit 0
 | 
					  exit 0
 | 
				
			||||||
  ;;
 | 
					  ;;
 | 
				
			||||||
 | 
					tail)
 | 
				
			||||||
 | 
					  shift 1
 | 
				
			||||||
 | 
					  case "$1" in
 | 
				
			||||||
 | 
					  null)
 | 
				
			||||||
 | 
					    shift $#
 | 
				
			||||||
 | 
					    tail -F "/dev/null"
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					  app)
 | 
				
			||||||
 | 
					    shift $#
 | 
				
			||||||
 | 
					    tail -F /data/logs/*/*.log
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					  -*)
 | 
				
			||||||
 | 
					    tail "$@"
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					  *)
 | 
				
			||||||
 | 
					    tail -F "${@:-/dev/null}"
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					  esac
 | 
				
			||||||
 | 
					  ;;
 | 
				
			||||||
logs)
 | 
					logs)
 | 
				
			||||||
  shift 1
 | 
					  shift 1
 | 
				
			||||||
  case "$1" in
 | 
					  case "$1" in
 | 
				
			||||||
@@ -422,29 +472,28 @@ cron)
 | 
				
			|||||||
# backup data and config dirs
 | 
					# backup data and config dirs
 | 
				
			||||||
backup)
 | 
					backup)
 | 
				
			||||||
  shift 1
 | 
					  shift 1
 | 
				
			||||||
  save="${1:-$BACKUP_DIR}"
 | 
					  __backup $BACKUP_MAX_DAYS $1
 | 
				
			||||||
  backupExit=0
 | 
					  exit $?
 | 
				
			||||||
  date="$(date '+%Y%m%d-%H%M')"
 | 
					 | 
				
			||||||
  file="$save/$date.tar.gz"
 | 
					 | 
				
			||||||
  echo "Backing up /data /config to $file"
 | 
					 | 
				
			||||||
  sleep 1
 | 
					 | 
				
			||||||
  tar cfvz "$file" --exclude="$save" "/data" "/config" || false
 | 
					 | 
				
			||||||
  backupExit=$?
 | 
					 | 
				
			||||||
  [ $backupExit -eq 0 ] && echo "Backed up /data /config has finished" || echo "Backup of /data /config has failed"
 | 
					 | 
				
			||||||
  exit $backupExit
 | 
					 | 
				
			||||||
  ;;
 | 
					  ;;
 | 
				
			||||||
# Docker healthcheck
 | 
					# Docker healthcheck
 | 
				
			||||||
healthcheck)
 | 
					healthcheck)
 | 
				
			||||||
  shift
 | 
					  arguments="$*"
 | 
				
			||||||
  healthStatus=0
 | 
					  healthStatus=0
 | 
				
			||||||
  services="${SERVICES_LIST:-$@}"
 | 
					 | 
				
			||||||
  healthEnabled="${HEALTH_ENABLED:-}"
 | 
					  healthEnabled="${HEALTH_ENABLED:-}"
 | 
				
			||||||
  healthPorts="${WEB_SERVER_PORTS:-}"
 | 
					  healthPorts="${WEB_SERVER_PORTS:-}"
 | 
				
			||||||
  healthEndPoints="${HEALTH_ENDPOINTS:-}"
 | 
					  healthEndPoints="${HEALTH_ENDPOINTS:-}"
 | 
				
			||||||
 | 
					  SERVICES_LIST="${arguments:-$SERVICES_LIST}"
 | 
				
			||||||
 | 
					  services="$(echo "${SERVICES_LIST//,/ }")"
 | 
				
			||||||
  healthMessage="Everything seems to be running"
 | 
					  healthMessage="Everything seems to be running"
 | 
				
			||||||
  services="${services//,/ }"
 | 
					 | 
				
			||||||
  { [ "$1" = "init" ] || [ "$1" = "test" ]; } && exit 0
 | 
					 | 
				
			||||||
  [ "$healthEnabled" = "yes" ] || exit 0
 | 
					  [ "$healthEnabled" = "yes" ] || exit 0
 | 
				
			||||||
 | 
					  if [ -d "/run/healthcheck" ] && [ "$(ls -A "/run/healthcheck" | wc -l)" -ne 0 ]; then
 | 
				
			||||||
 | 
					    for service in /run/healthcheck/*; do
 | 
				
			||||||
 | 
					      name=$(basename -- $service)
 | 
				
			||||||
 | 
					      services+="$name "
 | 
				
			||||||
 | 
					    done
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					  services="$(echo "$services" | tr ' ' '\n' | sort -u | grep -v '^$')"
 | 
				
			||||||
 | 
					  { [ "$1" = "init" ] || [ "$1" = "test" ]; } && exit 0
 | 
				
			||||||
  for proc in $services; do
 | 
					  for proc in $services; do
 | 
				
			||||||
    if [ -n "$proc" ]; then
 | 
					    if [ -n "$proc" ]; then
 | 
				
			||||||
      if ! __pgrep "$proc"; then
 | 
					      if ! __pgrep "$proc"; then
 | 
				
			||||||
@@ -537,7 +586,6 @@ start)
 | 
				
			|||||||
    elif [ -f "/usr/local/etc/docker/init.d/$1" ]; then
 | 
					    elif [ -f "/usr/local/etc/docker/init.d/$1" ]; then
 | 
				
			||||||
      eval "/usr/local/etc/docker/init.d/$1" &
 | 
					      eval "/usr/local/etc/docker/init.d/$1" &
 | 
				
			||||||
      __no_exit
 | 
					      __no_exit
 | 
				
			||||||
 | 
					 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  ;;
 | 
					  ;;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,17 +1,10 @@
 | 
				
			|||||||
#!/usr/bin/env bash
 | 
					#!/usr/bin/env sh
 | 
				
			||||||
# shellcheck shell=bash
 | 
					# shellcheck shell=sh
 | 
				
			||||||
# shellcheck disable=SC2016
 | 
					# shellcheck disable=SC2016
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
[ -n "$_DEBUG" ] && _DEBUG_OPTIONS="-x"
 | 
					 | 
				
			||||||
[ "$1" = "--debug" ] && _DEBUG_OPTIONS="-x" && shift 1
 | 
					 | 
				
			||||||
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
 | 
					 | 
				
			||||||
set -e $_DEBUG_OPTIONS
 | 
					 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					 | 
				
			||||||
USER_UID="$(id -u)"
 | 
					USER_UID="$(id -u)"
 | 
				
			||||||
USER_GID="$(id -g)"
 | 
					USER_GID="$(id -g)"
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
[ -f "/etc/pkmgr/options.conf" ] && . "/etc/pkmgr/options.conf"
 | 
					 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					 | 
				
			||||||
if [ -x "$(command -v apt 2>/dev/null)" ]; then
 | 
					if [ -x "$(command -v apt 2>/dev/null)" ]; then
 | 
				
			||||||
  export DEBIAN_FRONTEND=noninteractive
 | 
					  export DEBIAN_FRONTEND=noninteractive
 | 
				
			||||||
  pkmgr_cmd="apt"
 | 
					  pkmgr_cmd="apt"
 | 
				
			||||||
@@ -19,6 +12,7 @@ if [ -x "$(command -v apt 2>/dev/null)" ]; then
 | 
				
			|||||||
  pkmgr_mkcache_cmd="$pkmgr_cmd update"
 | 
					  pkmgr_mkcache_cmd="$pkmgr_cmd update"
 | 
				
			||||||
  pkmgr_update_cmd="$pkmgr_cmd upgrade -yy"
 | 
					  pkmgr_update_cmd="$pkmgr_cmd upgrade -yy"
 | 
				
			||||||
  pkmgr_install_cmd="$pkmgr_cmd install -yy $PKMGR_OPTS"
 | 
					  pkmgr_install_cmd="$pkmgr_cmd install -yy $PKMGR_OPTS"
 | 
				
			||||||
 | 
					  pkmgr_install_post="$pkmgr_cmd --fix-broken install"
 | 
				
			||||||
elif [ -x "$(command -v apt-get 2>/dev/null)" ]; then
 | 
					elif [ -x "$(command -v apt-get 2>/dev/null)" ]; then
 | 
				
			||||||
  export DEBIAN_FRONTEND=noninteractive
 | 
					  export DEBIAN_FRONTEND=noninteractive
 | 
				
			||||||
  pkmgr_cmd="apt-get"
 | 
					  pkmgr_cmd="apt-get"
 | 
				
			||||||
@@ -26,6 +20,7 @@ elif [ -x "$(command -v apt-get 2>/dev/null)" ]; then
 | 
				
			|||||||
  pkmgr_mkcache_cmd="$pkmgr_cmd update"
 | 
					  pkmgr_mkcache_cmd="$pkmgr_cmd update"
 | 
				
			||||||
  pkmgr_update_cmd="$pkmgr_cmd upgrade -yy"
 | 
					  pkmgr_update_cmd="$pkmgr_cmd upgrade -yy"
 | 
				
			||||||
  pkmgr_install_cmd="$pkmgr_cmd install -yy $PKMGR_OPTS"
 | 
					  pkmgr_install_cmd="$pkmgr_cmd install -yy $PKMGR_OPTS"
 | 
				
			||||||
 | 
					  pkmgr_install_post="$pkmgr_cmd --fix-broken install"
 | 
				
			||||||
elif [ -x "$(command -v dnf 2>/dev/null)" ]; then
 | 
					elif [ -x "$(command -v dnf 2>/dev/null)" ]; then
 | 
				
			||||||
  pkmgr_cmd="dnf"
 | 
					  pkmgr_cmd="dnf"
 | 
				
			||||||
  pkmgr_clean_cmd="$pkmgr_cmd clean all"
 | 
					  pkmgr_clean_cmd="$pkmgr_cmd clean all"
 | 
				
			||||||
@@ -90,13 +85,34 @@ pip)
 | 
				
			|||||||
  case "$1" in
 | 
					  case "$1" in
 | 
				
			||||||
  install)
 | 
					  install)
 | 
				
			||||||
    shift 1
 | 
					    shift 1
 | 
				
			||||||
    $pip_bin -m $pip_opts "$@"
 | 
					    pkg_list="$*"
 | 
				
			||||||
 | 
					    for pkg in $pkg_list; do
 | 
				
			||||||
 | 
					      $pip_bin -m pip $pip_opts "$pkg"
 | 
				
			||||||
 | 
					    done
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
  *)
 | 
					  *)
 | 
				
			||||||
    $pip_bin "$@"
 | 
					    for pkg in "$@"; do
 | 
				
			||||||
 | 
					      $pip_bin -m pip "$pkg"
 | 
				
			||||||
 | 
					    done
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
  esac
 | 
					  esac
 | 
				
			||||||
  exit $?
 | 
					  exit
 | 
				
			||||||
 | 
					  ;;
 | 
				
			||||||
 | 
					install)
 | 
				
			||||||
 | 
					  shift 1
 | 
				
			||||||
 | 
					  [ -n "$1" ] || exit 0
 | 
				
			||||||
 | 
					  [ "$USER_UID" -eq 0 ] || [ "$USER" = "root" ] || pkmgr_install_cmd="sudo $pkmgr_install_cmd"
 | 
				
			||||||
 | 
					  if [ -f "$1" ]; then
 | 
				
			||||||
 | 
					    install_list="$(cat "$1")"
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    install_list="$*"
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					  for pkg in $install_list;do
 | 
				
			||||||
 | 
					    echo "installing packages command: $pkmgr_install_cmd $pkg"
 | 
				
			||||||
 | 
					    $pkmgr_install_cmd $pkg
 | 
				
			||||||
 | 
					    if [ -n "$pkmgr_install_post" ]; then eval $pkmgr_install_post; fi
 | 
				
			||||||
 | 
					  done
 | 
				
			||||||
 | 
					  exit
 | 
				
			||||||
  ;;
 | 
					  ;;
 | 
				
			||||||
update | upgrade)
 | 
					update | upgrade)
 | 
				
			||||||
  shift $#
 | 
					  shift $#
 | 
				
			||||||
@@ -114,20 +130,6 @@ clean)
 | 
				
			|||||||
  $pkmgr_clean_cmd
 | 
					  $pkmgr_clean_cmd
 | 
				
			||||||
  exit $?
 | 
					  exit $?
 | 
				
			||||||
  ;;
 | 
					  ;;
 | 
				
			||||||
install)
 | 
					 | 
				
			||||||
  shift 1
 | 
					 | 
				
			||||||
  [ -n "$1" ] || exit 0
 | 
					 | 
				
			||||||
  [ "$USER_UID" -eq 0 ] || [ "$USER" = "root" ] || pkmgr_install_cmd="sudo $pkmgr_install_cmd"
 | 
					 | 
				
			||||||
  if [ -f "$1" ]; then
 | 
					 | 
				
			||||||
    install_list="$(cat "$1")"
 | 
					 | 
				
			||||||
    echo 'installing packages from file with command: '$pkmgr_install_cmd' "$(<"$1")"'
 | 
					 | 
				
			||||||
  else
 | 
					 | 
				
			||||||
    install_list="$*"
 | 
					 | 
				
			||||||
    echo "installing packages command: $pkmgr_install_cmd $install_list"
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
  $pkmgr_install_cmd $install_list
 | 
					 | 
				
			||||||
  exit $?
 | 
					 | 
				
			||||||
  ;;
 | 
					 | 
				
			||||||
*)
 | 
					*)
 | 
				
			||||||
  [ -n "$1" ] || exit 0
 | 
					  [ -n "$1" ] || exit 0
 | 
				
			||||||
  [ "$USER_UID" -eq 0 ] || [ "$USER" = "root" ] || pkmgr_cmd="sudo $pkmgr_cmd"
 | 
					  [ "$USER_UID" -eq 0 ] || [ "$USER" = "root" ] || pkmgr_cmd="sudo $pkmgr_cmd"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,7 +18,7 @@
 | 
				
			|||||||
# @@sudo/root        :  no
 | 
					# @@sudo/root        :  no
 | 
				
			||||||
# @@Template         :  functions/docker-entrypoint
 | 
					# @@Template         :  functions/docker-entrypoint
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# shellcheck disable=SC1003,SC2016,SC2031,SC2120,SC2155,SC2199,SC2317
 | 
					# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2120,SC2155,SC2199,SC2317,SC2329
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# 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
 | 
				
			||||||
[ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
 | 
					[ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
 | 
				
			||||||
@@ -39,138 +39,75 @@ __printf_space() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
__rm() { [ -n "$1" ] && [ -e "$1" ] && rm -Rf "${1:?}"; }
 | 
					__rm() { [ -n "$1" ] && [ -e "$1" ] && rm -Rf "${1:?}"; }
 | 
				
			||||||
__grep_test() { grep -ash "$1" "$2" | grep -aqwF "${3:-$1}" || return 1; }
 | 
					__grep_test() { grep -sh "$1" "$2" | grep -qwF "${3:-$1}" || return 1; }
 | 
				
			||||||
__netstat() { [ -f "$(type -P netstat)" ] && netstat "$@" || return 10; }
 | 
					__netstat() { [ -f "$(type -P netstat)" ] && netstat "$@" || return 10; }
 | 
				
			||||||
__cd() { { [ -d "$1" ] || mkdir -p "$1"; } && builtin cd "$1" || return 1; }
 | 
					__cd() { { [ -d "$1" ] || mkdir -p "$1"; } && builtin cd "$1" || return 1; }
 | 
				
			||||||
__is_in_file() { [ -e "$2" ] && grep -Rsaq "$1" "$2" && return 0 || return 1; }
 | 
					__is_in_file() { [ -e "$2" ] && grep -Rsq "$1" "$2" && return 0 || return 1; }
 | 
				
			||||||
__curl() { curl -q -sfI --max-time 3 -k -o /dev/null "$@" &>/dev/null || return 10; }
 | 
					__curl() { curl -q -sfI --max-time 3 -k -o /dev/null "$@" &>/dev/null || return 10; }
 | 
				
			||||||
__find() { find "$1" -mindepth 1 -type ${2:-f,d} 2>/dev/null | grep -a '^' || return 10; }
 | 
					__find() { find "$1" -mindepth 1 -type ${2:-f,d} 2>/dev/null | grep '.' || return 10; }
 | 
				
			||||||
__pcheck() { [ -n "$(which pgrep 2>/dev/null)" ] && pgrep -o "$1$" &>/dev/null || return 10; }
 | 
					__pcheck() { [ -n "$(which pgrep 2>/dev/null)" ] && pgrep -o "$1$" &>/dev/null || return 10; }
 | 
				
			||||||
__file_exists_with_content() { [ -n "$1" ] && [ -f "$1" ] && [ -s "$1" ] && return 0 || return 2; }
 | 
					__file_exists_with_content() { [ -n "$1" ] && [ -f "$1" ] && [ -s "$1" ] && return 0 || return 2; }
 | 
				
			||||||
__sed() { sed -i 's|'$1'|'$2'|g' "$3" &>/dev/null || sed -i "s|$1|$2|g" "$3" &>/dev/null || return 1; }
 | 
					__sed() { sed -i 's|'$1'|'$2'|g' "$3" &>/dev/null || sed -i "s|$1|$2|g" "$3" &>/dev/null || return 1; }
 | 
				
			||||||
__pgrep() { __pcheck "${1:-SERVICE_NAME}" || __ps "${1:-$SERVICE_NAME}" | grep -aqv ' grep' || return 10; }
 | 
					__pgrep() { __pcheck "${1:-SERVICE_NAME}" || __ps "${1:-$SERVICE_NAME}" | grep -qv ' grep' || return 10; }
 | 
				
			||||||
__ps() { [ -f "$(type -P ps)" ] && ps "$@" 2>/dev/null | sed 's|:||g' | grep -aFw " ${1:-$SERVICE_NAME}$" || return 10; }
 | 
					__ps() { [ -f "$(type -P ps)" ] && ps "$@" 2>/dev/null | sed 's|:||g' | grep -Fw " ${1:-$SERVICE_NAME}$" || return 10; }
 | 
				
			||||||
__is_dir_empty() { if [ -n "$1" ]; then [ "$(ls -A "$1" 2>/dev/null | wc -l)" -eq 0 ] && return 0 || return 1; else return 1; fi; }
 | 
					__is_dir_empty() { if [ -n "$1" ]; then [ "$(ls -A "$1" 2>/dev/null | wc -l)" -eq 0 ] && return 0 || return 1; else return 1; fi; }
 | 
				
			||||||
__get_ip6() { ip a 2>/dev/null | grep -aw 'inet6' | awk '{print $2}' | grep -avE '^::1|^fe' | sed 's|/.*||g' | head -n1 | grep -a '^' || echo ''; }
 | 
					__get_ip6() { ip a 2>/dev/null | grep -w 'inet6' | awk '{print $2}' | grep -vE '^::1|^fe' | sed 's|/.*||g' | head -n1 | grep '.' || echo ''; }
 | 
				
			||||||
__get_ip4() { ip a 2>/dev/null | grep -aw 'inet' | awk '{print $2}' | grep -avE '^127.0.0' | sed 's|/.*||g' | head -n1 | grep -a '^' || echo '127.0.0.1'; }
 | 
					__get_ip4() { ip a 2>/dev/null | grep -w 'inet' | awk '{print $2}' | grep -vE '^127.0.0' | sed 's|/.*||g' | head -n1 | grep '.' || echo '127.0.0.1'; }
 | 
				
			||||||
__find_file_relative() { find "$1"/* -not -path '*env/*' -not -path '.git*' -type f 2>/dev/null | sed 's|'$1'/||g' | sort -u | grep -av '^$' | grep -a '^' || false; }
 | 
					__find_file_relative() { find "$1"/* -not -path '*env/*' -not -path '.git*' -type f 2>/dev/null | sed 's|'$1'/||g' | sort -u | grep -v '^$' | grep '.' || false; }
 | 
				
			||||||
__find_directory_relative() { find "$1"/* -not -path '*env/*' -not -path '.git*' -type d 2>/dev/null | sed 's|'$1'/||g' | sort -u | grep -av '^$' | grep -a '^' || false; }
 | 
					__find_directory_relative() { find "$1"/* -not -path '*env/*' -not -path '.git*' -type d 2>/dev/null | sed 's|'$1'/||g' | sort -u | grep -v '^$' | grep '.' || false; }
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
__pid_exists() { ps -ax --no-header | sed 's/^[[:space:]]*//g' | awk -F' ' '{print $1}' | sed 's|:||g' | grep -a '[0-9]' | sort -uV | grep -a "^$1$" && return 0 || return 1; }
 | 
					__pid_exists() { ps -ax --no-header | sed 's/^[[:space:]]*//g' | awk -F' ' '{print $1}' | sed 's|:||g' | grep '[0-9]' | sort -uV | grep "^$1$" && return 0 || return 1; }
 | 
				
			||||||
__is_running() { ps -eo args --no-header | awk '{print $1,$2,$3}' | sed 's|:||g' | sort -u | grep -avE 'grep|COMMAND|awk|tee|ps|sed|sort|tail' | grep "$1" | grep -aq "${2:-^}" && return 0 || return 1; }
 | 
					__is_running() { ps -eo args --no-header | awk '{print $1,$2,$3}' | sed 's|:||g' | sort -u | grep -vE 'grep|COMMAND|awk|tee|ps|sed|sort|tail' | grep "$1" | grep -q "${2:-^}" && return 0 || return 1; }
 | 
				
			||||||
__get_pid() { ps -ax --no-header | sed 's/^[[:space:]]*//g;s|;||g;s|:||g' | awk '{print $1,$5}' | sed 's|:||g' | grep "$1$" | grep -av 'grep' | awk -F' ' '{print $1}' | grep -a '[0-9]' | sort -uV | head -n1 | grep -a '^' && return 0 || return 1; }
 | 
					__get_pid() { ps -ax --no-header | 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 '.' && return 0 || return 1; }
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
__format_variables() { printf '%s\n' "${@//,/ }" | tr ' ' '\n' | sort -RVu | grep -av '^$' | tr '\n' ' ' | __clean_variables | grep -a '^' || return 3; }
 | 
					__format_variables() { printf '%s\n' "${@//,/ }" | tr ' ' '\n' | sort -RVu | grep -v '^$' | tr '\n' ' ' | __clean_variables | grep '.' || return 3; }
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
__clean_variables() {
 | 
					__clean_variables() {
 | 
				
			||||||
  local var="$*"
 | 
					  local var="$*"
 | 
				
			||||||
  var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
 | 
					  var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
 | 
				
			||||||
  var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
 | 
					  var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
 | 
				
			||||||
  var="$(printf '%s\n' "$var" | sed 's/\( \)*/\1/g;s|^ ||g')"
 | 
					  var="$(printf '%s\n' "$var" | sed 's/\( \)*/\1/g;s|^ ||g')"
 | 
				
			||||||
  printf '%s' "$var" | grep -av '^$'
 | 
					  printf '%s' "$var" | grep -v '^$'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# Auto-detect services from init.d scripts
 | 
					 | 
				
			||||||
__auto_detect_services() {
 | 
					 | 
				
			||||||
  local discovered_services="tini"  # Always include tini as init
 | 
					 | 
				
			||||||
  local init_dir="/usr/local/etc/docker/init.d"
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  if [ -d "$init_dir" ]; then
 | 
					 | 
				
			||||||
    for script in "$init_dir"/*.sh; do
 | 
					 | 
				
			||||||
      if [ -f "$script" ]; then
 | 
					 | 
				
			||||||
        # Extract service name from filename (remove number prefix and .sh suffix)
 | 
					 | 
				
			||||||
        local service=$(basename "$script" | sed 's/^[0-9]*-//;s|\.sh$||g')
 | 
					 | 
				
			||||||
        discovered_services="$discovered_services,$service"
 | 
					 | 
				
			||||||
      fi
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  echo "$discovered_services"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Enhanced __no_exit function with service monitoring and proper failure handling
 | 
					 | 
				
			||||||
__no_exit() {
 | 
					__no_exit() {
 | 
				
			||||||
  local monitor_services="${SERVICES_LIST:-$(__auto_detect_services)}"
 | 
					  local monitor_interval="${SERVICE_MONITOR_INTERVAL:-60}"
 | 
				
			||||||
  local check_interval="${SERVICE_CHECK_INTERVAL:-30}"
 | 
					  local failure_threshold="${SERVICE_FAILURE_THRESHOLD:-3}"
 | 
				
			||||||
  local max_failures="${MAX_SERVICE_FAILURES:-3}"
 | 
					  local monitor_services="${SERVICES_LIST:-tini}"
 | 
				
			||||||
  declare -A failure_counts
 | 
					  local failed_services=""
 | 
				
			||||||
  
 | 
					  local failure_count=0
 | 
				
			||||||
  # Initialize failure counters
 | 
					
 | 
				
			||||||
  IFS=',' read -ra services <<< "$monitor_services"
 | 
					  [ -f "/run/no_exit.pid" ] && return 0
 | 
				
			||||||
  for service in "${services[@]}"; do
 | 
					
 | 
				
			||||||
    service="${service// /}" # trim whitespace
 | 
					  exec bash -c "
 | 
				
			||||||
    [ -n "$service" ] && failure_counts["$service"]=0
 | 
					    trap 'echo \"Container shutdown requested\"; rm -f /run/no_exit.pid /run/*.pid; exit 0' TERM INT
 | 
				
			||||||
  done
 | 
					    echo \$\$ > /run/no_exit.pid
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  echo "🔍 Starting service supervisor - monitoring: $monitor_services"
 | 
					    while true; do
 | 
				
			||||||
  echo "⏰ Check interval: ${check_interval}s, Max failures: $max_failures per service"
 | 
					      if [ -n \"$monitor_services\" ] && [ \"$monitor_services\" != \"tini\" ]; then
 | 
				
			||||||
  
 | 
					        for service in \$(echo \"$monitor_services\" | tr ',' ' '); do
 | 
				
			||||||
  # Set up trap to handle termination gracefully
 | 
					          if [ \"\$service\" != \"tini\" ] && ! pgrep -x \"\$service\" >/dev/null 2>&1; then
 | 
				
			||||||
  trap 'echo "🛑 Container terminating - cleaning up services"; kill $(jobs -p) 2>/dev/null; rm -f /run/*.pid /run/init.d/*.pid; exit 0' TERM INT EXIT
 | 
					            echo \"⚠️ Service \$service is not running\" >&2
 | 
				
			||||||
  
 | 
					            failed_services=\"\$failed_services \$service\"
 | 
				
			||||||
  # Main supervision loop
 | 
					            failure_count=\$((failure_count + 1))
 | 
				
			||||||
  while true; do
 | 
					          fi
 | 
				
			||||||
    local failed_services=""
 | 
					        done
 | 
				
			||||||
    local running_services=""
 | 
					
 | 
				
			||||||
    local critical_failure=false
 | 
					        if [ \$failure_count -ge $failure_threshold ]; then
 | 
				
			||||||
    
 | 
					          echo \"❌ Too many service failures (\$failure_count), exiting container\" >&2
 | 
				
			||||||
    # Check each monitored service
 | 
					          exit 1
 | 
				
			||||||
    IFS=',' read -ra services <<< "$monitor_services"
 | 
					        fi
 | 
				
			||||||
    for service in "${services[@]}"; do
 | 
					
 | 
				
			||||||
      service="${service// /}" # trim whitespace
 | 
					        if [ -n \"\$failed_services\" ]; then
 | 
				
			||||||
      [ -z "$service" ] && continue
 | 
					          echo \"⚠️ Failed services:\$failed_services\" >&2
 | 
				
			||||||
      
 | 
					          failed_services=\"\"
 | 
				
			||||||
      if __pgrep "$service" >/dev/null 2>&1; then
 | 
					 | 
				
			||||||
        running_services="$running_services $service"
 | 
					 | 
				
			||||||
        failure_counts["$service"]=0  # reset failure count on success
 | 
					 | 
				
			||||||
      else
 | 
					 | 
				
			||||||
        failed_services="$failed_services $service"
 | 
					 | 
				
			||||||
        failure_counts["$service"]=$((${failure_counts["$service"]:-0} + 1))
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        echo "⚠️  Service '$service' not running (failure ${failure_counts["$service"]}/$max_failures)"
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        # Check if we've exceeded max failures for this service
 | 
					 | 
				
			||||||
        if [ ${failure_counts["$service"]} -ge $max_failures ]; then
 | 
					 | 
				
			||||||
          echo "💥 Service '$service' failed $max_failures times - this is critical!"
 | 
					 | 
				
			||||||
          critical_failure=true
 | 
					 | 
				
			||||||
        fi
 | 
					        fi
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
    done
 | 
					
 | 
				
			||||||
    
 | 
					      sleep $monitor_interval
 | 
				
			||||||
    # If we have critical failures, terminate the container
 | 
					    done &
 | 
				
			||||||
    if [ "$critical_failure" = true ]; then
 | 
					    wait
 | 
				
			||||||
      echo "🚨 Critical service failure detected:"
 | 
					  "
 | 
				
			||||||
      echo "   💀 Dead services: $failed_services"  
 | 
					 | 
				
			||||||
      echo "   ✅ Running services: $running_services"
 | 
					 | 
				
			||||||
      echo "   🔄 Container will terminate to allow restart by orchestrator"
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      # Write final status to log
 | 
					 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
        echo "$(date): CRITICAL FAILURE - Container terminating"
 | 
					 | 
				
			||||||
        echo "Dead services: $failed_services"
 | 
					 | 
				
			||||||
        echo "Running services: $running_services"
 | 
					 | 
				
			||||||
      } >> "/data/logs/start.log"
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      # Terminate the container (PID 1 is the init process)
 | 
					 | 
				
			||||||
      kill -TERM 1
 | 
					 | 
				
			||||||
      exit 1
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    # Log status periodically (every 10 cycles = ~5 minutes with 30s interval)
 | 
					 | 
				
			||||||
    if [ $(($(date +%s) % 300)) -lt $check_interval ]; then
 | 
					 | 
				
			||||||
      echo "📊 Service status - Running:$running_services Failed:$failed_services"
 | 
					 | 
				
			||||||
      # Write to start.log for backward compatibility
 | 
					 | 
				
			||||||
      echo "$(date): Services running:$running_services failed:$failed_services" >> "/data/logs/start.log"
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    sleep "$check_interval"
 | 
					 | 
				
			||||||
  done &
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  # Keep the original behavior for log tailing (for compatibility)
 | 
					 | 
				
			||||||
  [ -f "/data/logs/start.log" ] && tail -f "/data/logs/start.log" >/dev/null 2>&1 &
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  # Wait for background processes
 | 
					 | 
				
			||||||
  wait
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
__trim() {
 | 
					__trim() {
 | 
				
			||||||
@@ -178,21 +115,21 @@ __trim() {
 | 
				
			|||||||
  var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
 | 
					  var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
 | 
				
			||||||
  var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
 | 
					  var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
 | 
				
			||||||
  var="$(echo "$var" | __remove_extra_spaces | sed "s| |; |g;s|;$| |g" | __remove_extra_spaces)"
 | 
					  var="$(echo "$var" | __remove_extra_spaces | sed "s| |; |g;s|;$| |g" | __remove_extra_spaces)"
 | 
				
			||||||
  printf '%s' "$var" | sed 's|;||g' | grep -av '^$'
 | 
					  printf '%s' "$var" | sed 's|;||g' | grep -v '^$'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
__banner() { printf '# - - - %-60s  - - - #\n' "$*"; }
 | 
					__banner() { printf '# - - - %-60s  - - - #\n' "$*"; }
 | 
				
			||||||
__find_php_bin() { find -L '/usr'/*bin -maxdepth 4 -name 'php-fpm*' 2>/dev/null | head -n1 | grep -a '^' || echo ''; }
 | 
					__find_php_bin() { find -L '/usr'/*bin -maxdepth 4 -name 'php-fpm*' 2>/dev/null | head -n1 | grep '.' || echo ''; }
 | 
				
			||||||
__find_php_ini() { find -L '/etc' -maxdepth 4 -name 'php.ini' 2>/dev/null | head -n1 | sed 's|/php.ini||g' | grep -a '^' || echo ''; }
 | 
					__find_php_ini() { find -L '/etc' -maxdepth 4 -name 'php.ini' 2>/dev/null | head -n1 | sed 's|/php.ini||g' | grep '.' || echo ''; }
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
__find_nginx_conf() { find -L '/etc' -maxdepth 4 -name 'nginx.conf' 2>/dev/null | head -n1 | grep -a '^' || echo ''; }
 | 
					__find_nginx_conf() { find -L '/etc' -maxdepth 4 -name 'nginx.conf' 2>/dev/null | head -n1 | grep '.' || echo ''; }
 | 
				
			||||||
__find_caddy_conf() { find -L '/etc' -maxdepth 4 -type f -iname 'caddy.conf' 2>/dev/null | head -n1 | grep -a '^' || echo ''; }
 | 
					__find_caddy_conf() { find -L '/etc' -maxdepth 4 -type f -iname 'caddy.conf' 2>/dev/null | head -n1 | grep '.' || echo ''; }
 | 
				
			||||||
__find_lighttpd_conf() { find -L '/etc' -maxdepth 4 -type f -iname 'lighttpd.conf' 2>/dev/null | head -n1 | grep -a '^' || echo ''; }
 | 
					__find_lighttpd_conf() { find -L '/etc' -maxdepth 4 -type f -iname 'lighttpd.conf' 2>/dev/null | head -n1 | grep '.' || echo ''; }
 | 
				
			||||||
__find_cherokee_conf() { find -L '/etc' -maxdepth 4 -type f -iname 'cherokee.conf' 2>/dev/null | head -n1 | grep -a '^' || echo ''; }
 | 
					__find_cherokee_conf() { find -L '/etc' -maxdepth 4 -type f -iname 'cherokee.conf' 2>/dev/null | head -n1 | grep '.' || echo ''; }
 | 
				
			||||||
__find_httpd_conf() { find -L '/etc' -maxdepth 4 -type f -iname 'httpd.conf' -o -iname 'apache2.conf' 2>/dev/null | head -n1 | grep -a '^' || echo ''; }
 | 
					__find_httpd_conf() { find -L '/etc' -maxdepth 4 -type f -iname 'httpd.conf' -o -iname 'apache2.conf' 2>/dev/null | head -n1 | grep '.' || echo ''; }
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
__find_mysql_conf() { find -L '/etc' -maxdepth 4 -type f -name 'my.cnf' 2>/dev/null | head -n1 | grep -a '^' || echo ''; }
 | 
					__find_mysql_conf() { find -L '/etc' -maxdepth 4 -type f -name 'my.cnf' 2>/dev/null | head -n1 | grep '.' || echo ''; }
 | 
				
			||||||
__find_pgsql_conf() { find -L '/var/lib' '/etc' -maxdepth 8 -type f -name 'postgresql.conf' 2>/dev/null | head -n1 | grep -a '^' || echo ''; }
 | 
					__find_pgsql_conf() { find -L '/var/lib' '/etc' -maxdepth 8 -type f -name 'postgresql.conf' 2>/dev/null | head -n1 | grep '.' || echo ''; }
 | 
				
			||||||
__find_couchdb_conf() { return; }
 | 
					__find_couchdb_conf() { return; }
 | 
				
			||||||
__find_mongodb_conf() { return; }
 | 
					__find_mongodb_conf() { return; }
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
@@ -523,7 +460,7 @@ __file_copy() {
 | 
				
			|||||||
__generate_random_uids() {
 | 
					__generate_random_uids() {
 | 
				
			||||||
  local set_random_uid="$(seq 3000 5000 | sort -R | head -n 1)"
 | 
					  local set_random_uid="$(seq 3000 5000 | sort -R | head -n 1)"
 | 
				
			||||||
  while :; do
 | 
					  while :; do
 | 
				
			||||||
    if grep -ashq "x:.*:$set_random_uid:" "/etc/group" && ! grep -ashq "x:$set_random_uid:.*:" "/etc/passwd"; then
 | 
					    if grep -shq "x:.*:$set_random_uid:" "/etc/group" && ! grep -shq "x:$set_random_uid:.*:" "/etc/passwd"; then
 | 
				
			||||||
      set_random_uid=$((set_random_uid + 1))
 | 
					      set_random_uid=$((set_random_uid + 1))
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      echo "$set_random_uid"
 | 
					      echo "$set_random_uid"
 | 
				
			||||||
@@ -571,7 +508,7 @@ __fix_permissions() {
 | 
				
			|||||||
  change_group="${2:-${SERVICE_GROUP:-$change_user}}"
 | 
					  change_group="${2:-${SERVICE_GROUP:-$change_user}}"
 | 
				
			||||||
  [ -n "$RUNAS_USER" ] && [ "$RUNAS_USER" != "root" ] && change_user="$RUNAS_USER" && change_group="$change_user"
 | 
					  [ -n "$RUNAS_USER" ] && [ "$RUNAS_USER" != "root" ] && change_user="$RUNAS_USER" && change_group="$change_user"
 | 
				
			||||||
  if [ -n "$change_user" ]; then
 | 
					  if [ -n "$change_user" ]; then
 | 
				
			||||||
    if grep -ashq "^$change_user:" "/etc/passwd"; then
 | 
					    if grep -shq "^$change_user:" "/etc/passwd"; then
 | 
				
			||||||
      for permissions in $ADD_APPLICATION_DIRS $APPLICATION_DIRS; do
 | 
					      for permissions in $ADD_APPLICATION_DIRS $APPLICATION_DIRS; do
 | 
				
			||||||
        if [ -n "$permissions" ] && [ -e "$permissions" ]; then
 | 
					        if [ -n "$permissions" ] && [ -e "$permissions" ]; then
 | 
				
			||||||
          (chown -Rf $change_user "$permissions" && echo "changed ownership on $permissions to user:$change_user") 2>/dev/stderr | tee -p -a "/data/logs/init.txt"
 | 
					          (chown -Rf $change_user "$permissions" && echo "changed ownership on $permissions to user:$change_user") 2>/dev/stderr | tee -p -a "/data/logs/init.txt"
 | 
				
			||||||
@@ -580,7 +517,7 @@ __fix_permissions() {
 | 
				
			|||||||
    fi
 | 
					    fi
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  if [ -n "$change_group" ]; then
 | 
					  if [ -n "$change_group" ]; then
 | 
				
			||||||
    if grep -ashq "^$change_group:" "/etc/group"; then
 | 
					    if grep -shq "^$change_group:" "/etc/group"; then
 | 
				
			||||||
      for permissions in $ADD_APPLICATION_DIRS $APPLICATION_DIRS; do
 | 
					      for permissions in $ADD_APPLICATION_DIRS $APPLICATION_DIRS; do
 | 
				
			||||||
        if [ -n "$permissions" ] && [ -e "$permissions" ]; then
 | 
					        if [ -n "$permissions" ] && [ -e "$permissions" ]; then
 | 
				
			||||||
          (chgrp -Rf $change_group "$permissions" && echo "changed group ownership on $permissions to group $change_group") 2>/dev/stderr | tee -p -a "/data/logs/init.txt"
 | 
					          (chgrp -Rf $change_group "$permissions" && echo "changed group ownership on $permissions to group $change_group") 2>/dev/stderr | tee -p -a "/data/logs/init.txt"
 | 
				
			||||||
@@ -590,12 +527,12 @@ __fix_permissions() {
 | 
				
			|||||||
  fi
 | 
					  fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
__get_gid() { grep -a "^$1:" /etc/group | awk -F ':' '{print $3}' || false; }
 | 
					__get_gid() { grep "^$1:" /etc/group | awk -F ':' '{print $3}' || false; }
 | 
				
			||||||
__get_uid() { grep -a "^$1:" /etc/passwd | awk -F ':' '{print $3}' || false; }
 | 
					__get_uid() { grep "^$1:" /etc/passwd | awk -F ':' '{print $3}' || false; }
 | 
				
			||||||
__check_for_uid() { cat "/etc/passwd" 2>/dev/null | awk -F ':' '{print $3}' | sort -u | grep -aq "^$1$" || false; }
 | 
					__check_for_uid() { cat "/etc/passwd" 2>/dev/null | awk -F ':' '{print $3}' | sort -u | grep -q "^$1$" || false; }
 | 
				
			||||||
__check_for_guid() { cat "/etc/group" 2>/dev/null | awk -F ':' '{print $3}' | sort -u | grep -aq "^$1$" || false; }
 | 
					__check_for_guid() { cat "/etc/group" 2>/dev/null | awk -F ':' '{print $3}' | sort -u | grep -q "^$1$" || false; }
 | 
				
			||||||
__check_for_user() { cat "/etc/passwd" 2>/dev/null | awk -F ':' '{print $1}' | sort -u | grep -aq "^$1$" || false; }
 | 
					__check_for_user() { cat "/etc/passwd" 2>/dev/null | awk -F ':' '{print $1}' | sort -u | grep -q "^$1$" || false; }
 | 
				
			||||||
__check_for_group() { cat "/etc/group" 2>/dev/null | awk -F ':' '{print $1}' | sort -u | grep -aq "^$1$" || false; }
 | 
					__check_for_group() { cat "/etc/group" 2>/dev/null | awk -F ':' '{print $1}' | sort -u | grep -q "^$1$" || false; }
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# check if process is already running
 | 
					# check if process is already running
 | 
				
			||||||
__proc_check() {
 | 
					__proc_check() {
 | 
				
			||||||
@@ -620,9 +557,9 @@ __set_user_group_id() {
 | 
				
			|||||||
  local random_id="$(__generate_random_uids)"
 | 
					  local random_id="$(__generate_random_uids)"
 | 
				
			||||||
  set_uid="$(__get_uid "$set_user" || echo "$set_uid")"
 | 
					  set_uid="$(__get_uid "$set_user" || echo "$set_uid")"
 | 
				
			||||||
  set_gid="$(__get_gid "$set_user" || echo "$set_gid")"
 | 
					  set_gid="$(__get_gid "$set_user" || echo "$set_gid")"
 | 
				
			||||||
  grep -ashq "^$create_user:" "/etc/passwd" "/etc/group" || return 0
 | 
					  grep -shq "^$create_user:" "/etc/passwd" "/etc/group" || return 0
 | 
				
			||||||
  [ -n "$set_user" ] && [ "$set_user" != "root" ] || return
 | 
					  [ -n "$set_user" ] && [ "$set_user" != "root" ] || return
 | 
				
			||||||
  if grep -ashq "^$set_user:" "/etc/passwd" "/etc/group"; then
 | 
					  if grep -shq "^$set_user:" "/etc/passwd" "/etc/group"; then
 | 
				
			||||||
    if __check_for_guid "$set_gid"; then
 | 
					    if __check_for_guid "$set_gid"; then
 | 
				
			||||||
      groupmod -g "${set_gid}" $set_user 2>/dev/stderr | tee -p -a "/data/logs/init.txt" >/dev/null && chown -Rf ":$set_gid"
 | 
					      groupmod -g "${set_gid}" $set_user 2>/dev/stderr | tee -p -a "/data/logs/init.txt" >/dev/null && chown -Rf ":$set_gid"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
@@ -643,7 +580,7 @@ __create_service_user() {
 | 
				
			|||||||
  local create_gid="${5:-${SERVICE_GID:-$USER_GID}}"
 | 
					  local create_gid="${5:-${SERVICE_GID:-$USER_GID}}"
 | 
				
			||||||
  local random_id="$(__generate_random_uids)"
 | 
					  local random_id="$(__generate_random_uids)"
 | 
				
			||||||
  local create_home_dir="${create_home_dir:-/home/$create_user}"
 | 
					  local create_home_dir="${create_home_dir:-/home/$create_user}"
 | 
				
			||||||
  grep -ashq "^$create_user:" "/etc/passwd" && grep -ashq "^$create_group:" "/etc/group" && return
 | 
					  grep -shq "^$create_user:" "/etc/passwd" && grep -shq "^$create_group:" "/etc/group" && return
 | 
				
			||||||
  [ "$create_user" = "root" ] && [ "$create_group" = "root" ] && return 0
 | 
					  [ "$create_user" = "root" ] && [ "$create_group" = "root" ] && return 0
 | 
				
			||||||
  if [ "$RUNAS_USER" != "root" ] && [ "$RUNAS_USER" != "" ]; then
 | 
					  if [ "$RUNAS_USER" != "root" ] && [ "$RUNAS_USER" != "" ]; then
 | 
				
			||||||
    create_user="$RUNAS_USER"
 | 
					    create_user="$RUNAS_USER"
 | 
				
			||||||
@@ -671,8 +608,8 @@ __create_service_user() {
 | 
				
			|||||||
    echo "creating system user $create_user"
 | 
					    echo "creating system user $create_user"
 | 
				
			||||||
    useradd --system -u $create_uid -g $create_group -c "Account for $create_user" -d "$create_home_dir" -s /bin/false $create_user 2>/dev/stderr | tee -p -a "/data/logs/init.txt" >/dev/null
 | 
					    useradd --system -u $create_uid -g $create_group -c "Account for $create_user" -d "$create_home_dir" -s /bin/false $create_user 2>/dev/stderr | tee -p -a "/data/logs/init.txt" >/dev/null
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  grep -ashq "$create_group" "/etc/group" || exitStatus=$((exitCode + 1))
 | 
					  grep -shq "$create_group" "/etc/group" || exitStatus=$((exitCode + 1))
 | 
				
			||||||
  grep -ashq "$create_user" "/etc/passwd" || exitStatus=$((exitCode + 1))
 | 
					  grep -shq "$create_user" "/etc/passwd" || exitStatus=$((exitCode + 1))
 | 
				
			||||||
  if [ $exitStatus -eq 0 ]; then
 | 
					  if [ $exitStatus -eq 0 ]; then
 | 
				
			||||||
    export WORK_DIR="${create_home_dir:-}"
 | 
					    export WORK_DIR="${create_home_dir:-}"
 | 
				
			||||||
    if [ -n "$WORK_DIR" ]; then
 | 
					    if [ -n "$WORK_DIR" ]; then
 | 
				
			||||||
@@ -681,7 +618,7 @@ __create_service_user() {
 | 
				
			|||||||
    fi
 | 
					    fi
 | 
				
			||||||
    if [ -d "/etc/sudoers.d" ] && [ ! -f "/etc/sudoers.d/$create_user" ]; then
 | 
					    if [ -d "/etc/sudoers.d" ] && [ ! -f "/etc/sudoers.d/$create_user" ]; then
 | 
				
			||||||
      echo "$create_user ALL=(ALL)   NOPASSWD: ALL" >"/etc/sudoers.d/$create_user"
 | 
					      echo "$create_user ALL=(ALL)   NOPASSWD: ALL" >"/etc/sudoers.d/$create_user"
 | 
				
			||||||
    elif [ -f "/etc/sudoers" ] && grep -aqs "$create_user" "/etc/sudoers"; then
 | 
					    elif [ -f "/etc/sudoers" ] && grep -qs "$create_user" "/etc/sudoers"; then
 | 
				
			||||||
      echo "$create_user ALL=(ALL)   NOPASSWD: ALL" >"/etc/sudoers"
 | 
					      echo "$create_user ALL=(ALL)   NOPASSWD: ALL" >"/etc/sudoers"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
    export SERVICE_UID="$create_uid"
 | 
					    export SERVICE_UID="$create_uid"
 | 
				
			||||||
@@ -725,7 +662,7 @@ __exec_command() {
 | 
				
			|||||||
  local cmdExec="${arg:-}"
 | 
					  local cmdExec="${arg:-}"
 | 
				
			||||||
  local pre_exec="--login -c"
 | 
					  local pre_exec="--login -c"
 | 
				
			||||||
  local shell="$(type -P bash 2>/dev/null || type -P dash 2>/dev/null || type -P ash 2>/dev/null || type -P sh 2>/dev/null)"
 | 
					  local shell="$(type -P bash 2>/dev/null || type -P dash 2>/dev/null || type -P ash 2>/dev/null || type -P sh 2>/dev/null)"
 | 
				
			||||||
  bin="$(echo "${arg[*]}" | tr ' ' '\n' | grep -av '^$' | head -n1 | sed 's| ||g' || echo 'bash')"
 | 
					  bin="$(echo "${arg[*]}" | tr ' ' '\n' | grep -v '^$' | head -n1 | sed 's| ||g' || echo 'bash')"
 | 
				
			||||||
  prog="$(type -P "$bin" 2>/dev/null || echo "$bin")"
 | 
					  prog="$(type -P "$bin" 2>/dev/null || echo "$bin")"
 | 
				
			||||||
  if type -t $bin >/dev/null 2>&1; then
 | 
					  if type -t $bin >/dev/null 2>&1; then
 | 
				
			||||||
    echo "${exec_message:-Executing command: $cmdExec}"
 | 
					    echo "${exec_message:-Executing command: $cmdExec}"
 | 
				
			||||||
@@ -743,129 +680,94 @@ __exec_command() {
 | 
				
			|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# Setup the server init scripts
 | 
					# Setup the server init scripts
 | 
				
			||||||
__start_init_scripts() {
 | 
					__start_init_scripts() {
 | 
				
			||||||
  # Let individual scripts handle their own errors - don't use global error traps
 | 
					  set -e
 | 
				
			||||||
  
 | 
					  trap 'echo "❌ Fatal error, killing container"; kill -TERM 1' ERR
 | 
				
			||||||
  [ "$1" = " " ] && shift 1
 | 
					  [ "$1" = " " ] && shift 1
 | 
				
			||||||
  [ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -o pipefail -x$DEBUGGER_OPTIONS || set -o pipefail
 | 
					  [ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -o pipefail -x$DEBUGGER_OPTIONS || set -o pipefail
 | 
				
			||||||
  
 | 
					  local retPID=""
 | 
				
			||||||
  local basename=""
 | 
					  local basename=""
 | 
				
			||||||
  local init_pids=""
 | 
					  local init_pids=""
 | 
				
			||||||
  local retstatus="0"
 | 
					  local retstatus="0"
 | 
				
			||||||
  local initStatus="0"
 | 
					  local initStatus="0"
 | 
				
			||||||
  local failed_services=""
 | 
					 | 
				
			||||||
  local successful_services=""
 | 
					 | 
				
			||||||
  local init_dir="${1:-/usr/local/etc/docker/init.d}"
 | 
					  local init_dir="${1:-/usr/local/etc/docker/init.d}"
 | 
				
			||||||
  local init_count="$(find "$init_dir" -name "*.sh" 2>/dev/null | wc -l)"
 | 
					  local init_count="$(ls -A "$init_dir"/* 2>/dev/null | grep -v '\.sample' | wc -l)"
 | 
				
			||||||
  
 | 
					  local critical_failures=0
 | 
				
			||||||
 | 
					  local exit_on_failure="${EXIT_ON_SERVICE_FAILURE:-true}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if [ -n "$SERVICE_DISABLED" ]; then
 | 
					  if [ -n "$SERVICE_DISABLED" ]; then
 | 
				
			||||||
    echo "$SERVICE_DISABLED is disabled"
 | 
					 | 
				
			||||||
    unset SERVICE_DISABLED
 | 
					    unset SERVICE_DISABLED
 | 
				
			||||||
 | 
					    echo "$SERVICE_DISABLED is disabled"
 | 
				
			||||||
    return 0
 | 
					    return 0
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  echo "🚀 Starting container services initialization"
 | 
					  # Clean stale PID files from previous runs
 | 
				
			||||||
  echo "📂 Init directory: $init_dir"
 | 
					  if [ ! -f "/run/__start_init_scripts.pid" ]; then
 | 
				
			||||||
  echo "📊 Services to start: $init_count"
 | 
					    echo "🧹 Cleaning stale PID files from previous container run"
 | 
				
			||||||
  
 | 
					    rm -f /run/*.pid /run/init.d/*.pid 2>/dev/null || true
 | 
				
			||||||
  # Create a fresh PID file to track this startup session
 | 
					  fi
 | 
				
			||||||
  echo $$ > /run/__start_init_scripts.pid
 | 
					
 | 
				
			||||||
  
 | 
					  touch /run/__start_init_scripts.pid
 | 
				
			||||||
  mkdir -p "/tmp" "/run" "/run/init.d" "/usr/local/etc/docker/exec" "/data/logs/init"
 | 
					  mkdir -p "/tmp" "/run" "/run/init.d" "/usr/local/etc/docker/exec"
 | 
				
			||||||
  chmod -R 777 "/tmp" "/run" "/run/init.d" "/usr/local/etc/docker/exec" "/data/logs/init"
 | 
					  chmod -R 777 "/tmp" "/run" "/run/init.d" "/usr/local/etc/docker/exec"
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  if [ "$init_count" -eq 0 ] || [ ! -d "$init_dir" ]; then
 | 
					  if [ "$init_count" -eq 0 ] || [ ! -d "$init_dir" ]; then
 | 
				
			||||||
    echo "⚠️  No init scripts found in $init_dir"
 | 
					    mkdir -p "/data/logs/init"
 | 
				
			||||||
    # Still create a minimal keep-alive for containers without services
 | 
					    while :; do echo "Running: $(date)" >"/data/logs/init/keep_alive" && sleep 3600; done &
 | 
				
			||||||
    while true; do 
 | 
					 | 
				
			||||||
      echo "$(date): No services - container keep-alive" >> "/data/logs/start.log"
 | 
					 | 
				
			||||||
      sleep 3600
 | 
					 | 
				
			||||||
    done &
 | 
					 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    echo "📋 Found $init_count service scripts to execute"
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if [ -d "$init_dir" ]; then
 | 
					    if [ -d "$init_dir" ]; then
 | 
				
			||||||
      # Remove sample files  
 | 
					      [ -f "$init_dir/service.sample" ] && __rm "$init_dir"/*.sample
 | 
				
			||||||
      find "$init_dir" -name "*.sample" -delete 2>/dev/null
 | 
					      chmod -Rf 755 "$init_dir"/*.sh
 | 
				
			||||||
      
 | 
					
 | 
				
			||||||
      # Make scripts executable
 | 
					      echo "🚀 Starting container services initialization"
 | 
				
			||||||
      find "$init_dir" -name "*.sh" -exec chmod 755 {} \; 2>/dev/null
 | 
					      echo "📂 Init directory: $init_dir"
 | 
				
			||||||
      
 | 
					      echo "📊 Services to start: $init_count"
 | 
				
			||||||
      # Execute scripts in numerical/alphabetical order
 | 
					      echo "📋 Found $init_count service scripts to execute"
 | 
				
			||||||
 | 
					      echo ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      for init in "$init_dir"/*.sh; do
 | 
					      for init in "$init_dir"/*.sh; do
 | 
				
			||||||
        if [ -x "$init" ]; then
 | 
					        if [ -x "$init" ]; then
 | 
				
			||||||
          basename="$(basename "$init")"
 | 
					          name="$(basename "$init")"
 | 
				
			||||||
          service="$(printf '%s' "$basename" | sed 's/^[0-9]*-//;s|\.sh$||g')"
 | 
					          service="$(printf '%s' "$name" | sed 's/^[^-]*-//;s|.sh$||g')"
 | 
				
			||||||
          
 | 
					
 | 
				
			||||||
          printf '\n🔧 Executing service script: %s (service: %s)\n' "$init" "$service"
 | 
					          echo "🔧 Executing service script: $init (service: $service)"
 | 
				
			||||||
          
 | 
					
 | 
				
			||||||
          # Execute the init script and capture its exit code
 | 
					          # Execute the init script and capture the exit code
 | 
				
			||||||
          if eval "$init"; then
 | 
					          if eval "$init"; then
 | 
				
			||||||
            sleep 5  # Give service more time to start properly
 | 
					            sleep 5
 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            # Verify the service actually started by checking for PID
 | 
					 | 
				
			||||||
            retPID=$(__get_pid "$service")
 | 
					            retPID=$(__get_pid "$service")
 | 
				
			||||||
            if [ -n "$retPID" ]; then
 | 
					            if [ -n "$retPID" ]; then
 | 
				
			||||||
              initStatus="0"
 | 
					              initStatus="0"
 | 
				
			||||||
              successful_services="$successful_services $service"
 | 
					              echo "✅ Service $service started successfully - PID: ${retPID}"
 | 
				
			||||||
              printf '✅ Service %s started successfully - PID: %s\n' "$service" "$retPID"
 | 
					 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
              # Service script succeeded but no PID found - this is suspicious
 | 
					 | 
				
			||||||
              initStatus="1"
 | 
					              initStatus="1"
 | 
				
			||||||
              failed_services="$failed_services $service"
 | 
					              critical_failures=$((critical_failures + 1))
 | 
				
			||||||
              printf '⚠️  Service %s script completed but no PID found\n' "$service"
 | 
					              echo "⚠️ Service $service appears to have started but no process found"
 | 
				
			||||||
            fi
 | 
					            fi
 | 
				
			||||||
          else
 | 
					          else
 | 
				
			||||||
            # Service script failed
 | 
					            initStatus="1"
 | 
				
			||||||
            script_exit_code="$?"
 | 
					            critical_failures=$((critical_failures + 1))
 | 
				
			||||||
            initStatus="1" 
 | 
					            echo "❌ Service $service failed to start - check logs: docker logs $CONTAINER_NAME"
 | 
				
			||||||
            failed_services="$failed_services $service"
 | 
					 | 
				
			||||||
            printf '❌ Init script %s failed with exit code %s\n' "$init" "$script_exit_code"
 | 
					 | 
				
			||||||
          fi
 | 
					          fi
 | 
				
			||||||
        else
 | 
					
 | 
				
			||||||
          printf '⚠️  Script %s is not executable, skipping\n' "$init"
 | 
					          echo ""
 | 
				
			||||||
        fi
 | 
					        fi
 | 
				
			||||||
        
 | 
					        retstatus=$((retstatus + initStatus))
 | 
				
			||||||
        retstatus=$(($retstatus + $initStatus))
 | 
					 | 
				
			||||||
        printf '\n'
 | 
					 | 
				
			||||||
      done
 | 
					      done
 | 
				
			||||||
      
 | 
					
 | 
				
			||||||
      printf '📊 Service startup summary:\n'
 | 
					      # Summary
 | 
				
			||||||
      printf '   ✅ Successful: %s\n' "${successful_services:-none}"
 | 
					      if [ $critical_failures -gt 0 ]; then
 | 
				
			||||||
      printf '   ❌ Failed: %s\n' "${failed_services:-none}"
 | 
					        echo "⚠️ Warning: $critical_failures service(s) failed to start"
 | 
				
			||||||
      printf '   📈 Total status code: %s\n' "$retstatus"
 | 
					        if [ "$exit_on_failure" = "true" ] && [ $critical_failures -ge 1 ]; then
 | 
				
			||||||
      
 | 
					          echo "❌ Exiting due to critical service failures"
 | 
				
			||||||
      # If any services failed to start, terminate the container immediately
 | 
					          return 1
 | 
				
			||||||
      if [ $retstatus -gt 0 ]; then
 | 
					        fi
 | 
				
			||||||
        echo ""
 | 
					      else
 | 
				
			||||||
        echo "💥 Service startup failures detected!"
 | 
					        echo "✅ All services started successfully"
 | 
				
			||||||
        echo "🔄 Container will terminate to allow orchestrator restart"
 | 
					 | 
				
			||||||
        echo "📝 Check container logs for detailed failure information"
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        # Write failure information to log
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
          echo "$(date): SERVICE STARTUP FAILURE"
 | 
					 | 
				
			||||||
          echo "Successful services: $successful_services"
 | 
					 | 
				
			||||||
          echo "Failed services: $failed_services" 
 | 
					 | 
				
			||||||
          echo "Total errors: $retstatus"
 | 
					 | 
				
			||||||
        } >> "/data/logs/start.log"
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        # Clean up and exit
 | 
					 | 
				
			||||||
        rm -f /run/__start_init_scripts.pid
 | 
					 | 
				
			||||||
        exit $retstatus
 | 
					 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  # Write successful startup status to log
 | 
					  printf '%s\n' "$SERVICE_NAME started on $(date)" >"/data/logs/start.log"
 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    echo "$(date): Container startup completed successfully"
 | 
					 | 
				
			||||||
    echo "Active services: $successful_services"
 | 
					 | 
				
			||||||
    [ -n "$failed_services" ] && echo "Failed services: $failed_services" 
 | 
					 | 
				
			||||||
    echo "Status code: $retstatus"
 | 
					 | 
				
			||||||
  } >> "/data/logs/start.log"
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  printf '\n🎉 All services initialized successfully!\n'
 | 
					 | 
				
			||||||
  printf '🔍 Service monitoring will now begin...\n\n'
 | 
					 | 
				
			||||||
  return $retstatus
 | 
					  return $retstatus
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
@@ -880,7 +782,7 @@ __setup_mta() {
 | 
				
			|||||||
  local local_hostname="${FULL_DOMAIN_NAME:-}"
 | 
					  local local_hostname="${FULL_DOMAIN_NAME:-}"
 | 
				
			||||||
  local account_user="${SERVER_ADMIN//@*/}"
 | 
					  local account_user="${SERVER_ADMIN//@*/}"
 | 
				
			||||||
  local account_domain="${EMAIL_DOMAIN//*@/}"
 | 
					  local account_domain="${EMAIL_DOMAIN//*@/}"
 | 
				
			||||||
  echo "$EMAIL_RELAY" | grep -a '[0-9][0-9]' || relay_port="465"
 | 
					  echo "$EMAIL_RELAY" | grep '[0-9][0-9]' || relay_port="465"
 | 
				
			||||||
  ################# sSMTP relay setup
 | 
					  ################# sSMTP relay setup
 | 
				
			||||||
  if [ -n "$(type -P 'ssmtp')" ]; then
 | 
					  if [ -n "$(type -P 'ssmtp')" ]; then
 | 
				
			||||||
    [ -d "/config/ssmtp" ] || mkdir -p "/config/ssmtp"
 | 
					    [ -d "/config/ssmtp" ] || mkdir -p "/config/ssmtp"
 | 
				
			||||||
@@ -1045,7 +947,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 -aq '^/etc'; then
 | 
					  if echo "$dir" | grep -q '^/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"
 | 
				
			||||||
@@ -1078,8 +980,8 @@ __initialize_system_etc() {
 | 
				
			|||||||
  local file=()
 | 
					  local file=()
 | 
				
			||||||
  local directories=""
 | 
					  local directories=""
 | 
				
			||||||
  if [ -n "$conf_dir" ] && [ -e "$conf_dir" ]; then
 | 
					  if [ -n "$conf_dir" ] && [ -e "$conf_dir" ]; then
 | 
				
			||||||
    files="$(find "$conf_dir"/* -not -path '*/env/*' -type f 2>/dev/null | sed 's|'/config/'||g' | sort -u | grep -av '^$' | grep -a '^' || false)"
 | 
					    files="$(find "$conf_dir"/* -not -path '*/env/*' -type f 2>/dev/null | sed 's|'/config/'||g' | sort -u | grep -v '^$' | grep '.' || false)"
 | 
				
			||||||
    directories="$(find "$conf_dir"/* -not -path '*/env/*' -type d 2>/dev/null | sed 's|'/config/'||g' | sort -u | grep -av '^$' | grep -a '^' || false)"
 | 
					    directories="$(find "$conf_dir"/* -not -path '*/env/*' -type d 2>/dev/null | sed 's|'/config/'||g' | sort -u | grep -v '^$' | grep '.' || false)"
 | 
				
			||||||
    echo "Copying config files to system: $conf_dir > /etc/${conf_dir//\/config\//}"
 | 
					    echo "Copying config files to system: $conf_dir > /etc/${conf_dir//\/config\//}"
 | 
				
			||||||
    if [ -n "$directories" ]; then
 | 
					    if [ -n "$directories" ]; then
 | 
				
			||||||
      for d in $directories; do
 | 
					      for d in $directories; do
 | 
				
			||||||
@@ -1193,7 +1095,7 @@ __initialize_www_root() {
 | 
				
			|||||||
__is_htdocs_mounted() {
 | 
					__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"
 | 
				
			||||||
  [ -n "$IMPORT_FROM_GIT" ] && echo "$IMPORT_FROM_GIT" | grep -aqE 'https://|http://|git://|ssh://' || unset IMPORT_FROM_GIT
 | 
					  [ -n "$IMPORT_FROM_GIT" ] && echo "$IMPORT_FROM_GIT" | grep -qE 'https://|http://|git://|ssh://' || unset IMPORT_FROM_GIT
 | 
				
			||||||
  if [ -n "$IMPORT_FROM_GIT" ] && [ "$(command -v "git" 2>/dev/null)" ]; then
 | 
					  if [ -n "$IMPORT_FROM_GIT" ] && [ "$(command -v "git" 2>/dev/null)" ]; then
 | 
				
			||||||
    if __is_dir_empty "$WWW_ROOT_DIR"; then
 | 
					    if __is_dir_empty "$WWW_ROOT_DIR"; then
 | 
				
			||||||
      echo "Importing project from $IMPORT_FROM_GIT to $WWW_ROOT_DIR"
 | 
					      echo "Importing project from $IMPORT_FROM_GIT to $WWW_ROOT_DIR"
 | 
				
			||||||
@@ -1250,7 +1152,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 -aq "^/usr/local/share/httpd"; then
 | 
					    if ! echo "$1" | grep -q "^/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
 | 
				
			||||||
@@ -1384,6 +1286,6 @@ export ENTRYPOINT_DATA_INIT_FILE DATA_DIR_INITIALIZED ENTRYPOINT_CONFIG_INIT_FIL
 | 
				
			|||||||
export ENTRYPOINT_PID_FILE ENTRYPOINT_INIT_FILE ENTRYPOINT_FIRST_RUN
 | 
					export ENTRYPOINT_PID_FILE ENTRYPOINT_INIT_FILE ENTRYPOINT_FIRST_RUN
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# export the functions
 | 
					# export the functions
 | 
				
			||||||
export -f __get_pid __start_init_scripts __is_running __certbot __update_ssl_certs __create_ssl_cert __no_exit __auto_detect_services
 | 
					export -f __get_pid __start_init_scripts __is_running __certbot __update_ssl_certs __create_ssl_cert
 | 
				
			||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
				
			||||||
# end of functions
 | 
					# end of functions
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -113,7 +113,7 @@ 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/init.d/entrypoint.pid}"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user