From 7e9f9b4c3cd487844465a86c19a6b885c16df1b1 Mon Sep 17 00:00:00 2001 From: casjay Date: Sun, 3 Sep 2023 13:36:17 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Committing=20everything?= =?UTF-8?q?=20that=20changed=20=F0=9F=97=83=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit .gitignore rootfs/usr/local/bin/entrypoint.sh rootfs/usr/local/etc/docker/functions/entrypoint.sh --- .gitignore | 2 +- rootfs/usr/local/bin/entrypoint.sh | 63 ++++++++++++------- .../local/etc/docker/functions/entrypoint.sh | 38 +++++++---- 3 files changed, 69 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index 020fef5..ca5c7d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# gitignore created on 09/01/23 at 11:01 +# gitignore created on 09/03/23 at 12:44 # Disable reminder in prompt ignoredirmessage diff --git a/rootfs/usr/local/bin/entrypoint.sh b/rootfs/usr/local/bin/entrypoint.sh index 9b19892..4d1500b 100755 --- a/rootfs/usr/local/bin/entrypoint.sh +++ b/rootfs/usr/local/bin/entrypoint.sh @@ -1,13 +1,13 @@ #!/usr/bin/env bash # shellcheck shell=bash # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -##@Version : 202309011101-git +##@Version : 202309031244-git # @@Author : Jason Hempstead # @@Contact : jason@casjaysdev.pro # @@License : WTFPL # @@ReadME : docker-entrypoint --help # @@Copyright : Copyright: (c) 2023 Jason Hempstead, Casjays Developments -# @@Created : Friday, Sep 01, 2023 11:01 EDT +# @@Created : Sunday, Sep 03, 2023 12:44 EDT # @@File : docker-entrypoint # @@Description : # @@Changelog : New script @@ -82,18 +82,6 @@ HEALTH_ENDPOINTS="" # url endpoints: [http://localhost/health,http://localhost/ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Overwrite variables -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -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 BACKUP_DIR="${BACKUP_DIR:-/data/backups}" -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}" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - __run_message() { @@ -102,14 +90,47 @@ __run_message() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ################## END OF CONFIGURATION ##################### # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Startup variables +export INIT_DATE="${INIT_DATE:-$(date)}" +export START_SERVICES="${START_SERVICES:-yes}" +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}" +export SSL_KEY="${SSL_KEY:-/config/ssl/localhost.pem}" +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 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}" +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Additional -PHP_INI_DIR="${PHP_INI_DIR:-$(__find_php_ini)}" -PHP_BIN_DIR="${PHP_BIN_DIR:-$(__find_php_bin)}" -HTTPD_CONFIG_FILE="${HTTPD_CONFIG_FILE:-$(__find_httpd_conf)}" -NGINX_CONFIG_FILE="${NGINX_CONFIG_FILE:-$(__find_nginx_conf)}" -MYSQL_CONFIG_FILE="${MYSQL_CONFIG_FILE:-$(__find_mysql_conf)}" -PGSQL_CONFIG_FILE="${PGSQL_CONFIG_FILE:-$(__find_pgsql_conf)}" -MONGODB_CONFIG_FILE="${MONGODB_CONFIG_FILE:-$(__find_mongodb_conf)}" +export PHP_INI_DIR="${PHP_INI_DIR:-$(__find_php_ini)}" +export PHP_BIN_DIR="${PHP_BIN_DIR:-$(__find_php_bin)}" +export HTTPD_CONFIG_FILE="${HTTPD_CONFIG_FILE:-$(__find_httpd_conf)}" +export NGINX_CONFIG_FILE="${NGINX_CONFIG_FILE:-$(__find_nginx_conf)}" +export MYSQL_CONFIG_FILE="${MYSQL_CONFIG_FILE:-$(__find_mysql_conf)}" +export PGSQL_CONFIG_FILE="${PGSQL_CONFIG_FILE:-$(__find_pgsql_conf)}" +export MONGODB_CONFIG_FILE="${MONGODB_CONFIG_FILE:-$(__find_mongodb_conf)}" +export ENTRYPOINT_PID_FILE="${ENTRYPOINT_PID_FILE:-/run/init.d/entrypoint.pid}" +export ENTRYPOINT_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}" +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +if [ -f "$ENTRYPOINT_PID_FILE" ] || [ -f "$ENTRYPOINT_INIT_FILE" ]; then + START_SERVICES="no" ENTRYPOINT_MESSAGE="no" ENTRYPOINT_FIRST_RUN="no" +fi # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # variables based on env/files [ "$WEB_SERVER_PORT" = "443" ] && SSL_ENABLED="true" diff --git a/rootfs/usr/local/etc/docker/functions/entrypoint.sh b/rootfs/usr/local/etc/docker/functions/entrypoint.sh index bbabd38..db0e55b 100644 --- a/rootfs/usr/local/etc/docker/functions/entrypoint.sh +++ b/rootfs/usr/local/etc/docker/functions/entrypoint.sh @@ -1,13 +1,13 @@ #!/usr/bin/env bash # shellcheck shell=bash # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -##@Version : 202308281453-git +##@Version : 202309030111-git # @@Author : Jason Hempstead # @@Contact : git-admin@casjaysdev.pro -# @@License : WTFPL +# @@License : LICENSE.md # @@ReadME : docker-entrypoint --help # @@Copyright : Copyright: (c) 2023 Jason Hempstead, Casjays Developments -# @@Created : Monday, Aug 28, 2023 14:53 EDT +# @@Created : Sunday, Sep 03, 2023 01:40 EDT # @@File : docker-entrypoint # @@Description : functions for my docker containers # @@Changelog : newScript @@ -575,7 +575,7 @@ __initialize_web_health() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # file_dir __initialize_replace_variables() { - [ $# -ne 0 ] || return 1 # REPLACE_GITEA_PROTO + [ $# -ne 0 ] || return 1 __find_replace "REPLACE_SSL_DIR" "${SSL_DIR:-/etc/ssl}" "$1" __find_replace "REPLACE_RANDOM_ID" "$(__random_password 8)" "$1" __find_replace "REPLACE_TZ" "${TZ:-${TIMEZONE:-America/New_York}}" "$1" @@ -602,18 +602,32 @@ __initialize_replace_variables() { } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - __initialize_database() { - [ -n "$user_name" ] && __replace "REPLACE_USER_NAME" "$user_name" "$1" - [ -n "$user_pass" ] && __replace "REPLACE_USER_PASS" "$user_pass" "$1" - [ -n "$user_name" ] && __replace "REPLACE_DATABASE_USER" "$user_name" "$1" - [ -n "$user_pass" ] && __replace "REPLACE_DATABASE_PASS" "$user_pass" "$1" - [ -n "$root_user_name" ] && __replace "REPLACE_ROOT_ADMIN" "$root_user_name" "$1" - [ -n "$root_user_pass" ] && __replace "REPLACE_ROOT_PASS" "$root_user_pass" "$1" - [ -n "$root_user_name" ] && __replace "REPLACE_DATABASE_ROOT_USER" "$root_user_name" "$1" - [ -n "$root_user_pass" ] && __replace "REPLACE_DATABASE_ROOT_PASS" "$root_user_pass" "$1" + [ "$IS_DATABASE_SERVICE" = "yes" ] || return 0 + local db_normal_user="${DATABASE_USER_NORMAL:-$user_name}" + local db_normal_pass="${DATABASE_PASS_NORMAL:-$user_pass}" + local db_admin_user="${DATABASE_USER_ROOT:-$root_user_name}" + local db_admin_pass="${DATABASE_PASS_ROOT:-$root_user_pass}" + [ -n "$db_normal_user" ] && __replace "REPLACE_USER_NAME" "$db_normal_user" "$1" + [ -n "$db_normal_pass" ] && __replace "REPLACE_USER_PASS" "$db_normal_pass" "$1" + [ -n "$db_normal_user" ] && __replace "REPLACE_DATABASE_USER" "$db_normal_user" "$1" + [ -n "$db_normal_pass" ] && __replace "REPLACE_DATABASE_PASS" "$db_normal_pass" "$1" + [ -n "$db_admin_user" ] && __replace "REPLACE_ROOT_ADMIN" "$db_admin_user" "$1" + [ -n "$db_admin_pass" ] && __replace "REPLACE_ROOT_PASS" "$db_admin_pass" "$1" + [ -n "$db_admin_user" ] && __replace "REPLACE_DATABASE_ROOT_USER" "$db_admin_user" "$1" + [ -n "$db_admin_pass" ] && __replace "REPLACE_DATABASE_ROOT_PASS" "$db_admin_pass" "$1" [ -n "$DATABASE_NAME" ] && __replace "REPLACE_DATABASE_NAME" "$DATABASE_NAME" "$1" [ -n "$DATABASE_DIR" ] && __replace "REPLACE_DATABASE_DIR" "$DATABASE_DIR" "$1" } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +__initialize_db_users() { + [ "$IS_DATABASE_SERVICE" = "yes" ] || return 0 + db_normal_user="${DATABASE_USER_NORMAL:-$user_name}" + db_normal_pass="${DATABASE_PASS_NORMAL:-$user_pass}" + db_admin_user="${DATABASE_USER_ROOT:-$root_user_name}" + db_admin_pass="${DATABASE_PASS_ROOT:-$root_user_pass}" + export user_name="$db_normal_user" user_pass="$db_normal_pass" root_user_name="$db_admin_user" root_user_pass="$db_admin_pass" +} +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - __initialize_system_etc() { local conf_dir="$1" local file="" directories=""