♻️ Migrate couchdb to /config/ source-of-truth architecture ♻️

Migrate couchdb Docker image to the new build-time config architecture.
- rootfs/root/docker/setup/03-files.sh: rewrite to canonical form with /tmp/bin, /tmp/var, /tmp/etc, /tmp/usr handlers
- rootfs/usr/local/etc/docker/functions/entrypoint.sh: update to latest template
- rootfs/usr/local/etc/docker/init.d/*.sh: fix $(basename) UUOC; move inline comments above code lines
- rootfs/tmp/etc/: add service config files (couchdb nginx ) deployed to /etc/ at build time
- rootfs/usr/local/share/template-files/: delete; config now deployed via /tmp/etc/ and /tmp/usr/ at build time

rootfs/root/docker/setup/03-files.sh
rootfs/tmp/
rootfs/usr/local/etc/docker/functions/entrypoint.sh
rootfs/usr/local/etc/docker/init.d/00-couchdb.sh
rootfs/usr/local/etc/docker/init.d/zz-nginx.sh
rootfs/usr/local/share/template-files/config/couchdb/default.ini
rootfs/usr/local/share/template-files/config/couchdb/local.ini
rootfs/usr/local/share/template-files/config/env/default.sample
rootfs/usr/local/share/template-files/config/env/examples/00-directory.sh
rootfs/usr/local/share/template-files/config/env/examples/addresses.sh
rootfs/usr/local/share/template-files/config/env/examples/certbot.sh
rootfs/usr/local/share/template-files/config/env/examples/couchdb.sh
rootfs/usr/local/share/template-files/config/env/examples/dockerd.sh
rootfs/usr/local/share/template-files/config/env/examples/global.sh
rootfs/usr/local/share/template-files/config/env/examples/healthcheck.sh
rootfs/usr/local/share/template-files/config/env/examples/mariadb.sh
rootfs/usr/local/share/template-files/config/env/examples/mongodb.sh
rootfs/usr/local/share/template-files/config/env/examples/networking.sh
rootfs/usr/local/share/template-files/config/env/examples/other.sh
rootfs/usr/local/share/template-files/config/env/examples/php.sh
rootfs/usr/local/share/template-files/config/env/examples/postgres.sh
rootfs/usr/local/share/template-files/config/env/examples/redis.sh
rootfs/usr/local/share/template-files/config/env/examples/services.sh
rootfs/usr/local/share/template-files/config/env/examples/ssl.sh
rootfs/usr/local/share/template-files/config/env/examples/supabase.sh
rootfs/usr/local/share/template-files/config/env/examples/webservers.sh
rootfs/usr/local/share/template-files/config/env/examples/zz-entrypoint.sh
rootfs/usr/local/share/template-files/config/.gitkeep
rootfs/usr/local/share/template-files/config/nginx/mime.types
rootfs/usr/local/share/template-files/config/nginx/nginx.conf
rootfs/usr/local/share/template-files/config/nginx/nginx.ssl.conf
rootfs/usr/local/share/template-files/config/nginx/vhosts.d/default.conf.sample
rootfs/usr/local/share/template-files/config/nginx/vhosts.d/default.ssl.sample
rootfs/usr/local/share/template-files/data/.gitkeep
rootfs/usr/local/share/template-files/defaults/.gitkeep
This commit is contained in:
2026-06-04 14:38:14 -04:00
parent fadb1a2a74
commit aa4d64c1ed
34 changed files with 374 additions and 730 deletions
+104 -54
View File
@@ -43,7 +43,7 @@ __script_exit() {
fi
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SCRIPT_NAME="$(basename "$0" 2>/dev/null)"
SCRIPT_NAME="${0##*/}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
export PATH="/usr/local/etc/docker/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -78,29 +78,40 @@ DATABASE_DIR="${DATABASE_DIR_COUCHDB:-/data/db/couchdb}"
WWW_DIR="/usr/share/webapps/couchdb"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Default predefined variables
DATA_DIR="/data" # set data directory
CONF_DIR="/config" # set config directory
# set data directory
DATA_DIR="/data"
# set config directory
CONF_DIR="/config"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# set the containers etc directory
ETC_DIR="/etc/couchdb"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RUN_DIR="/run/init.d" # set scripts pid dir
LOG_DIR="/data/logs/couchdb" # set log directory
# set scripts pid dir
RUN_DIR="/run/init.d"
# set log directory
LOG_DIR="/data/logs/couchdb"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the working dir
WORK_DIR="" # set working directory
# set working directory
WORK_DIR=""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Where to save passwords to
ROOT_FILE_PREFIX="/config/secure/auth/root" # directory to save username/password for root user
USER_FILE_PREFIX="/config/secure/auth/user" # directory to save username/password for normal user
# directory to save username/password for root user
ROOT_FILE_PREFIX="/config/secure/auth/root"
# directory to save username/password for normal user
USER_FILE_PREFIX="/config/secure/auth/user"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# root/admin user info password/random]
root_user_name="${COUCHDB_ROOT_USER_NAME:-root}" # root user name
root_user_pass="${COUCHDB_ROOT_PASS_WORD:-random}" # root user password
# root user name
root_user_name="${COUCHDB_ROOT_USER_NAME:-root}"
# root user password
root_user_pass="${COUCHDB_ROOT_PASS_WORD:-random}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Normal user info [password/random]
user_name="${COUCHDB_USER_NAME:-}" # normal user name
user_pass="${COUCHDB_USER_PASS_WORD:-}" # normal user password
# normal user name
user_name="${COUCHDB_USER_NAME:-}"
# normal user password
user_pass="${COUCHDB_USER_PASS_WORD:-}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Overwrite variables from files
__file_exists_with_content "${USER_FILE_PREFIX}/${SERVICE_NAME}_name" && user_name="$(<"${USER_FILE_PREFIX}/${SERVICE_NAME}_name")"
@@ -112,11 +123,16 @@ __file_exists_with_content "${ROOT_FILE_PREFIX}/${SERVICE_NAME}_pass" && root_us
SERVICE_PORT="5984"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# execute command variables
SERVICE_UID="0" # set the user id
SERVICE_USER="root" # execute command as another user
EXEC_CMD_BIN="couchdb" # command to execute
EXEC_CMD_ARGS="-vvvvv" # command arguments
EXEC_PRE_SCRIPT="" # execute script before
# set the user id
SERVICE_UID="0"
# execute command as another user
SERVICE_USER="root"
# command to execute
EXEC_CMD_BIN="couchdb"
# command arguments
EXEC_CMD_ARGS="-vvvvv"
# execute script before
EXEC_PRE_SCRIPT=""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Is this service a web server
IS_WEB_SERVER="no"
@@ -142,10 +158,14 @@ CMD_ENV=""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# use this function to update config files - IE: change port
__update_conf_files() {
local exitCode=0 # default exit code
local user="${SERVICE_USER:-root}" # specifiy different user
local runas="root" # run as a different user
local sysname="${SERVER_NAME:-$HOSTNAME}" # set hostname
# default exit code
local exitCode=0
# specifiy different user
local user="${SERVICE_USER:-root}"
# run as a different user
local runas="root"
# set hostname
local sysname="${SERVER_NAME:-$HOSTNAME}"
# delete files
#__rm ""
@@ -209,10 +229,14 @@ __update_conf_files() {
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# function to run before executing
__pre_execute() {
local exitCode=0 # default exit code
local user="${SERVICE_USER:-root}" # specifiy different user
local runas="root" # run as a different user
local sysname="${SERVER_NAME:-$HOSTNAME}" # set hostname
# default exit code
local exitCode=0
# specifiy different user
local user="${SERVICE_USER:-root}"
# run as a different user
local runas="root"
# set hostname
local sysname="${SERVER_NAME:-$HOSTNAME}"
# define commands
@@ -239,12 +263,18 @@ __pre_execute() {
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# function to run after executing
__post_execute() {
local exitCode=0 # default exit code
local user="${SERVICE_USER:-root}" # specifiy different user
local runas="root" # run as a different user
local sysname="${SERVER_NAME:-$HOSTNAME}" # set hostname
sleep 60 # how long to wait before executing
echo "Running post commands" # message
# default exit code
local exitCode=0
# specifiy different user
local user="${SERVICE_USER:-root}"
# run as a different user
local runas="root"
# set hostname
local sysname="${SERVER_NAME:-$HOSTNAME}"
# how long to wait before executing
sleep 60
# message
echo "Running post commands"
# execute commands
(
if ! __curl "http://$COUCHDB_SERVER:$SERVICE_PORT/_users" | grep -q 'db_name":"_users'; then
@@ -304,7 +334,8 @@ __pre_message() {
# use this function to setup ssl support
__update_ssl_conf() {
local exitCode=0
local sysname="${SERVER_NAME:-$HOSTNAME}" # set hostname
# set hostname
local sysname="${SERVER_NAME:-$HOSTNAME}"
return $exitCode
}
@@ -323,7 +354,6 @@ __create_service_env() {
# EXEC_PRE_SCRIPT="${ENV_EXEC_PRE_SCRIPT:-$EXEC_PRE_SCRIPT}" # execute before commands
# EXEC_CMD_BIN="${ENV_EXEC_CMD_BIN:-$EXEC_CMD_BIN}" # command to execute
# EXEC_CMD_ARGS="${ENV_EXEC_CMD_ARGS:-$EXEC_CMD_ARGS}" # command arguments
# EXEC_CMD_NAME="$(basename "$EXEC_CMD_BIN")" # set the binary name
# ENV_USER_NAME="${user_name:-$ENV_USER_NAME}" #
# ENV_USER_PASS="${user_pass:-$ENV_USER_PASS}" #
# ENV_ROOT_USER_NAME="${root_user_name:-$ENV_ROOT_USER_NAME}" #
@@ -344,7 +374,8 @@ __run_start_script() {
local lc_type="${LC_ALL:-${LC_CTYPE:-$LANG}}"
local home="${workdir//\/root/\/tmp\/docker}"
local path="/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"
local sysname="${SERVER_NAME:-$HOSTNAME}" # set hostname
# set hostname
local sysname="${SERVER_NAME:-$HOSTNAME}"
local message=""
if [ -z "$cmd" ]; then
__post_execute 2>"/dev/stderr" |& tee -a "$LOG_DIR/init.txt" &>/dev/null
@@ -419,7 +450,7 @@ __pgrep() { __pcheck "${1:-$EXEC_CMD_BIN}" || __ps aux 2>/dev/null | grep -Fw "
# check if process is already running
__proc_check() {
cmd_bin="$(type -P "${1:-$EXEC_CMD_BIN}")"
cmd_name="$(basename "${cmd_bin:-$EXEC_CMD_NAME}")"
local _b="${cmd_bin:-$EXEC_CMD_NAME}"; cmd_name="${_b##*/}"
if __pgrep "$cmd_bin" || __pgrep "$cmd_name"; then
SERVICE_IS_RUNNING="true"
touch "$SERVICE_PID_FILE"
@@ -433,27 +464,46 @@ __proc_check() {
# Allow ENV_ variable - Import env file
__file_exists_with_content "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.sh" && . "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.sh"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SERVICE_EXIT_CODE=0 # default exit code
WORK_DIR="${ENV_WORKDIR:-$WORK_DIR}" # change to directory
WWW_DIR="${ENV_WWW_DIR:-$WWW_DIR}" # set default web dir
ETC_DIR="${ENV_ETC_DIR:-$ETC_DIR}" # set default etc dir
DATA_DIR="${ENV_DATA_DIR:-$DATA_DIR}" # set default data dir
CONF_DIR="${ENV_CONF_DIR:-$CONF_DIR}" # set default config dir
DATABASE_DIR="${ENV_DATABASE_DIR:-$DATABASE_DIR}" # set database dir
SERVICE_USER="${ENV_SERVICE_USER:-$SERVICE_USER}" # execute command as another user
SERVICE_UID="${ENV_SERVICE_UID:-$SERVICE_UID}" # set the user id
SERVICE_PORT="${ENV_SERVICE_PORT:-$SERVICE_PORT}" # port which service is listening on
PRE_EXEC_MESSAGE="${ENV_PRE_EXEC_MESSAGE:-$PRE_EXEC_MESSAGE}" # Show message before execute
# default exit code
SERVICE_EXIT_CODE=0
# change to directory
WORK_DIR="${ENV_WORKDIR:-$WORK_DIR}"
# set default web dir
WWW_DIR="${ENV_WWW_DIR:-$WWW_DIR}"
# set default etc dir
ETC_DIR="${ENV_ETC_DIR:-$ETC_DIR}"
# set default data dir
DATA_DIR="${ENV_DATA_DIR:-$DATA_DIR}"
# set default config dir
CONF_DIR="${ENV_CONF_DIR:-$CONF_DIR}"
# set database dir
DATABASE_DIR="${ENV_DATABASE_DIR:-$DATABASE_DIR}"
# execute command as another user
SERVICE_USER="${ENV_SERVICE_USER:-$SERVICE_USER}"
# set the user id
SERVICE_UID="${ENV_SERVICE_UID:-$SERVICE_UID}"
# port which service is listening on
SERVICE_PORT="${ENV_SERVICE_PORT:-$SERVICE_PORT}"
# Show message before execute
PRE_EXEC_MESSAGE="${ENV_PRE_EXEC_MESSAGE:-$PRE_EXEC_MESSAGE}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# application specific
EXEC_PRE_SCRIPT="${ENV_EXEC_PRE_SCRIPT:-$EXEC_PRE_SCRIPT}" # Pre
EXEC_CMD_BIN="${ENV_EXEC_CMD_BIN:-$EXEC_CMD_BIN}" # command to execute
EXEC_CMD_NAME="$(basename "$EXEC_CMD_BIN")" # set the binary name
SERVICE_PID_FILE="/run/init.d/$EXEC_CMD_NAME.pid" # set the pid file location
EXEC_CMD_ARGS="${ENV_EXEC_CMD_ARGS:-$EXEC_CMD_ARGS}" # command arguments
SERVICE_PID_NUMBER="$(__pgrep)" # check if running
EXEC_CMD_BIN="$(type -P "$EXEC_CMD_BIN" || echo "$EXEC_CMD_BIN")" # set full path
EXEC_PRE_SCRIPT="$(type -P "$EXEC_PRE_SCRIPT" || echo "$EXEC_PRE_SCRIPT")" # set full path
# Pre
EXEC_PRE_SCRIPT="${ENV_EXEC_PRE_SCRIPT:-$EXEC_PRE_SCRIPT}"
# command to execute
EXEC_CMD_BIN="${ENV_EXEC_CMD_BIN:-$EXEC_CMD_BIN}"
# set the binary name
EXEC_CMD_NAME="${EXEC_CMD_BIN##*/}"
# set the pid file location
SERVICE_PID_FILE="/run/init.d/$EXEC_CMD_NAME.pid"
# command arguments
EXEC_CMD_ARGS="${ENV_EXEC_CMD_ARGS:-$EXEC_CMD_ARGS}"
# check if running
SERVICE_PID_NUMBER="$(__pgrep)"
# set full path
EXEC_CMD_BIN="$(type -P "$EXEC_CMD_BIN" || echo "$EXEC_CMD_BIN")"
# set full path
EXEC_PRE_SCRIPT="$(type -P "$EXEC_PRE_SCRIPT" || echo "$EXEC_PRE_SCRIPT")"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# create auth directories
[ -n "$USER_FILE_PREFIX" ] && { [ -d "$USER_FILE_PREFIX" ] || mkdir -p "$USER_FILE_PREFIX"; }
+104 -54
View File
@@ -43,7 +43,7 @@ __script_exit() {
fi
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SCRIPT_NAME="$(basename "$0" 2>/dev/null)"
SCRIPT_NAME="${0##*/}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
export PATH="/usr/local/etc/docker/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -76,29 +76,40 @@ DATABASE_DIR="${DATABASE_DIR_NGINX:-/data/db/nginx}"
WWW_DIR="/usr/share/webapps/nginx"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Default predefined variables
DATA_DIR="/data" # set data directory
CONF_DIR="/config" # set config directory
# set data directory
DATA_DIR="/data"
# set config directory
CONF_DIR="/config"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# set the containers etc directory
ETC_DIR="/etc/nginx"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RUN_DIR="/run/init.d" # set scripts pid dir
LOG_DIR="/data/logs/nginx" # set log directory
# set scripts pid dir
RUN_DIR="/run/init.d"
# set log directory
LOG_DIR="/data/logs/nginx"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the working dir
WORK_DIR="" # set working directory
# set working directory
WORK_DIR=""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Where to save passwords to
ROOT_FILE_PREFIX="/config/secure/auth/root" # directory to save username/password for root user
USER_FILE_PREFIX="/config/secure/auth/user" # directory to save username/password for normal user
# directory to save username/password for root user
ROOT_FILE_PREFIX="/config/secure/auth/root"
# directory to save username/password for normal user
USER_FILE_PREFIX="/config/secure/auth/user"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# root/admin user info password/random]
root_user_name="${NGINX_ROOT_USER_NAME:-}" # root user name
root_user_pass="${NGINX_ROOT_PASS_WORD:-}" # root user password
# root user name
root_user_name="${NGINX_ROOT_USER_NAME:-}"
# root user password
root_user_pass="${NGINX_ROOT_PASS_WORD:-}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Normal user info [password/random]
user_name="${NGINX_USER_NAME:-}" # normal user name
user_pass="${NGINX_USER_PASS_WORD:-}" # normal user password
# normal user name
user_name="${NGINX_USER_NAME:-}"
# normal user password
user_pass="${NGINX_USER_PASS_WORD:-}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Overwrite variables from files
__file_exists_with_content "${USER_FILE_PREFIX}/${SERVICE_NAME}_name" && user_name="$(<"${USER_FILE_PREFIX}/${SERVICE_NAME}_name")"
@@ -110,11 +121,16 @@ __file_exists_with_content "${ROOT_FILE_PREFIX}/${SERVICE_NAME}_pass" && root_us
SERVICE_PORT="80"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# execute command variables
SERVICE_UID="0" # set the user id
SERVICE_USER="root" # execute command as another user
EXEC_CMD_BIN="nginx" # command to execute
EXEC_CMD_ARGS="-c $ETC_DIR/nginx.conf" # command arguments
EXEC_PRE_SCRIPT="" # execute script before
# set the user id
SERVICE_UID="0"
# execute command as another user
SERVICE_USER="root"
# command to execute
EXEC_CMD_BIN="nginx"
# command arguments
EXEC_CMD_ARGS="-c $ETC_DIR/nginx.conf"
# execute script before
EXEC_PRE_SCRIPT=""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Is this service a web server
IS_WEB_SERVER="yes"
@@ -140,10 +156,14 @@ CMD_ENV=""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# use this function to update config files - IE: change port
__update_conf_files() {
local exitCode=0 # default exit code
local user="${SERVICE_USER:-root}" # specifiy different user
local runas="root" # run as a different user
local sysname="${SERVER_NAME:-$HOSTNAME}" # set hostname
# default exit code
local exitCode=0
# specifiy different user
local user="${SERVICE_USER:-root}"
# run as a different user
local runas="root"
# set hostname
local sysname="${SERVER_NAME:-$HOSTNAME}"
# delete files
#__rm ""
@@ -202,10 +222,14 @@ __update_conf_files() {
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# function to run before executing
__pre_execute() {
local exitCode=0 # default exit code
local user="${SERVICE_USER:-root}" # specifiy different user
local runas="root" # run as a different user
local sysname="${SERVER_NAME:-$HOSTNAME}" # set hostname
# default exit code
local exitCode=0
# specifiy different user
local user="${SERVICE_USER:-root}"
# run as a different user
local runas="root"
# set hostname
local sysname="${SERVER_NAME:-$HOSTNAME}"
# define commands
@@ -232,12 +256,18 @@ __pre_execute() {
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# function to run after executing
__post_execute() {
local exitCode=0 # default exit code
local user="${SERVICE_USER:-root}" # specifiy different user
local runas="root" # run as a different user
local sysname="${SERVER_NAME:-$HOSTNAME}" # set hostname
sleep 60 # how long to wait before executing
echo "Running post commands" # message
# default exit code
local exitCode=0
# specifiy different user
local user="${SERVICE_USER:-root}"
# run as a different user
local runas="root"
# set hostname
local sysname="${SERVER_NAME:-$HOSTNAME}"
# how long to wait before executing
sleep 60
# message
echo "Running post commands"
# execute commands
return $exitCode
@@ -257,7 +287,8 @@ __pre_message() {
# use this function to setup ssl support
__update_ssl_conf() {
local exitCode=0
local sysname="${SERVER_NAME:-$HOSTNAME}" # set hostname
# set hostname
local sysname="${SERVER_NAME:-$HOSTNAME}"
return $exitCode
}
@@ -276,7 +307,6 @@ __create_service_env() {
# EXEC_PRE_SCRIPT="${ENV_EXEC_PRE_SCRIPT:-$EXEC_PRE_SCRIPT}" # execute before commands
# EXEC_CMD_BIN="${ENV_EXEC_CMD_BIN:-$EXEC_CMD_BIN}" # command to execute
# EXEC_CMD_ARGS="${ENV_EXEC_CMD_ARGS:-$EXEC_CMD_ARGS}" # command arguments
# EXEC_CMD_NAME="$(basename "$EXEC_CMD_BIN")" # set the binary name
# ENV_USER_NAME="${user_name:-$ENV_USER_NAME}" #
# ENV_USER_PASS="${user_pass:-$ENV_USER_PASS}" #
# ENV_ROOT_USER_NAME="${root_user_name:-$ENV_ROOT_USER_NAME}" #
@@ -297,7 +327,8 @@ __run_start_script() {
local lc_type="${LC_ALL:-${LC_CTYPE:-$LANG}}"
local home="${workdir//\/root/\/tmp\/docker}"
local path="/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"
local sysname="${SERVER_NAME:-$HOSTNAME}" # set hostname
# set hostname
local sysname="${SERVER_NAME:-$HOSTNAME}"
local message=""
if [ -z "$cmd" ]; then
__post_execute 2>"/dev/stderr" |& tee -a "$LOG_DIR/init.txt" &>/dev/null
@@ -372,7 +403,7 @@ __pgrep() { __pcheck "${1:-$EXEC_CMD_BIN}" || __ps aux 2>/dev/null | grep -Fw "
# check if process is already running
__proc_check() {
cmd_bin="$(type -P "${1:-$EXEC_CMD_BIN}")"
cmd_name="$(basename "${cmd_bin:-$EXEC_CMD_NAME}")"
local _b="${cmd_bin:-$EXEC_CMD_NAME}"; cmd_name="${_b##*/}"
if __pgrep "$cmd_bin" || __pgrep "$cmd_name"; then
SERVICE_IS_RUNNING="true"
touch "$SERVICE_PID_FILE"
@@ -386,27 +417,46 @@ __proc_check() {
# Allow ENV_ variable - Import env file
__file_exists_with_content "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.sh" && . "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.sh"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SERVICE_EXIT_CODE=0 # default exit code
WORK_DIR="${ENV_WORKDIR:-$WORK_DIR}" # change to directory
WWW_DIR="${ENV_WWW_DIR:-$WWW_DIR}" # set default web dir
ETC_DIR="${ENV_ETC_DIR:-$ETC_DIR}" # set default etc dir
DATA_DIR="${ENV_DATA_DIR:-$DATA_DIR}" # set default data dir
CONF_DIR="${ENV_CONF_DIR:-$CONF_DIR}" # set default config dir
DATABASE_DIR="${ENV_DATABASE_DIR:-$DATABASE_DIR}" # set database dir
SERVICE_USER="${ENV_SERVICE_USER:-$SERVICE_USER}" # execute command as another user
SERVICE_UID="${ENV_SERVICE_UID:-$SERVICE_UID}" # set the user id
SERVICE_PORT="${ENV_SERVICE_PORT:-$SERVICE_PORT}" # port which service is listening on
PRE_EXEC_MESSAGE="${ENV_PRE_EXEC_MESSAGE:-$PRE_EXEC_MESSAGE}" # Show message before execute
# default exit code
SERVICE_EXIT_CODE=0
# change to directory
WORK_DIR="${ENV_WORKDIR:-$WORK_DIR}"
# set default web dir
WWW_DIR="${ENV_WWW_DIR:-$WWW_DIR}"
# set default etc dir
ETC_DIR="${ENV_ETC_DIR:-$ETC_DIR}"
# set default data dir
DATA_DIR="${ENV_DATA_DIR:-$DATA_DIR}"
# set default config dir
CONF_DIR="${ENV_CONF_DIR:-$CONF_DIR}"
# set database dir
DATABASE_DIR="${ENV_DATABASE_DIR:-$DATABASE_DIR}"
# execute command as another user
SERVICE_USER="${ENV_SERVICE_USER:-$SERVICE_USER}"
# set the user id
SERVICE_UID="${ENV_SERVICE_UID:-$SERVICE_UID}"
# port which service is listening on
SERVICE_PORT="${ENV_SERVICE_PORT:-$SERVICE_PORT}"
# Show message before execute
PRE_EXEC_MESSAGE="${ENV_PRE_EXEC_MESSAGE:-$PRE_EXEC_MESSAGE}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# application specific
EXEC_PRE_SCRIPT="${ENV_EXEC_PRE_SCRIPT:-$EXEC_PRE_SCRIPT}" # Pre
EXEC_CMD_BIN="${ENV_EXEC_CMD_BIN:-$EXEC_CMD_BIN}" # command to execute
EXEC_CMD_NAME="$(basename "$EXEC_CMD_BIN")" # set the binary name
SERVICE_PID_FILE="/run/init.d/$EXEC_CMD_NAME.pid" # set the pid file location
EXEC_CMD_ARGS="${ENV_EXEC_CMD_ARGS:-$EXEC_CMD_ARGS}" # command arguments
SERVICE_PID_NUMBER="$(__pgrep)" # check if running
EXEC_CMD_BIN="$(type -P "$EXEC_CMD_BIN" || echo "$EXEC_CMD_BIN")" # set full path
EXEC_PRE_SCRIPT="$(type -P "$EXEC_PRE_SCRIPT" || echo "$EXEC_PRE_SCRIPT")" # set full path
# Pre
EXEC_PRE_SCRIPT="${ENV_EXEC_PRE_SCRIPT:-$EXEC_PRE_SCRIPT}"
# command to execute
EXEC_CMD_BIN="${ENV_EXEC_CMD_BIN:-$EXEC_CMD_BIN}"
# set the binary name
EXEC_CMD_NAME="${EXEC_CMD_BIN##*/}"
# set the pid file location
SERVICE_PID_FILE="/run/init.d/$EXEC_CMD_NAME.pid"
# command arguments
EXEC_CMD_ARGS="${ENV_EXEC_CMD_ARGS:-$EXEC_CMD_ARGS}"
# check if running
SERVICE_PID_NUMBER="$(__pgrep)"
# set full path
EXEC_CMD_BIN="$(type -P "$EXEC_CMD_BIN" || echo "$EXEC_CMD_BIN")"
# set full path
EXEC_PRE_SCRIPT="$(type -P "$EXEC_PRE_SCRIPT" || echo "$EXEC_PRE_SCRIPT")"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# create auth directories
[ -n "$USER_FILE_PREFIX" ] && { [ -d "$USER_FILE_PREFIX" ] || mkdir -p "$USER_FILE_PREFIX"; }