mirror of
https://github.com/casjaysdevdocker/gotify
synced 2026-06-24 08:01:05 -04:00
♻️ Migrate gotify to /config/ source-of-truth architecture ♻️
Migrate gotify 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 (gotify ) 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/gotify.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/config/gotify/config.yml rootfs/usr/local/share/template-files/config/gotify/.env.gotify 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"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
@@ -70,18 +70,27 @@ RESET_ENV="no"
|
||||
PRE_EXEC_MESSAGE=""
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Default predefined variables
|
||||
WORKDIR="" # set working directory
|
||||
DATA_DIR="/data" # set data directory
|
||||
WWW_DIR="/data/htdocs/www" # set the web root
|
||||
# set working directory
|
||||
WORKDIR=""
|
||||
# set data directory
|
||||
DATA_DIR="/data"
|
||||
# set the web root
|
||||
WWW_DIR="/data/htdocs/www"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
ETC_DIR="/etc/gotify" # set etc directory
|
||||
CONF_DIR="/config/gotify" # set config directory
|
||||
# set etc directory
|
||||
ETC_DIR="/etc/gotify"
|
||||
# set config directory
|
||||
CONF_DIR="/config/gotify"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
RUN_DIR="/run/init.d" # set scripts pid dir
|
||||
LOG_DIR="/data/logs/gotify" # set log directory
|
||||
# set scripts pid dir
|
||||
RUN_DIR="/run/init.d"
|
||||
# set log directory
|
||||
LOG_DIR="/data/logs/gotify"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
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"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# set the database directory
|
||||
DATABASE_DIR="${DATABASE_DIR_GOTIFY:-/data/db/gotify}"
|
||||
@@ -93,11 +102,16 @@ DATABASE_DIR="${DATABASE_DIR_GOTIFY:-/data/db/gotify}"
|
||||
SERVICE_PORT=""
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# execute command variables
|
||||
SERVICE_UID="0" # set the user id
|
||||
SERVICE_USER="root" # execute command as another user
|
||||
EXEC_CMD_BIN="gotify" # command to execute
|
||||
EXEC_CMD_ARGS="" # 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="gotify"
|
||||
# command arguments
|
||||
EXEC_CMD_ARGS=""
|
||||
# execute script before
|
||||
EXEC_PRE_SCRIPT=""
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Is this service a web server
|
||||
IS_WEB_SERVER="no"
|
||||
@@ -109,12 +123,16 @@ IS_DATABASE_SERVICE="yes"
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# usernames
|
||||
user_name="${GOTIFY_USER_NAME:-}" # normal user name
|
||||
root_user_name="${GOTIFY_ROOT_USER_NAME:-admin}" # root user name
|
||||
# normal user name
|
||||
user_name="${GOTIFY_USER_NAME:-}"
|
||||
# root user name
|
||||
root_user_name="${GOTIFY_ROOT_USER_NAME:-admin}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# passwords [password/random]
|
||||
user_pass="${GOTIFY_USER_PASS_WORD:-}" # normal user password
|
||||
root_user_pass="${GOTIFY_ROOT_PASS_WORD:-pass}" # root user password
|
||||
# normal user password
|
||||
user_pass="${GOTIFY_USER_PASS_WORD:-}"
|
||||
# root user password
|
||||
root_user_pass="${GOTIFY_ROOT_PASS_WORD:-pass}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Overwrite variables from files
|
||||
[ -f "${USER_FILE_PREFIX}/${SERVICE_NAME}_name" ] && user_name="$(<"${USER_FILE_PREFIX}/${SERVICE_NAME}_name")"
|
||||
@@ -139,8 +157,10 @@ 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
|
||||
# default exit code
|
||||
local exitCode=0
|
||||
# specifiy different user
|
||||
local user="${SERVICE_USER:-root}"
|
||||
|
||||
# delete files
|
||||
#__rm ""
|
||||
@@ -186,8 +206,10 @@ __update_conf_files() {
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# function to run before executing
|
||||
__pre_execute() {
|
||||
local exitCode=0 # default exit code
|
||||
local user="${SERVICE_USER:-root}" # specifiy different user
|
||||
# default exit code
|
||||
local exitCode=0
|
||||
# specifiy different user
|
||||
local user="${SERVICE_USER:-root}"
|
||||
# define commands
|
||||
|
||||
# execute if directories is empty
|
||||
@@ -213,10 +235,14 @@ __pre_execute() {
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# function to run after executing
|
||||
__post_execute() {
|
||||
local exitCode=0 # default exit code
|
||||
local user="${SERVICE_USER:-root}" # specifiy different user
|
||||
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}"
|
||||
# how long to wait before executing
|
||||
sleep 60
|
||||
# message
|
||||
echo "Running post commands"
|
||||
# execute commands
|
||||
|
||||
return $exitCode
|
||||
@@ -254,7 +280,6 @@ __create_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}" #
|
||||
@@ -349,7 +374,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"
|
||||
@@ -363,27 +388,46 @@ __proc_check() {
|
||||
# Allow ENV_ variable - Import env file
|
||||
[ -f "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.sh" ] && . "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.sh"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
SERVICE_EXIT_CODE=0 # default exit code
|
||||
WORKDIR="${ENV_WORKDIR:-$WORKDIR}" # 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
|
||||
WORKDIR="${ENV_WORKDIR:-$WORKDIR}"
|
||||
# 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"; }
|
||||
|
||||
Reference in New Issue
Block a user