mirror of
https://github.com/casjaysdevdocker/bind
synced 2025-11-04 13:02:16 -05:00
🗃️ Update codebase 🗃️
detect_and_update_services.sh enhanced_functions.sh rootfs/usr/local/bin/entrypoint.sh rootfs/usr/local/etc/docker/functions/entrypoint.sh test_solution.sh
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck shell=bash
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
##@Version : 202407241259-git
|
||||
# @@Author : Jason Hempstead
|
||||
# @@Contact : git-admin@casjaysdev.pro
|
||||
@@ -17,15 +17,15 @@
|
||||
# @@Terminal App : no
|
||||
# @@sudo/root : no
|
||||
# @@Template : functions/docker-entrypoint
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# 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
|
||||
[ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
|
||||
{ [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; } && echo "Enabling debugging" && set -xo pipefail -x$DEBUGGER_OPTIONS && export DEBUGGER="on" || set -o pipefail
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
[ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || true
|
||||
{ [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; } && set -xo pipefail -x$DEBUGGER_OPTIONS && export DEBUGGER="on" || set -o pipefail
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__remove_extra_spaces() { sed 's/\( \)*/\1/g;s|^ ||g'; }
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__printf_space() {
|
||||
local pad=$(printf '%0.1s' " "{1..60})
|
||||
local padlength=$1
|
||||
@@ -37,7 +37,7 @@ __printf_space() {
|
||||
message+="$(printf '%s\n' "$string2") "
|
||||
printf '%s\n' "$message"
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__rm() { [ -n "$1" ] && [ -e "$1" ] && rm -Rf "${1:?}"; }
|
||||
__grep_test() { grep -sh "$1" "$2" | grep -qwF "${3:-$1}" || return 1; }
|
||||
__netstat() { [ -f "$(type -P netstat)" ] && netstat "$@" || return 10; }
|
||||
@@ -52,7 +52,8 @@ __ps() { [ -f "$(type -P ps)" ] && ps "$@" 2>/dev/null | sed 's|:||g' | grep -Fw
|
||||
__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 -w 'inet6' | awk '{print $2}' | grep -vE '^::1|^fe' | sed 's|/.*||g' | head -n1 | grep '.' || echo ''; }
|
||||
__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_and_remove() { find "${2:-/etc}" -iname "$1" -exec rm -Rfv {} \; 2>/dev/null; }
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__pgrep() {
|
||||
local count=3
|
||||
local srvc="${1:-SERVICE_NAME}"
|
||||
@@ -64,28 +65,28 @@ __pgrep() {
|
||||
done
|
||||
return 10
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__find_file_relative() {
|
||||
[ -e "$1" ] || return 0
|
||||
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() {
|
||||
[ -d "$1" ] || return 0
|
||||
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() {
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__pid_exists() {
|
||||
local result=""
|
||||
result="$(ps -ax --no-header 2>/dev/null | sed 's/^[[:space:]]*//g' | awk -F' ' '{print $1}' | sed 's|:||g' | grep '[0-9]' | sort -uV | grep "^$1$" 2>/dev/null || echo '')"
|
||||
[ -n "$result" ] && return 0 || return 1
|
||||
}
|
||||
__is_running() {
|
||||
__is_running() {
|
||||
local result=""
|
||||
result="$(ps -eo args --no-header 2>/dev/null | awk '{print $1,$2,$3}' | sed 's|:||g' | sort -u | grep -vE 'grep|COMMAND|awk|tee|ps|sed|sort|tail' | grep "$1" | grep "${2:-^}" 2>/dev/null || echo '')"
|
||||
[ -n "$result" ] && return 0 || return 1
|
||||
}
|
||||
__get_pid() {
|
||||
__get_pid() {
|
||||
local result=""
|
||||
result="$(ps -ax --no-header 2>/dev/null | sed 's/^[[:space:]]*//g;s|;||g;s|:||g' | awk '{print $1,$5}' | sed 's|:||g' | grep "$1$" | grep -v 'grep' | awk -F' ' '{print $1}' | grep '[0-9]' | sort -uV | head -n1 | grep '.' 2>/dev/null || echo '')"
|
||||
if [ -n "$result" ]; then
|
||||
@@ -95,9 +96,9 @@ __get_pid() {
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__format_variables() { printf '%s\n' "${@//,/ }" | tr ' ' '\n' | sort -RVu | grep -v '^$' | tr '\n' ' ' | __clean_variables | grep '.' || return 0; }
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__clean_variables() {
|
||||
local var="$*"
|
||||
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
|
||||
@@ -105,7 +106,7 @@ __clean_variables() {
|
||||
var="$(printf '%s\n' "$var" | sed 's/\( \)*/\1/g;s|^ ||g')"
|
||||
printf '%s' "$var" | grep -v '^$'
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__no_exit() {
|
||||
local monitor_interval="${SERVICE_MONITOR_INTERVAL:-60}"
|
||||
local failure_threshold="${SERVICE_FAILURE_THRESHOLD:-3}"
|
||||
@@ -145,7 +146,7 @@ __no_exit() {
|
||||
wait
|
||||
"
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__trim() {
|
||||
local var="${*//;/ }"
|
||||
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
|
||||
@@ -153,14 +154,14 @@ __trim() {
|
||||
var="$(echo "$var" | __remove_extra_spaces | sed "s| |; |g;s|;$| |g" | __remove_extra_spaces)"
|
||||
printf '%s' "$var" | sed 's|;||g' | grep -v '^$'
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__banner() {
|
||||
local message="$*"
|
||||
local total_width=80
|
||||
local content_width=$((total_width - 14)) # Account for "# - - - " and " - - - #"
|
||||
printf '# - - - %-*s - - - #\n' "$content_width" "$message"
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__service_banner() {
|
||||
local icon="${1:-🔧}"
|
||||
local message="${2:-Processing}"
|
||||
@@ -172,23 +173,23 @@ __service_banner() {
|
||||
local text_width=$((content_width - icon_width * 2 - 2)) # Account for both icons and spaces
|
||||
printf '# - - - %s %-*s %s - - - #\n' "$icon" "$text_width" "$full_message" "$icon"
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__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 '.' || 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 '.' || 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 '.' || 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 '.' || 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_mongodb_conf() { return; }
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__random_password() { cat "/dev/urandom" | tr -dc '0-9a-zA-Z' | head -c${1:-16} && echo ""; }
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__init_working_dir() {
|
||||
local service_name="$SERVICE_NAME" # get service name
|
||||
local workdir="$(eval echo "${WORK_DIR:-}")" # expand variables
|
||||
@@ -206,15 +207,15 @@ __init_working_dir() {
|
||||
[ -n "$workdir" ] && { [ -d "$workdir" ] || mkdir -p "$workdir"; }
|
||||
[ "$SERVICE_USER" = "root" ] || [ -d "$home" ] && chmod -f 777 "$home"
|
||||
[ "$SERVICE_USER" = "root" ] || [ -d "$workdir" ] && chmod -f 777 "$workdir"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# cd to dir
|
||||
__cd "${workdir:-$home}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
echo "Setting the working directory to: $PWD"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
export WORK_DIR="$workdir" HOME="$home"
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__exec_service() {
|
||||
local count=6
|
||||
echo "Starting $1"
|
||||
@@ -224,7 +225,7 @@ __exec_service() {
|
||||
__pgrep $1 && touch "/run/init.d/$1.pid" && break || count=$((count - 1))
|
||||
done
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__update_ssl_certs() {
|
||||
[ -f "/config/env/ssl.sh" ] && . "/config/env/ssl.sh"
|
||||
if [ -f "$SSL_CERT" ] && [ -f "$SSL_KEY" ]; then
|
||||
@@ -234,7 +235,7 @@ __update_ssl_certs() {
|
||||
[ -f "$SSL_CERT" ] && cp -Rf "$SSL_CERT" "/etc/ssl/$SSL_CERT"
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__certbot() {
|
||||
[ -n "$(type -P 'certbot')" ] || return 1
|
||||
local options="$1"
|
||||
@@ -295,7 +296,7 @@ __certbot() {
|
||||
[ $statusCode -eq 0 ] && __update_ssl_certs
|
||||
return $statusCode
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__display_user_info() {
|
||||
if [ -n "$user_name" ] || [ -n "$user_pass" ] || [ -n "$root_user_name" ] || [ -n "$root_user_pass" ]; then
|
||||
__banner "User info"
|
||||
@@ -306,7 +307,7 @@ __display_user_info() {
|
||||
__banner ""
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__init_config_etc() {
|
||||
local copy="no"
|
||||
local name="$(find "/etc/$SERVICE_NAME" -maxdepth 0 2>/dev/null | head -n1)"
|
||||
@@ -321,7 +322,7 @@ __init_config_etc() {
|
||||
__copy_templates "$etc_dir" "$conf_dir"
|
||||
fi
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
}
|
||||
__create_ssl_cert() {
|
||||
local SSL_DIR="${SSL_DIR:-/etc/ssl}"
|
||||
@@ -353,7 +354,7 @@ __create_ssl_cert() {
|
||||
return 2
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__init_apache() {
|
||||
local etc_dir="" conf_dir="" conf_dir="" www_dir="" apache_bin=""
|
||||
etc_dir="/etc/${1:-apache2}"
|
||||
@@ -363,7 +364,7 @@ __init_apache() {
|
||||
#
|
||||
return 0
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__init_nginx() {
|
||||
local etc_dir="/etc/${1:-nginx}"
|
||||
local conf_dir="/config/${1:-nginx}"
|
||||
@@ -371,14 +372,14 @@ __init_nginx() {
|
||||
local nginx_bin="$(type -P 'nginx')"
|
||||
return 0
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__init_php() {
|
||||
local etc_dir="/etc/${1:-php}"
|
||||
local conf_dir="/config/${1:-php}"
|
||||
local php_bin="${PHP_BIN_DIR:-$(__find_php_bin)}"
|
||||
return 0
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__init_mysql() {
|
||||
local db_dir="/data/db/mysql"
|
||||
local etc_dir="${home:-/etc/${1:-mysql}}"
|
||||
@@ -391,28 +392,28 @@ __init_mysql() {
|
||||
local mysqld_bin="$(type -P 'mysqld')"
|
||||
return 0
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__init_mongodb() {
|
||||
local home="${MONGODB_CONFIG_FILE:-$(__find_mongodb_conf)}"
|
||||
local user_name="${INITDB_ROOT_USERNAME:-root}"
|
||||
local user_pass="${MONGO_INITDB_ROOT_PASSWORD:-$_ROOT_PASSWORD}"
|
||||
return
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__init_postgres() {
|
||||
local home="${PGSQL_CONFIG_FILE:-$(__find_pgsql_conf)}"
|
||||
local user_name="${POSTGRES_USER:-root}"
|
||||
local user_pass="${POSTGRES_PASSWORD:-$POSTGRES_ROOT_PASSWORD}"
|
||||
return
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__init_couchdb() {
|
||||
local home="${COUCHDB_CONFIG_FILE:-$(__find_couchdb_conf)}"
|
||||
local user_name="${COUCHDB_USER:-root}"
|
||||
local user_pass="${COUCHDB_PASSWORD:-$SET_RANDOM_PASS}"
|
||||
return
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Show available init functions
|
||||
__init_help() {
|
||||
echo '
|
||||
@@ -422,7 +423,7 @@ __create_ssl_cert
|
||||
'
|
||||
return
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__run_once() {
|
||||
if [ "$CONFIG_DIR_INITIALIZED" = "false" ] || [ "$DATA_DIR_INITIALIZED" = "false" ] || [ ! -f "/config/.docker_has_run" ]; then
|
||||
return 0
|
||||
@@ -430,7 +431,7 @@ __run_once() {
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# run program ever n minutes
|
||||
__cron() {
|
||||
trap 'retVal=$?;[ -f "/run/cron/$bin.run" ] && rm -Rf "/run/cron/$bin.run";[ -f "/run/cron/$bin.pid" ] && rm -Rf "/run/cron/$bin.pid";exit ${retVal:-0}' SIGINT ERR EXIT
|
||||
@@ -449,19 +450,19 @@ __cron() {
|
||||
[ -f "/run/cron/$bin.run" ] || break
|
||||
done 2>/dev/stderr >>"/data/logs/cron.log"
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__replace() {
|
||||
local search="$1" replace="$2" file="${3:-$2}"
|
||||
[ -e "$file" ] || return 1
|
||||
__sed "$search" "$replace" "$file" || return 0
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__find_replace() {
|
||||
local search="$1" replace="$2" file="${3:-$2}"
|
||||
[ -e "$file" ] || return 1
|
||||
find "$file" -type f -not -path '.git*' -exec sed -i "s|$search|$replace|g" {} \; 2>/dev/null
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# /config > /etc
|
||||
__copy_templates() {
|
||||
local from="$1" to="$2"
|
||||
@@ -471,7 +472,7 @@ __copy_templates() {
|
||||
__file_copy "$from" "$to"
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# /config/file > /etc/file
|
||||
__symlink() {
|
||||
local from="$1" to="$2"
|
||||
@@ -480,7 +481,7 @@ __symlink() {
|
||||
ln -sf "$to" "$from" && echo "Created symlink to $from > $to"
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__file_copy() {
|
||||
local from="$1"
|
||||
local dest="$2"
|
||||
@@ -510,7 +511,7 @@ __file_copy() {
|
||||
fi
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__generate_random_uids() {
|
||||
local set_random_uid="$(seq 100 999 | sort -R | head -n 1)"
|
||||
while :; do
|
||||
@@ -522,7 +523,7 @@ __generate_random_uids() {
|
||||
fi
|
||||
done
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__setup_directories() {
|
||||
APPLICATION_DIRS="${APPLICATION_DIRS//,/ }"
|
||||
APPLICATION_FILES="${APPLICATION_FILES//,/ }"
|
||||
@@ -555,7 +556,7 @@ __setup_directories() {
|
||||
fi
|
||||
done
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# set user on files/folders
|
||||
__fix_permissions() {
|
||||
change_user="${1:-${SERVICE_USER:-root}}"
|
||||
@@ -580,14 +581,14 @@ __fix_permissions() {
|
||||
fi
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__get_gid() { grep "^$1:" /etc/group | 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 -q "^$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 -q "^$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
|
||||
__proc_check() {
|
||||
cmd_bin="$(type -P "${1:-$EXEC_CMD_BIN}")"
|
||||
@@ -601,7 +602,7 @@ __proc_check() {
|
||||
fi
|
||||
}
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__set_user_group_id() {
|
||||
local exitStatus=0
|
||||
local set_user="${1:-$SERVICE_USER}"
|
||||
@@ -614,16 +615,16 @@ __set_user_group_id() {
|
||||
[ -n "$set_user" ] && [ "$set_user" != "root" ] || return
|
||||
if grep -shq "^$set_user:" "/etc/passwd" "/etc/group"; 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
|
||||
fi
|
||||
if __check_for_uid "$set_uid"; then
|
||||
usermod -u "${set_uid}" -g "${set_gid}" $set_user 2>/dev/stderr | tee -p -a "/data/logs/init.txt" >/dev/null && chown -Rf $set_uid:$set_gid
|
||||
usermod -u "${set_uid}" -g "${set_gid}" $set_user 2>/dev/stderr | tee -p -a "/data/logs/init.txt" >/dev/null
|
||||
fi
|
||||
fi
|
||||
export SERVICE_UID="$set_uid"
|
||||
export SERVICE_GID="$set_gid"
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__create_service_user() {
|
||||
local exitStatus=0
|
||||
local create_user="${1:-$SERVICE_USER}"
|
||||
@@ -634,7 +635,9 @@ __create_service_user() {
|
||||
local random_id="$(__generate_random_uids)"
|
||||
local create_home_dir="${create_home_dir:-/home/$create_user}"
|
||||
grep -shq "^$create_user:" "/etc/passwd" && grep -shq "^$create_group:" "/etc/group" && return
|
||||
[ "$create_user" = "root" ] && [ "$create_group" = "root" ] && return 0
|
||||
if [ "$create_user" = "root" ] && [ "$create_group" = "root" ]; then
|
||||
return 0
|
||||
fi
|
||||
if [ "$RUNAS_USER" != "root" ] && [ "$RUNAS_USER" != "" ]; then
|
||||
create_user="$RUNAS_USER"
|
||||
create_group="$RUNAS_USER"
|
||||
@@ -653,17 +656,17 @@ __create_service_user() {
|
||||
break
|
||||
fi
|
||||
done
|
||||
if ! __check_for_group "$create_group"; then
|
||||
if [ -n "$create_group" ] && ! __check_for_group "$create_group"; then
|
||||
echo "creating system group $create_group"
|
||||
groupadd --force --system -g $create_gid $create_group 2>/dev/stderr | tee -p -a "/data/logs/init.txt" >/dev/null
|
||||
groupadd --force --system -g $create_gid $create_group 2>/dev/stderr | tee -a "/data/logs/init.txt" >/dev/null
|
||||
grep -shq "$create_group" "/etc/group" || exitStatus=$((exitStatus + 1))
|
||||
fi
|
||||
if ! __check_for_user "$create_user"; then
|
||||
if [ -n "$create_user" ] && ! __check_for_user "$create_user"; then
|
||||
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 --uid $create_uid --gid $create_group --comment "Account for $create_user" --home-dir "$create_home_dir" --shell /bin/false $create_user 2>/dev/stderr | tee -a "/data/logs/init.txt" >/dev/null
|
||||
grep -shq "$create_user" "/etc/passwd" || exitStatus=$((exitStatus + 1))
|
||||
fi
|
||||
grep -shq "$create_group" "/etc/group" || exitStatus=$((exitStatus + 1))
|
||||
grep -shq "$create_user" "/etc/passwd" || exitStatus=$((exitCode + 1))
|
||||
if [ $exitStatus -eq 0 ]; then
|
||||
if [ $exitStatus -eq 0 ] && [ -n "$create_group" ] && [ -n "$create_user" ]; then
|
||||
export WORK_DIR="${create_home_dir:-}"
|
||||
if [ -n "$WORK_DIR" ]; then
|
||||
[ -d "$WORK_DIR" ] || mkdir -p "$WORK_DIR"
|
||||
@@ -674,20 +677,22 @@ __create_service_user() {
|
||||
elif [ -f "/etc/sudoers" ] && ! grep -qs "$create_user" "/etc/sudoers"; then
|
||||
echo "$create_user ALL=(ALL) NOPASSWD: ALL" >"/etc/sudoers"
|
||||
fi
|
||||
export SERVICE_UID="$create_uid"
|
||||
export SERVICE_GID="$create_gid"
|
||||
export SERVICE_USER="$create_user"
|
||||
export SERVICE_GROUP="$create_group"
|
||||
exitStatus=0
|
||||
SERVICE_UID="$create_uid"
|
||||
SERVICE_GID="$create_gid"
|
||||
SERVICE_USER="$create_user"
|
||||
SERVICE_GROUP="$create_group"
|
||||
else
|
||||
export USER_UID=0
|
||||
export USER_GID=0
|
||||
export SERVICE_USER=root
|
||||
export SERVICE_GROUP=root
|
||||
SERVICE_UID=0
|
||||
SERVICE_GID=0
|
||||
SERVICE_USER=root
|
||||
SERVICE_GROUP=root
|
||||
exitStatus=2
|
||||
fi
|
||||
export SERVICE_UID SERVICE_GID SERVICE_USER SERVICE_GROUP
|
||||
return $exitStatus
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__create_env_file() {
|
||||
local dir=""
|
||||
local envStatus=0
|
||||
@@ -707,7 +712,7 @@ EOF
|
||||
rm -f "$sample_file"
|
||||
return $envStatus
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__exec_command() {
|
||||
local bin=""
|
||||
local arg=("$@")
|
||||
@@ -730,7 +735,7 @@ __exec_command() {
|
||||
fi
|
||||
return $exitCode
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Setup the server init scripts
|
||||
__start_init_scripts() {
|
||||
[ "$1" = " " ] && shift 1
|
||||
@@ -741,6 +746,7 @@ __start_init_scripts() {
|
||||
local retstatus="0"
|
||||
local initStatus="0"
|
||||
local critical_failures="0"
|
||||
local pidFile="/run/__start_init_scripts.pid"
|
||||
local init_dir="${1:-/usr/local/etc/docker/init.d}"
|
||||
local init_count="$(ls -A "$init_dir"/* 2>/dev/null | grep -v '\.sample' | wc -l)"
|
||||
local exit_on_failure="${EXIT_ON_SERVICE_FAILURE:-true}"
|
||||
@@ -751,7 +757,7 @@ __start_init_scripts() {
|
||||
rm -f /run/*.pid /run/init.d/*.pid 2>/dev/null || true
|
||||
fi
|
||||
|
||||
touch /run/__start_init_scripts.pid
|
||||
touch "$pidFile"
|
||||
|
||||
if [ "$init_count" -eq 0 ] || [ ! -d "$init_dir" ]; then
|
||||
mkdir -p "/data/logs/init"
|
||||
@@ -769,6 +775,7 @@ __start_init_scripts() {
|
||||
|
||||
for init in "$init_dir"/*.sh; do
|
||||
if [ -x "$init" ]; then
|
||||
touch "$pidFile"
|
||||
name="$(basename "$init")"
|
||||
service="$(printf '%s' "$name" | sed 's/^[^-]*-//;s|.sh$||g')"
|
||||
__service_banner "🔧" "Executing service script:" "$(basename "$init")"
|
||||
@@ -795,9 +802,9 @@ __start_init_scripts() {
|
||||
fi
|
||||
else
|
||||
# Service uses PID tracking - verify actual running processes
|
||||
set +e # Temporarily disable exit on error
|
||||
set +e # Temporarily disable exit on error
|
||||
retPID=""
|
||||
|
||||
|
||||
# First, try to find actual running process with various name patterns
|
||||
for name_variant in "$service" "${service}84" "${service}d" "$(echo "$service" | sed 's/-//g')" "$(echo "$service" | tr -d '-')"; do
|
||||
if [ -z "$retPID" ]; then
|
||||
@@ -805,9 +812,9 @@ __start_init_scripts() {
|
||||
[ -n "$retPID" ] && found_process="$name_variant" && break
|
||||
fi
|
||||
done
|
||||
|
||||
set -e # Re-enable exit on error
|
||||
|
||||
|
||||
set -e # Re-enable exit on error
|
||||
|
||||
if [ -n "$retPID" ] && [ "$retPID" != "0" ]; then
|
||||
# Found actual running process
|
||||
initStatus="0"
|
||||
@@ -859,7 +866,7 @@ __start_init_scripts() {
|
||||
printf '%s\n' "$SERVICE_NAME started on $(date)" >"/data/logs/start.log"
|
||||
return $retstatus
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__setup_mta() {
|
||||
[ -d "/etc/ssmtp" ] || [ -d "/etc/postfix" ] || return
|
||||
if [ ! -d "/config/ssmtp" ] || [ ! -d "/config/postfix" ]; then
|
||||
@@ -966,7 +973,7 @@ EOF
|
||||
[ -f "/root/dead.letter" ] && __rm "/root/dead.letter"
|
||||
return $exitCode
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__initialize_web_health() {
|
||||
local www_dir="${1:-${WWW_ROOT_DIR:-/usr/local/share/httpd/default}}"
|
||||
if [ -d "$www_dir" ]; then
|
||||
@@ -975,7 +982,7 @@ __initialize_web_health() {
|
||||
__find_replace "REPLACE_LAST_UPDATED_ON_MESSAGE" "${LAST_UPDATED_ON_MESSAGE:-$(date +'Last updated on: %Y-%m-%d at %H:%M:%S')}" "/usr/local/share/httpd"
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# file_dir
|
||||
__initialize_replace_variables() {
|
||||
local set_dir="" get_dir="$*"
|
||||
@@ -1018,7 +1025,7 @@ __initialize_replace_variables() {
|
||||
mkdir -p "${TMP_DIR:-/tmp/$SERVICE_NAME}" "${RUN_DIR:-/run/$SERVICE_NAME}" "${LOG_DIR:-/data/logs/$SERVICE_NAME}"
|
||||
chmod -f 777 "${TMP_DIR:-/tmp/$SERVICE_NAME}" "${RUN_DIR:-/run/$SERVICE_NAME}" "${LOG_DIR:-/data/logs/$SERVICE_NAME}"
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__initialize_database() {
|
||||
[ "$IS_DATABASE_SERVICE" = "yes" ] || [ "$USES_DATABASE_SERVICE" = "yes" ] || return 0
|
||||
local dir="${1:-$ETC_DIR}"
|
||||
@@ -1049,7 +1056,7 @@ __initialize_database() {
|
||||
__find_replace "REPLACE_DATABASE_DIR" "$DATABASE_DIR" "/etc"
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__initialize_db_users() {
|
||||
[ "$IS_DATABASE_SERVICE" = "yes" ] || [ "$USES_DATABASE_SERVICE" = "yes" ] || return 0
|
||||
db_normal_user="${DATABASE_USER_NORMAL:-$user_name}"
|
||||
@@ -1062,7 +1069,7 @@ __initialize_db_users() {
|
||||
export DATABASE_PASS_ROOT="$db_admin_pass"
|
||||
export db_normal_user db_normal_pass db_admin_user db_admin_pass
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__initialize_system_etc() {
|
||||
local conf_dir="$1"
|
||||
local dir=""
|
||||
@@ -1089,7 +1096,7 @@ __initialize_system_etc() {
|
||||
done
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__initialize_custom_bin_dir() {
|
||||
local SET_USR_BIN=""
|
||||
[ -d "/data/bin" ] && SET_USR_BIN+="$(__find /data/bin f) "
|
||||
@@ -1107,7 +1114,7 @@ __initialize_custom_bin_dir() {
|
||||
unset create_bin_template create_bin_name SET_USR_BIN
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__initialize_default_templates() {
|
||||
if [ -n "$DEFAULT_TEMPLATE_DIR" ]; then
|
||||
if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -d "/config" ]; then
|
||||
@@ -1127,7 +1134,7 @@ __initialize_default_templates() {
|
||||
fi
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__initialize_config_dir() {
|
||||
if [ -n "$DEFAULT_CONF_DIR" ]; then
|
||||
if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -d "/config" ]; then
|
||||
@@ -1147,7 +1154,7 @@ __initialize_config_dir() {
|
||||
fi
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__initialize_data_dir() {
|
||||
if [ -d "/data" ]; then
|
||||
if [ "$DATA_DIR_INITIALIZED" = "false" ] && [ -n "$DEFAULT_DATA_DIR" ]; then
|
||||
@@ -1167,7 +1174,7 @@ __initialize_data_dir() {
|
||||
fi
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__initialize_www_root() {
|
||||
local WWW_INIT=""
|
||||
local WWW_TEMPLATE=""
|
||||
@@ -1180,7 +1187,7 @@ __initialize_www_root() {
|
||||
fi
|
||||
__initialize_web_health "$WWW_ROOT_DIR"
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__is_htdocs_mounted() {
|
||||
WWW_ROOT_DIR="${WWW_ROOT_DIR:-/data/htdocs}"
|
||||
[ -n "$ENV_WWW_ROOT_DIR" ] && WWW_ROOT_DIR="$ENV_WWW_ROOT_DIR"
|
||||
@@ -1207,7 +1214,7 @@ __is_htdocs_mounted() {
|
||||
[ -d "$WWW_ROOT_DIR" ] || mkdir -p "$WWW_ROOT_DIR"
|
||||
export WWW_ROOT_DIR="${WWW_ROOT_DIR:-/usr/local/share/httpd/default}"
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__initialize_ssl_certs() {
|
||||
[ "$SSL_ENABLED" = "yes" ] && __certbot
|
||||
if [ -d "/config/letsencrypt" ]; then
|
||||
@@ -1234,7 +1241,7 @@ __initialize_ssl_certs() {
|
||||
fi
|
||||
type update-ca-certificates &>/dev/null && update-ca-certificates &>/dev/null
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__start_php_dev_server() {
|
||||
if [ "$2" = "yes" ]; then
|
||||
if [ -d "/usr/local/share/httpd" ]; then
|
||||
@@ -1247,7 +1254,7 @@ __start_php_dev_server() {
|
||||
fi
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__check_service() {
|
||||
if [ "$1" = "check" ]; then
|
||||
shift $#
|
||||
@@ -1255,7 +1262,7 @@ __check_service() {
|
||||
exit $?
|
||||
fi
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
__switch_to_user() {
|
||||
if [ "$RUNAS_USER" = "root" ]; then
|
||||
su_exec=""
|
||||
@@ -1278,7 +1285,7 @@ __switch_to_user() {
|
||||
fi
|
||||
export su_exec
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# usage backup "days" "hours"
|
||||
__backup() {
|
||||
local dirs="" backup_dir backup_name backup_exclude runTime cronTime maxDays
|
||||
@@ -1316,7 +1323,7 @@ __backup() {
|
||||
[ -n "$cronTime" ] && runTime=$((cronTime * 3600)) || return $exitStatus
|
||||
sleep $runTime && __backup "$maxDays" "$cronTime"
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# set variables from function calls
|
||||
export INIT_DATE="${INIT_DATE:-$(date)}"
|
||||
export START_SERVICES="${START_SERVICES:-yes}"
|
||||
@@ -1324,13 +1331,13 @@ export ENTRYPOINT_MESSAGE="${ENTRYPOINT_MESSAGE:-yes}"
|
||||
export ENTRYPOINT_FIRST_RUN="${ENTRYPOINT_FIRST_RUN:-yes}"
|
||||
export DATA_DIR_INITIALIZED="${DATA_DIR_INITIALIZED:-false}"
|
||||
export CONFIG_DIR_INITIALIZED="${CONFIG_DIR_INITIALIZED:-false}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# System
|
||||
export LANG="${LANG:-C.UTF-8}"
|
||||
export LC_ALL="${LANG:-C.UTF-8}"
|
||||
export TZ="${TZ:-${TIMEZONE:-America/New_York}}"
|
||||
export HOSTNAME="${FULL_DOMAIN_NAME:-${SERVER_HOSTNAME:-$HOSTNAME}}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Default directories
|
||||
export SSL_DIR="${SSL_DIR:-/config/ssl}"
|
||||
export SSL_CA="${SSL_CERT:-/config/ssl/ca.crt}"
|
||||
@@ -1340,15 +1347,15 @@ 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_CONF_DIR="${DEFAULT_CONF_DIR:-/usr/local/share/template-files/config}"
|
||||
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}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CONTAINER_IP4_ADDRESS="${CONTAINER_IP4_ADDRESS:-$(__get_ip4)}"
|
||||
CONTAINER_IP6_ADDRESS="${CONTAINER_IP6_ADDRESS:-$(__get_ip6)}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Additional
|
||||
export WORK_DIR="${ENV_WORK_DIR:-$WORK_DIR}"
|
||||
export SET_RANDOM_PASS="${SET_RANDOM_PASS:-$(__random_password 16)}"
|
||||
@@ -1366,15 +1373,15 @@ export ENTRYPOINT_PID_FILE="${ENTRYPOINT_PID_FILE:-/run/init.d/entrypoint.pid}"
|
||||
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_CONFIG_INIT_FILE="${ENTRYPOINT_CONFIG_INIT_FILE:-/config/.docker_has_run}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# is already Initialized
|
||||
[ -z "$DATA_DIR_INITIALIZED" ] && { [ -f "$ENTRYPOINT_DATA_INIT_FILE" ] && DATA_DIR_INITIALIZED="true" || DATA_DIR_INITIALIZED="false"; }
|
||||
[ -z "$CONFIG_DIR_INITIALIZED" ] && { [ -f "$ENTRYPOINT_CONFIG_INIT_FILE" ] && CONFIG_DIR_INITIALIZED="true" || CONFIG_DIR_INITIALIZED="false"; }
|
||||
[ -z "$ENTRYPOINT_FIRST_RUN" ] && { { [ -f "$ENTRYPOINT_PID_FILE" ] || [ -f "$ENTRYPOINT_INIT_FILE" ]; } && ENTRYPOINT_FIRST_RUN="no" || ENTRYPOINT_FIRST_RUN="true"; }
|
||||
export ENTRYPOINT_DATA_INIT_FILE DATA_DIR_INITIALIZED ENTRYPOINT_CONFIG_INIT_FILE CONFIG_DIR_INITIALIZED
|
||||
export ENTRYPOINT_PID_FILE ENTRYPOINT_INIT_FILE ENTRYPOINT_FIRST_RUN
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# export the functions
|
||||
export -f __get_pid __start_init_scripts __is_running __certbot __update_ssl_certs __create_ssl_cert
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# end of functions
|
||||
|
||||
Reference in New Issue
Block a user