more config options + refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2024-01-13 09:55:32 +03:00
parent ffb69c61ad
commit a84b3846a7
8 changed files with 54 additions and 3 deletions

View File

@ -202,7 +202,9 @@ xread(){
shift
local non_empty=1
fi
# XXX check DFL_..???
if [[ "${!2}" == "SKIP" ]] ; then
eval "$2="
return
fi
if [ -z ${!2} ] ; then
@ -220,7 +222,9 @@ xread(){
# xreadYes MSG VAR
#
xreadYes(){
# XXX check DFL_..???
if [[ "${!2}" == "SKIP" ]] ; then
eval "$2="
return
fi
if [ -z ${!2} ] ; then
@ -312,8 +316,12 @@ tklWaitForSetup(){
# CLEAN_RUN - if set ignore ./config.last-run
# CONFIG - config file to load last
#
# XXX need this not to make this behave with explicitly set vars...
readConfig(){
if [ -z $NO_DEFAULTS ] ; then
local IFS=$'\n'
#__ENV=($( (set -o posix ; set | grep -v 'BASHOPTS=') ))
#__ENV=($( (declare -xp) ))
[ -e ../config.global ] \
&& source ../config.global
[ -e ./config ] \
@ -324,6 +332,8 @@ readConfig(){
&& source ./config.last-run
[ -e "$CONFIG" ] \
&& source $CONFIG
#eval "${__ENV[@]}"
#__ENV=
fi
}
@ -373,6 +383,22 @@ saveLastRunConfig(){
saveConfig -d -a "$cfg" ${XREAD_VARS[@]}
}
# webAppConfig NAME
webAppConfig(){
local name=${1^^}
eval "${name}_SUBDOMAIN=\${${name}_SUBDOMAIN:=\${DFL_SUB${name}_DOMAIN}}
${name}_SUBDOMAIN=\${${name}_SUBDOMAIN:+\${${name}_SUBDOMAIN%.}.}
${name}_DOMAIN=\${${name}_DOMAIN:=\${DFL_${name}_DOMAIN}}
# prioretize \${name}_*
DFL_DOMAIN=\${DFL_DOMAIN:+\${${name}_SUBDOMAIN}\${DFL_DOMAIN}}
DFL_DOMAIN=\${DOMAIN:+\${${name}_SUBDOMAIN}\${DOMAIN}}
if [ \$${name}_DOMAIN ] ; then
DFL_DOMAIN=\${${name}_SUBDOMAIN}\${${name}_DOMAIN}
fi"
# force check of domain...
DOMAIN=
}
#
# readVars
#

View File

@ -18,9 +18,9 @@
#
#------------------------------------------------------------------------
DFL_EMAIL=user@example.com
EMAIL=user@example.com
DFL_DOMAIN=example.com
DOMAIN=example.com
DFL_WAN_IP=192.168.1.101/24
DFL_WAN_GATE=192.168.1.252
@ -41,6 +41,24 @@ LAN_BRIDGE=
ADMIN_BRIDGE=
# Web app/service domain configuration
#
# Here two optional variables are provided per service:
# - <SERVICE>_DOMAIN=...
# Overrides the $DOMAIN option above for <SERVICE>
# - <SERVICE>_SUBDOMAIN=...
# Sets the subdomain of $DOMAIN (or $<SERVICE>_DOMAIN) for <SERVICE>
#
# Nextcloud
#NEXTCLOUD_DOMAIN=
NEXTCLOUD_SUBDOMAIN=nc.
# Gitea
#GITEA_DOMAIN=
#GITEA_SUBDOMAIN=
# Extra options passed to each CT created.
#
# This can be used for passing in ssh keys, etc...

View File

@ -17,6 +17,8 @@ readConfig
#----------------------------------------------------------------------
webAppConfig gitea
DFL_ID=${DFL_ID:=300}
DFL_CTHOSTNAME=${DFL_CTHOSTNAME:=gitea}

View File

@ -17,6 +17,8 @@ readConfig
#----------------------------------------------------------------------
webAppConfig Nextcloud
DFL_ID=${DFL_ID:=300}
DFL_CTHOSTNAME=${DFL_CTHOSTNAME:=nextcloud}
@ -42,6 +44,9 @@ REBOOT=${REBOOT:=1}
readVars
# Nextcloud-specific configuration...
APP_DOMAIN=$DOMAIN
#----------------------------------------------------------------------

View File

@ -4,7 +4,7 @@ http:
entryPoints:
- https
service: nextcloud
rule: "Host(`nc.${DOMAIN}`)"
rule: "Host(`${DOMAIN}`)"
tls:
certResolver: letsEncrypt