mirror of
https://github.com/casjaysdevdocker/gitea
synced 2026-06-24 02:01:03 -04:00
♻️ Migrate gitea to /config/ source-of-truth architecture ♻️
Migrate gitea 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/05-dockerd.sh
rootfs/usr/local/etc/docker/init.d/08-gitea.sh
rootfs/usr/local/etc/docker/init.d/zz-act_runner.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:
@@ -126,8 +126,10 @@ RESET_ENV="no"
|
||||
WWW_ROOT_DIR="/usr/local/share/httpd/default"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Default predefined variables
|
||||
DATA_DIR="/data/docker" # set data directory
|
||||
CONF_DIR="/config/docker" # set config directory
|
||||
# set data directory
|
||||
DATA_DIR="/data/docker"
|
||||
# set config directory
|
||||
CONF_DIR="/config/docker"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# set the containers etc directory
|
||||
ETC_DIR="/etc/docker"
|
||||
@@ -135,9 +137,12 @@ ETC_DIR="/etc/docker"
|
||||
# set the var dir
|
||||
VAR_DIR=""
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
TMP_DIR="/tmp/docker" # set the temp dir
|
||||
RUN_DIR="/run/docker" # set scripts pid dir
|
||||
LOG_DIR="/data/logs/docker" # set log directory
|
||||
# set the temp dir
|
||||
TMP_DIR="/tmp/docker"
|
||||
# set scripts pid dir
|
||||
RUN_DIR="/run/docker"
|
||||
# set log directory
|
||||
LOG_DIR="/data/logs/docker"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set the working dir
|
||||
WORK_DIR=""
|
||||
@@ -146,27 +151,38 @@ WORK_DIR=""
|
||||
SERVICE_PORT="2375"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# 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="root" # execute command as another user
|
||||
SERVICE_GROUP="root" # Set the service group
|
||||
# execute command as another user
|
||||
SERVICE_USER="root"
|
||||
# Set the service group
|
||||
SERVICE_GROUP="root"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set password length
|
||||
RANDOM_PASS_USER=""
|
||||
RANDOM_PASS_ROOT=""
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# 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='dockerd' # command to execute
|
||||
EXEC_CMD_ARGS='-H tcp://0.0.0.0:$SERVICE_PORT ' # command arguments
|
||||
EXEC_CMD_ARGS+='-H unix:///var/run/docker.sock ' # command arguments
|
||||
EXEC_CMD_ARGS+='-H unix:///tmp/docker.sock --config-file $ETC_DIR/daemon.json' # command arguments
|
||||
EXEC_PRE_SCRIPT='' # execute script before
|
||||
SERVICE_USES_PID='' # Set to no if the service is not running otherwise leave blank
|
||||
# command to execute
|
||||
EXEC_CMD_BIN='dockerd'
|
||||
# command arguments
|
||||
EXEC_CMD_ARGS='-H tcp://0.0.0.0:$SERVICE_PORT '
|
||||
# command arguments
|
||||
EXEC_CMD_ARGS+='-H unix:///var/run/docker.sock '
|
||||
# command arguments
|
||||
EXEC_CMD_ARGS+='-H unix:///tmp/docker.sock --config-file $ETC_DIR/daemon.json'
|
||||
# execute script before
|
||||
EXEC_PRE_SCRIPT=''
|
||||
# Set to no if the service is not running otherwise leave blank
|
||||
SERVICE_USES_PID=''
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Is this service a web server
|
||||
IS_WEB_SERVER="no"
|
||||
@@ -194,20 +210,28 @@ IP4_ADDRESS="$(__get_ip4)"
|
||||
IP6_ADDRESS="$(__get_ip6)"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# 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="${DOCKER_ROOT_USER_NAME:-}" # root user name
|
||||
root_user_pass="${DOCKER_ROOT_PASS_WORD:-}" # root user password
|
||||
# root user name
|
||||
root_user_name="${DOCKER_ROOT_USER_NAME:-}"
|
||||
# root user password
|
||||
root_user_pass="${DOCKER_ROOT_PASS_WORD:-}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Normal user info [password/random]
|
||||
user_name="${DOCKER_USER_NAME:-}" # normal user name
|
||||
user_pass="${DOCKER_USER_PASS_WORD:-}" # normal user password
|
||||
# normal user name
|
||||
user_name="${DOCKER_USER_NAME:-}"
|
||||
# normal user password
|
||||
user_pass="${DOCKER_USER_PASS_WORD:-}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Load variables from config
|
||||
[ -f "/config/env/docker.script.sh" ] && . "/config/env/docker.script.sh" # Generated by my dockermgr script
|
||||
[ -f "/config/env/docker.sh" ] && . "/config/env/docker.sh" # Overwrite the variabes
|
||||
# Generated by my dockermgr script
|
||||
[ -f "/config/env/docker.script.sh" ] && . "/config/env/docker.script.sh"
|
||||
# Overwrite the variabes
|
||||
[ -f "/config/env/docker.sh" ] && . "/config/env/docker.sh"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Additional predefined variables
|
||||
|
||||
@@ -259,8 +283,10 @@ __execute_prerun() {
|
||||
__run_pre_execute_checks() {
|
||||
# Set variables
|
||||
local exitStatus=0
|
||||
local pre_execute_checks_MessageST="Running preexecute check for $SERVICE_NAME" # message to show at start
|
||||
local pre_execute_checks_MessageEnd="Finished preexecute check for $SERVICE_NAME" # message to show at completion
|
||||
# message to show at start
|
||||
local pre_execute_checks_MessageST="Running preexecute check for $SERVICE_NAME"
|
||||
# message to show at completion
|
||||
local pre_execute_checks_MessageEnd="Finished preexecute check for $SERVICE_NAME"
|
||||
__banner "$pre_execute_checks_MessageST"
|
||||
# Put command to execute in parentheses
|
||||
{
|
||||
@@ -342,7 +368,7 @@ __run_pre_execute_checks() {
|
||||
for container_dir in /data/docker/containers/*/; do
|
||||
if [ -d "$container_dir" ]; then
|
||||
if [ ! -f "${container_dir}config.v2.json" ]; then
|
||||
echo "Removing orphaned container: $(basename "$container_dir")"
|
||||
echo "Removing orphaned container: ${container_dir##*/}"
|
||||
rm -rf "$container_dir"
|
||||
fi
|
||||
fi
|
||||
@@ -439,8 +465,10 @@ EOF
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# 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}}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# delete files
|
||||
#__rm ""
|
||||
@@ -466,8 +494,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}}"
|
||||
# execute if directories is empty
|
||||
# __is_dir_empty "$CONF_DIR" && true
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
@@ -486,12 +516,18 @@ __pre_execute() {
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# function to run after executing
|
||||
__post_execute() {
|
||||
local pid="" # init pid var
|
||||
local retVal=0 # set default exit code
|
||||
local ctime=${POST_EXECUTE_WAIT_TIME:-1} # how long to wait before executing
|
||||
local waitTime=$((ctime * 60)) # convert minutes to seconds
|
||||
local postMessageST="Running post commands for $SERVICE_NAME" # message to show at start
|
||||
local postMessageEnd="Finished post commands for $SERVICE_NAME" # message to show at completion
|
||||
# init pid var
|
||||
local pid=""
|
||||
# set default exit code
|
||||
local retVal=0
|
||||
# how long to wait before executing
|
||||
local ctime=${POST_EXECUTE_WAIT_TIME:-1}
|
||||
# convert minutes to seconds
|
||||
local waitTime=$((ctime * 60))
|
||||
# message to show at start
|
||||
local postMessageST="Running post commands for $SERVICE_NAME"
|
||||
# message to show at completion
|
||||
local postMessageEnd="Finished post commands for $SERVICE_NAME"
|
||||
# wait
|
||||
sleep $waitTime
|
||||
# execute commands after waiting
|
||||
@@ -526,7 +562,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}}"
|
||||
# execute commands
|
||||
|
||||
# allow custom functions
|
||||
@@ -770,13 +807,19 @@ __run_secure_function() {
|
||||
__file_exists_with_content "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.sh" && . "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.sh"
|
||||
__file_exists_with_content "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.local.sh" && . "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.local.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 "$EXEC_CMD_NAME" || echo '')" # 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 "$EXEC_CMD_NAME" || echo '')"
|
||||
# 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")"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Only run check when explicitly requested
|
||||
if [ "$1" = "check" ] && __check_service "$1"; then
|
||||
|
||||
@@ -126,8 +126,10 @@ RESET_ENV="no"
|
||||
WWW_ROOT_DIR="/usr/local/share/httpd/default"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Default predefined variables
|
||||
DATA_DIR="/data/gitea" # set data directory
|
||||
CONF_DIR="/config/gitea" # set config directory
|
||||
# set data directory
|
||||
DATA_DIR="/data/gitea"
|
||||
# set config directory
|
||||
CONF_DIR="/config/gitea"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# set the containers etc directory
|
||||
ETC_DIR="/etc/gitea"
|
||||
@@ -135,9 +137,12 @@ ETC_DIR="/etc/gitea"
|
||||
# set the var dir
|
||||
VAR_DIR=""
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
TMP_DIR="/tmp/gitea" # set the temp dir
|
||||
RUN_DIR="/run/gitea" # set scripts pid dir
|
||||
LOG_DIR="/data/logs/gitea" # set log directory
|
||||
# set the temp dir
|
||||
TMP_DIR="/tmp/gitea"
|
||||
# set scripts pid dir
|
||||
RUN_DIR="/run/gitea"
|
||||
# set log directory
|
||||
LOG_DIR="/data/logs/gitea"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set the working dir
|
||||
WORK_DIR=""
|
||||
@@ -146,27 +151,38 @@ WORK_DIR=""
|
||||
SERVICE_PORT="80"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# User to use to launch service - IE: postgres
|
||||
RUNAS_USER="git" # gitea must run as git user, not root
|
||||
# gitea must run as git user, not root
|
||||
RUNAS_USER="git"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# User and group in which the service switches to - IE: nginx,apache,mysql,postgres
|
||||
SERVICE_USER="git" # execute command as another user
|
||||
SERVICE_GROUP="git" # Set the service group
|
||||
# execute command as another user
|
||||
SERVICE_USER="git"
|
||||
# Set the service group
|
||||
SERVICE_GROUP="git"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set password length
|
||||
RANDOM_PASS_USER=""
|
||||
RANDOM_PASS_ROOT=""
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# 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='gitea' # command to execute
|
||||
EXEC_CMD_ARGS='web ' # command arguments
|
||||
EXEC_CMD_ARGS+='--port $SERVICE_PORT --config $ETC_DIR/app.ini ' # command arguments
|
||||
EXEC_CMD_ARGS+='--custom-path $CONF_DIR/custom --work-path $DATA_DIR ' # command arguments
|
||||
EXEC_PRE_SCRIPT='' # execute script before
|
||||
SERVICE_USES_PID='' # Set to no if the service is not running otherwise leave blank
|
||||
# command to execute
|
||||
EXEC_CMD_BIN='gitea'
|
||||
# command arguments
|
||||
EXEC_CMD_ARGS='web '
|
||||
# command arguments
|
||||
EXEC_CMD_ARGS+='--port $SERVICE_PORT --config $ETC_DIR/app.ini '
|
||||
# command arguments
|
||||
EXEC_CMD_ARGS+='--custom-path $CONF_DIR/custom --work-path $DATA_DIR '
|
||||
# execute script before
|
||||
EXEC_PRE_SCRIPT=''
|
||||
# Set to no if the service is not running otherwise leave blank
|
||||
SERVICE_USES_PID=''
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Is this service a web server
|
||||
IS_WEB_SERVER="no"
|
||||
@@ -194,20 +210,28 @@ IP4_ADDRESS="$(__get_ip4)"
|
||||
IP6_ADDRESS="$(__get_ip6)"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# 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="${GITEA_ROOT_USER_NAME:-}" # root user name
|
||||
root_user_pass="${GITEA_ROOT_PASS_WORD:-}" # root user password
|
||||
# root user name
|
||||
root_user_name="${GITEA_ROOT_USER_NAME:-}"
|
||||
# root user password
|
||||
root_user_pass="${GITEA_ROOT_PASS_WORD:-}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Normal user info [password/random]
|
||||
user_name="${GITEA_USER_NAME:-}" # normal user name
|
||||
user_pass="${GITEA_USER_PASS_WORD:-}" # normal user password
|
||||
# normal user name
|
||||
user_name="${GITEA_USER_NAME:-}"
|
||||
# normal user password
|
||||
user_pass="${GITEA_USER_PASS_WORD:-}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Load variables from config
|
||||
[ -f "/config/env/gitea.script.sh" ] && . "/config/env/gitea.script.sh" # Generated by my dockermgr script
|
||||
[ -f "/config/env/gitea.sh" ] && . "/config/env/gitea.sh" # Overwrite the variabes
|
||||
# Generated by my dockermgr script
|
||||
[ -f "/config/env/gitea.script.sh" ] && . "/config/env/gitea.script.sh"
|
||||
# Overwrite the variabes
|
||||
[ -f "/config/env/gitea.sh" ] && . "/config/env/gitea.sh"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Additional predefined variables
|
||||
|
||||
@@ -280,8 +304,10 @@ __execute_prerun() {
|
||||
__run_pre_execute_checks() {
|
||||
# Set variables
|
||||
local exitStatus=0
|
||||
local pre_execute_checks_MessageST="Running preexecute check for $SERVICE_NAME" # message to show at start
|
||||
local pre_execute_checks_MessageEnd="Finished preexecute check for $SERVICE_NAME" # message to show at completion
|
||||
# message to show at start
|
||||
local pre_execute_checks_MessageST="Running preexecute check for $SERVICE_NAME"
|
||||
# message to show at completion
|
||||
local pre_execute_checks_MessageEnd="Finished preexecute check for $SERVICE_NAME"
|
||||
__banner "$pre_execute_checks_MessageST"
|
||||
# Put command to execute in parentheses
|
||||
{
|
||||
@@ -304,8 +330,10 @@ __run_pre_execute_checks() {
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# 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}}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# delete files
|
||||
#__rm ""
|
||||
@@ -388,8 +416,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}}"
|
||||
# execute if directories is empty
|
||||
# __is_dir_empty "$CONF_DIR" && true
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
@@ -408,12 +438,18 @@ __pre_execute() {
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# function to run after executing
|
||||
__post_execute() {
|
||||
local pid="" # init pid var
|
||||
local retVal=0 # set default exit code
|
||||
local ctime=${POST_EXECUTE_WAIT_TIME:-1} # how long to wait before executing
|
||||
local waitTime=$((ctime * 60)) # convert minutes to seconds
|
||||
local postMessageST="Running post commands for $SERVICE_NAME" # message to show at start
|
||||
local postMessageEnd="Finished post commands for $SERVICE_NAME" # message to show at completion
|
||||
# init pid var
|
||||
local pid=""
|
||||
# set default exit code
|
||||
local retVal=0
|
||||
# how long to wait before executing
|
||||
local ctime=${POST_EXECUTE_WAIT_TIME:-1}
|
||||
# convert minutes to seconds
|
||||
local waitTime=$((ctime * 60))
|
||||
# message to show at start
|
||||
local postMessageST="Running post commands for $SERVICE_NAME"
|
||||
# message to show at completion
|
||||
local postMessageEnd="Finished post commands for $SERVICE_NAME"
|
||||
# wait
|
||||
sleep $waitTime
|
||||
# execute commands after waiting
|
||||
@@ -448,7 +484,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}}"
|
||||
# execute commands
|
||||
|
||||
# allow custom functions
|
||||
@@ -692,13 +729,19 @@ __run_secure_function() {
|
||||
__file_exists_with_content "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.sh" && . "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.sh"
|
||||
__file_exists_with_content "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.local.sh" && . "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.local.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 "$EXEC_CMD_NAME" || echo '')" # 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 "$EXEC_CMD_NAME" || echo '')"
|
||||
# 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")"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Only run check when explicitly requested
|
||||
if [ "$1" = "check" ] && __check_service "$1"; then
|
||||
|
||||
@@ -152,8 +152,10 @@ RESET_ENV="no"
|
||||
WWW_ROOT_DIR="/usr/local/share/httpd/default"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Default predefined variables
|
||||
DATA_DIR="/data/act_runner" # set data directory
|
||||
CONF_DIR="/config/act_runner" # set config directory
|
||||
# set data directory
|
||||
DATA_DIR="/data/act_runner"
|
||||
# set config directory
|
||||
CONF_DIR="/config/act_runner"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# set the containers etc directory
|
||||
ETC_DIR="/etc/act_runner"
|
||||
@@ -161,9 +163,12 @@ ETC_DIR="/etc/act_runner"
|
||||
# set the var dir
|
||||
VAR_DIR=""
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
TMP_DIR="/tmp/act_runner" # set the temp dir
|
||||
RUN_DIR="/run/act_runner" # set scripts pid dir
|
||||
LOG_DIR="/data/logs/act_runner" # set log directory
|
||||
# set the temp dir
|
||||
TMP_DIR="/tmp/act_runner"
|
||||
# set scripts pid dir
|
||||
RUN_DIR="/run/act_runner"
|
||||
# set log directory
|
||||
LOG_DIR="/data/logs/act_runner"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set the working dir
|
||||
WORK_DIR=""
|
||||
@@ -172,25 +177,34 @@ WORK_DIR=""
|
||||
SERVICE_PORT="44015"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# 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="git" # execute command as another user
|
||||
SERVICE_GROUP="git" # Set the service group
|
||||
# execute command as another user
|
||||
SERVICE_USER="git"
|
||||
# Set the service group
|
||||
SERVICE_GROUP="git"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set password length
|
||||
RANDOM_PASS_USER=""
|
||||
RANDOM_PASS_ROOT=""
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# 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='' # command to execute
|
||||
EXEC_CMD_ARGS='' # command arguments
|
||||
EXEC_PRE_SCRIPT='' # execute script before
|
||||
SERVICE_USES_PID='' # Set to no if the service is not running otherwise leave blank
|
||||
# command to execute
|
||||
EXEC_CMD_BIN=''
|
||||
# command arguments
|
||||
EXEC_CMD_ARGS=''
|
||||
# execute script before
|
||||
EXEC_PRE_SCRIPT=''
|
||||
# Set to no if the service is not running otherwise leave blank
|
||||
SERVICE_USES_PID=''
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Is this service a web server
|
||||
IS_WEB_SERVER="no"
|
||||
@@ -218,20 +232,28 @@ IP4_ADDRESS="$(__get_ip4)"
|
||||
IP6_ADDRESS="$(__get_ip6)"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# 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="${ACT_RUNNER_ROOT_USER_NAME:-}" # root user name
|
||||
root_user_pass="${ACT_RUNNER_ROOT_PASS_WORD:-}" # root user password
|
||||
# root user name
|
||||
root_user_name="${ACT_RUNNER_ROOT_USER_NAME:-}"
|
||||
# root user password
|
||||
root_user_pass="${ACT_RUNNER_ROOT_PASS_WORD:-}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Normal user info [password/random]
|
||||
user_name="${ACT_RUNNER_USER_NAME:-}" # normal user name
|
||||
user_pass="${ACT_RUNNER_USER_PASS_WORD:-}" # normal user password
|
||||
# normal user name
|
||||
user_name="${ACT_RUNNER_USER_NAME:-}"
|
||||
# normal user password
|
||||
user_pass="${ACT_RUNNER_USER_PASS_WORD:-}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Load variables from config
|
||||
[ -f "/config/env/act_runner.script.sh" ] && . "/config/env/act_runner.script.sh" # Generated by my dockermgr script
|
||||
[ -f "/config/env/act_runner.sh" ] && . "/config/env/act_runner.sh" # Overwrite the variabes
|
||||
# Generated by my dockermgr script
|
||||
[ -f "/config/env/act_runner.script.sh" ] && . "/config/env/act_runner.script.sh"
|
||||
# Overwrite the variabes
|
||||
[ -f "/config/env/act_runner.sh" ] && . "/config/env/act_runner.sh"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Additional predefined variables
|
||||
GITEA_PORT="${GITEA_PORT:-80}"
|
||||
@@ -331,8 +353,10 @@ __execute_prerun() {
|
||||
__run_pre_execute_checks() {
|
||||
# Set variables
|
||||
local exitStatus=0
|
||||
local pre_execute_checks_MessageST="Running preexecute check for $SERVICE_NAME" # message to show at start
|
||||
local pre_execute_checks_MessageEnd="Finished preexecute check for $SERVICE_NAME" # message to show at completion
|
||||
# message to show at start
|
||||
local pre_execute_checks_MessageST="Running preexecute check for $SERVICE_NAME"
|
||||
# message to show at completion
|
||||
local pre_execute_checks_MessageEnd="Finished preexecute check for $SERVICE_NAME"
|
||||
__banner "$pre_execute_checks_MessageST"
|
||||
# Put command to execute in parentheses
|
||||
{
|
||||
@@ -374,8 +398,10 @@ __run_pre_execute_checks() {
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# 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}}"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# delete files
|
||||
#__rm ""
|
||||
@@ -400,8 +426,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}}"
|
||||
# execute if directories is empty
|
||||
# __is_dir_empty "$CONF_DIR" && true
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
@@ -420,12 +448,18 @@ __pre_execute() {
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# function to run after executing
|
||||
__post_execute() {
|
||||
local pid="" # init pid var
|
||||
local retVal=0 # set default exit code
|
||||
local ctime=${POST_EXECUTE_WAIT_TIME:-1} # how long to wait before executing
|
||||
local waitTime=$((ctime * 60)) # convert minutes to seconds
|
||||
local postMessageST="Running post commands for $SERVICE_NAME" # message to show at start
|
||||
local postMessageEnd="Finished post commands for $SERVICE_NAME" # message to show at completion
|
||||
# init pid var
|
||||
local pid=""
|
||||
# set default exit code
|
||||
local retVal=0
|
||||
# how long to wait before executing
|
||||
local ctime=${POST_EXECUTE_WAIT_TIME:-1}
|
||||
# convert minutes to seconds
|
||||
local waitTime=$((ctime * 60))
|
||||
# message to show at start
|
||||
local postMessageST="Running post commands for $SERVICE_NAME"
|
||||
# message to show at completion
|
||||
local postMessageEnd="Finished post commands for $SERVICE_NAME"
|
||||
export RUNNERS_START="${RUNNERS_START:-5}" RUNNER_LABELS RUNNERS_LOG_DIR="$LOG_DIR"
|
||||
export SERVER_ADDRESS="$RUNNER_IP_ADDRESS:$GITEA_PORT" SERVER_TOKEN="${RUNNER_AUTH_TOKEN:-$SYS_AUTH_TOKEN}"
|
||||
|
||||
@@ -492,7 +526,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}}"
|
||||
# execute commands
|
||||
|
||||
# allow custom functions
|
||||
@@ -736,13 +771,19 @@ __run_secure_function() {
|
||||
__file_exists_with_content "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.sh" && . "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.sh"
|
||||
__file_exists_with_content "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.local.sh" && . "/config/env/${SERVICE_NAME:-$SCRIPT_NAME}.local.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 "$EXEC_CMD_NAME" || echo '')" # 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 "$EXEC_CMD_NAME" || echo '')"
|
||||
# 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")"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Only run check when explicitly requested
|
||||
if [ "$1" = "check" ] && __check_service "$1"; then
|
||||
|
||||
Reference in New Issue
Block a user