mirror of
https://github.com/casjaysdevdocker/inn
synced 2026-06-24 14:01:04 -04:00
♻️ Migrate inn to /config/ source-of-truth architecture ♻️
Migrate inn 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; remove template-files copy block
- rootfs/usr/local/etc/docker/functions/entrypoint.sh: update to latest template with __init_service_conf, __find_php_ini, __find_php_bin helpers
- rootfs/usr/local/etc/docker/init.d/*.sh: fix $(basename) UUOC → ${var##*/}; move inline comments above code lines; remove commented-out dead code
- rootfs/usr/local/share/template-files/: delete entire directory; config files now deployed via /tmp/etc/ at build time
rootfs/root/docker/setup/03-files.sh
rootfs/usr/local/etc/docker/functions/entrypoint.sh
rootfs/usr/local/etc/docker/init.d/inn.sh
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/data/.gitkeep
rootfs/usr/local/share/template-files/defaults/.gitkeep
This commit is contained in:
@@ -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"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
@@ -91,49 +91,68 @@ DATABASE_DIR="${DATABASE_DIR_INN:-/data/db/sqlite}"
|
||||
WWW_ROOT_DIR="/usr/local/share/httpd/default"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Default predefined variables
|
||||
DATA_DIR="/data/news" # set data directory
|
||||
CONF_DIR="/config/news" # set config directory
|
||||
# set data directory
|
||||
DATA_DIR="/data/news"
|
||||
# set config directory
|
||||
CONF_DIR="/config/news"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# set the containers etc directory
|
||||
ETC_DIR="/etc/news"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
TMP_DIR="/tmp/news"
|
||||
RUN_DIR="/run/news" # set scripts pid dir
|
||||
LOG_DIR="/data/logs/news" # set log directory
|
||||
# set scripts pid dir
|
||||
RUN_DIR="/run/news"
|
||||
# set log directory
|
||||
LOG_DIR="/data/logs/news"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# 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="${INN_ROOT_USER_NAME:-}" # root user name
|
||||
root_user_pass="${INN_ROOT_PASS_WORD:-}" # root user password
|
||||
# root user name
|
||||
root_user_name="${INN_ROOT_USER_NAME:-}"
|
||||
# root user password
|
||||
root_user_pass="${INN_ROOT_PASS_WORD:-}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Normal user info [password/random]
|
||||
user_name="${INN_USER_NAME:-}" # normal user name
|
||||
user_pass="${INN_USER_PASS_WORD:-}" # normal user password
|
||||
# normal user name
|
||||
user_name="${INN_USER_NAME:-}"
|
||||
# normal user password
|
||||
user_pass="${INN_USER_PASS_WORD:-}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# port which service is listening on
|
||||
SERVICE_PORT="119"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# User to use to launch service - IE: postgres
|
||||
RUNAS_USER="root" # normally root
|
||||
# normally root
|
||||
RUNAS_USER="root"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# User and group in which the service switches to - IE: nginx,apache,mysql,postgres
|
||||
SERVICE_USER="news" # execute command as another user
|
||||
SERVICE_GROUP="news" # Set the service group
|
||||
# execute command as another user
|
||||
SERVICE_USER="news"
|
||||
# Set the service group
|
||||
SERVICE_GROUP="news"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set user and group ID
|
||||
SERVICE_UID="0" # set the user id
|
||||
SERVICE_GID="0" # set the group id
|
||||
# set the user id
|
||||
SERVICE_UID="0"
|
||||
# set the group id
|
||||
SERVICE_GID="0"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# execute command variables - keep single quotes variables will be expanded later
|
||||
EXEC_CMD_BIN='nnrpd' # command to execute
|
||||
EXEC_CMD_ARGS='-D -p 119 -S' # command arguments
|
||||
EXEC_PRE_SCRIPT='' # execute script before
|
||||
# command to execute
|
||||
EXEC_CMD_BIN='nnrpd'
|
||||
# command arguments
|
||||
EXEC_CMD_ARGS='-D -p 119 -S'
|
||||
# execute script before
|
||||
EXEC_PRE_SCRIPT=''
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Is this service a web server
|
||||
IS_WEB_SERVER="no"
|
||||
@@ -142,8 +161,10 @@ IS_WEB_SERVER="no"
|
||||
IS_DATABASE_SERVICE="no"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Load variables from config
|
||||
[ -f "$CONF_DIR/env/inn.script.sh" ] && . "$CONF_DIR/env/inn.script.sh" # Generated by my dockermgr script
|
||||
[ -f "$CONF_DIR/env/inn.sh" ] && . "$CONF_DIR/env/inn.sh" # Overwrite the variabes
|
||||
# Generated by my dockermgr script
|
||||
[ -f "$CONF_DIR/env/inn.script.sh" ] && . "$CONF_DIR/env/inn.script.sh"
|
||||
# Overwrite the variabes
|
||||
[ -f "$CONF_DIR/env/inn.sh" ] && . "$CONF_DIR/env/inn.sh"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Additional predefined variables
|
||||
|
||||
@@ -175,11 +196,14 @@ CMD_ENV=""
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# use this function to update config files - IE: change port
|
||||
__update_conf_files() {
|
||||
local exitCode=0 # default exit code
|
||||
local sysname="${SERVER_NAME:-${FULL_DOMAIN_NAME:-$HOSTNAME}}" # set hostname
|
||||
# default exit code
|
||||
local exitCode=0
|
||||
# set hostname
|
||||
local sysname="${SERVER_NAME:-${FULL_DOMAIN_NAME:-$HOSTNAME}}"
|
||||
|
||||
# CD into temp to bybass any permission errors
|
||||
cd /tmp || false # lets keep shellcheck happy by adding false
|
||||
# lets keep shellcheck happy by adding false
|
||||
cd /tmp || false
|
||||
|
||||
# delete files
|
||||
#__rm ""
|
||||
@@ -215,8 +239,10 @@ __update_conf_files() {
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# function to run before executing
|
||||
__pre_execute() {
|
||||
local exitCode=0 # default exit code
|
||||
local sysname="${SERVER_NAME:-${FULL_DOMAIN_NAME:-$HOSTNAME}}" # set hostname
|
||||
# default exit code
|
||||
local exitCode=0
|
||||
# set hostname
|
||||
local sysname="${SERVER_NAME:-${FULL_DOMAIN_NAME:-$HOSTNAME}}"
|
||||
|
||||
# define commands
|
||||
|
||||
@@ -261,11 +287,15 @@ __pre_execute() {
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# function to run after executing
|
||||
__post_execute() {
|
||||
local exitCode=0 # default exit code
|
||||
local sysname="${SERVER_NAME:-${FULL_DOMAIN_NAME:-$HOSTNAME}}" # set hostname
|
||||
# default exit code
|
||||
local exitCode=0
|
||||
# set hostname
|
||||
local sysname="${SERVER_NAME:-${FULL_DOMAIN_NAME:-$HOSTNAME}}"
|
||||
|
||||
sleep 60 # how long to wait before executing
|
||||
echo "Running post commands" # message
|
||||
# how long to wait before executing
|
||||
sleep 60
|
||||
# message
|
||||
echo "Running post commands"
|
||||
# execute commands
|
||||
(
|
||||
sleep 20
|
||||
@@ -289,7 +319,8 @@ __pre_message() {
|
||||
# use this function to setup ssl support
|
||||
__update_ssl_conf() {
|
||||
local exitCode=0
|
||||
local sysname="${SERVER_NAME:-${FULL_DOMAIN_NAME:-$HOSTNAME}}" # set hostname
|
||||
# set hostname
|
||||
local sysname="${SERVER_NAME:-${FULL_DOMAIN_NAME:-$HOSTNAME}}"
|
||||
|
||||
return $exitCode
|
||||
}
|
||||
@@ -316,17 +347,28 @@ EOF
|
||||
# script to start server
|
||||
__run_start_script() {
|
||||
local runExitCode=0
|
||||
local workdir="$(eval echo "${WORK_DIR:-}")" # expand variables
|
||||
local cmd="$(eval echo "${EXEC_CMD_BIN:-}")" # expand variables
|
||||
local args="$(eval echo "${EXEC_CMD_ARGS:-}")" # expand variables
|
||||
local name="$(eval echo "${EXEC_CMD_NAME:-}")" # expand variables
|
||||
local pre="$(eval echo "${EXEC_PRE_SCRIPT:-}")" # expand variables
|
||||
local extra_env="$(eval echo "${CMD_ENV//,/ }")" # expand variables
|
||||
local lc_type="$(eval echo "${LANG:-${LC_ALL:-$LC_CTYPE}}")" # expand variables
|
||||
local home="$(eval echo "${workdir//\/root/\/tmp\/docker}")" # expand variables
|
||||
local path="$(eval echo "$PATH")" # expand variables
|
||||
local message="$(eval echo "")" # expand variables
|
||||
local sysname="${SERVER_NAME:-${FULL_DOMAIN_NAME:-$HOSTNAME}}" # set hostname
|
||||
# expand variables
|
||||
local workdir="$(eval echo "${WORK_DIR:-}")"
|
||||
# expand variables
|
||||
local cmd="$(eval echo "${EXEC_CMD_BIN:-}")"
|
||||
# expand variables
|
||||
local args="$(eval echo "${EXEC_CMD_ARGS:-}")"
|
||||
# expand variables
|
||||
local name="$(eval echo "${EXEC_CMD_NAME:-}")"
|
||||
# expand variables
|
||||
local pre="$(eval echo "${EXEC_PRE_SCRIPT:-}")"
|
||||
# expand variables
|
||||
local extra_env="$(eval echo "${CMD_ENV//,/ }")"
|
||||
# expand variables
|
||||
local lc_type="$(eval echo "${LANG:-${LC_ALL:-$LC_CTYPE}}")"
|
||||
# expand variables
|
||||
local home="$(eval echo "${workdir//\/root/\/tmp\/docker}")"
|
||||
# expand variables
|
||||
local path="$(eval echo "$PATH")"
|
||||
# expand variables
|
||||
local message="$(eval echo "")"
|
||||
# set hostname
|
||||
local sysname="${SERVER_NAME:-${FULL_DOMAIN_NAME:-$HOSTNAME}}"
|
||||
[ -f "$CONF_DIR/$SERVICE_NAME.exec_cmd.sh" ] && . "$CONF_DIR/$SERVICE_NAME.exec_cmd.sh"
|
||||
if [ -z "$cmd" ]; then
|
||||
__post_execute 2>"/dev/stderr" |& tee -p -a "$LOG_DIR/init.txt" &>/dev/null
|
||||
@@ -411,7 +453,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"
|
||||
@@ -425,13 +467,19 @@ __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
|
||||
# default exit code
|
||||
SERVICE_EXIT_CODE=0
|
||||
# application specific
|
||||
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
|
||||
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
|
||||
# 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"
|
||||
# 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"; }
|
||||
|
||||
Reference in New Issue
Block a user