cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2024-01-20 18:08:55 +03:00
parent 3963fdd97e
commit da2837a80d

View File

@ -49,6 +49,7 @@ would-like(){
} }
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# Fill section... # Fill section...
# #
@ -148,6 +149,7 @@ hostname2ct(){
} }
#---------------------------------------------------------------------- #----------------------------------------------------------------------
normpath(){ normpath(){
@ -161,34 +163,9 @@ normpath(){
} }
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#
# pveGetLatestTemplate PATTERN [VAR]
#
# see:
# https://pve.proxmox.com/wiki/Linux_Container
pveGetLatestTemplate(){
if [ $DRY_RUN ] ; then
[ -z $2 ] \
|| eval "$2=${CT_TEMPLATE:-\\\$CT_TEMPLATE}"
return
fi
#@ pveam update
local templates=($(pveam available | grep -o ''${1}'.*$'))
local latest=${templates[-1]}
@ pveam download local ${latest}
latest=$(pveam list local | grep -o "^.*$latest")
#latest=($(ls /var/lib/vz/template/cache/${1}*))
[ -z $2 ] \
|| eval "$2=${latest}"
}
# #
# xread [-n] MSG VAR # xread [-n] MSG VAR
# #
@ -286,32 +263,8 @@ xreadpass(){
} }
# Wait for /etc/inithooks.conf to be generated then cleared
#
# tklWaitForSetup ID
#
# for tkl inithooks doc see:
# https://www.turnkeylinux.org/docs/inithooks
tklWaitForSetup(){
printf "# TKL setup, this may take a while"
if [ -z $DRY_RUN ] ; then
while ! $(lxc-attach $1 -- test -e /etc/inithooks.conf) ; do
printf '.'
sleep ${TIMEOUT:=5}
done
printf '+'
sleep ${TIMEOUT:=5}
while ! [[ $(lxc-attach $1 -- cat /etc/inithooks.conf | wc -c) < 2 ]] ; do
printf '.'
sleep ${TIMEOUT:=5}
done
else
printf '.+..'
fi
printf 'ready.\n'
sleep ${TIMEOUT:=5}
}
#----------------------------------------------------------------------
# #
# readConfig # readConfig
@ -341,6 +294,7 @@ readConfig(){
fi fi
} }
# #
# saveConfig [-d|-a] CONFIG VAR .. # saveConfig [-d|-a] CONFIG VAR ..
# #
@ -376,6 +330,7 @@ saveConfig(){
} >> "$cfg" } >> "$cfg"
} }
saveLastRunConfig(){ saveLastRunConfig(){
local cfg=config.last-run local cfg=config.last-run
echo "# Saving config to: config.last-run" echo "# Saving config to: config.last-run"
@ -387,7 +342,10 @@ saveLastRunConfig(){
saveConfig -d -a "$cfg" ${XREAD_VARS[@]} saveConfig -d -a "$cfg" ${XREAD_VARS[@]}
} }
#
# webAppConfig NAME # webAppConfig NAME
#
webAppConfig(){ webAppConfig(){
local name=${1^^} local name=${1^^}
eval "${name}_SUBDOMAIN=\${${name}_SUBDOMAIN:=\${DFL_SUB${name}_DOMAIN}} eval "${name}_SUBDOMAIN=\${${name}_SUBDOMAIN:=\${DFL_SUB${name}_DOMAIN}}
@ -403,6 +361,7 @@ webAppConfig(){
DOMAIN= DOMAIN=
} }
# #
# readVars # readVars
# #
@ -621,6 +580,9 @@ buildAssets(){
} }
#----------------------------------------------------------------------
# #
# pctPushAssets ID # pctPushAssets ID
# #
@ -629,6 +591,33 @@ pctPushAssets(){
} }
#
# pveGetLatestTemplate PATTERN [VAR]
#
# see:
# https://pve.proxmox.com/wiki/Linux_Container
pveGetLatestTemplate(){
if [ $DRY_RUN ] ; then
[ -z $2 ] \
|| eval "$2=${CT_TEMPLATE:-\\\$CT_TEMPLATE}"
return
fi
#@ pveam update
local templates=($(pveam available | grep -o ''${1}'.*$'))
local latest=${templates[-1]}
@ pveam download local ${latest}
latest=$(pveam list local | grep -o "^.*$latest")
#latest=($(ls /var/lib/vz/template/cache/${1}*))
[ -z $2 ] \
|| eval "$2=${latest}"
}
# #
# pctCreate ID TEMPLATE ARGS [PASS] # pctCreate ID TEMPLATE ARGS [PASS]
# #
@ -700,6 +689,31 @@ pctCreateTurnkey(){
sleep ${TIMEOUT:=5} sleep ${TIMEOUT:=5}
} }
# Wait for /etc/inithooks.conf to be generated then cleared
#
# tklWaitForSetup ID
#
# for tkl inithooks doc see:
# https://www.turnkeylinux.org/docs/inithooks
tklWaitForSetup(){
printf "# TKL setup, this may take a while"
if [ -z $DRY_RUN ] ; then
while ! $(lxc-attach $1 -- test -e /etc/inithooks.conf) ; do
printf '.'
sleep ${TIMEOUT:=5}
done
printf '+'
sleep ${TIMEOUT:=5}
while ! [[ $(lxc-attach $1 -- cat /etc/inithooks.conf | wc -c) < 2 ]] ; do
printf '.'
sleep ${TIMEOUT:=5}
done
else
printf '.+..'
fi
printf 'ready.\n'
sleep ${TIMEOUT:=5}
}
# #
# pctUpdateTurnkey ID # pctUpdateTurnkey ID
# #
@ -747,5 +761,6 @@ pctSetNotes(){
} }
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# vim:set ts=4 sw=4 nowrap : # vim:set ts=4 sw=4 nowrap :