From a084422584dcbb23b29f00a98da58747a2e346e6 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 3 Jan 2024 19:27:52 +0300 Subject: [PATCH] more polish... Signed-off-by: Alex A. Naanou --- .pct-helpers | 14 +++++++++++++- gate-traefik/make.sh | 31 ++++++++----------------------- ns/make.sh | 22 +++++++++------------- 3 files changed, 30 insertions(+), 37 deletions(-) diff --git a/.pct-helpers b/.pct-helpers index 51a4590..c6898bb 100644 --- a/.pct-helpers +++ b/.pct-helpers @@ -142,7 +142,7 @@ normpath(){ #---------------------------------------------------------------------- # -# xread [-n] MSG VAR +# xread [-n] MSG VAR # xread(){ local non_empty= @@ -155,6 +155,8 @@ xread(){ if [ -z $non_empty ] ; then eval ''$2'=${'$2':=$DFL_'$2'}' fi + [ $SCRIPTING ] \ + && echo "$2=${!2}" } @@ -195,6 +197,13 @@ readVars(){ xread "ADMIN bridge: vmbr" ADMIN_BRIDGE # gateway... + # IPs can be: + # + # / + # dhcp + # Gateways can be: + # + # xread "WAN ip: " WAN_IP xread "WAN gateway: " WAN_GATE xread "LAN ip: " LAN_IP @@ -280,6 +289,9 @@ pctCreateAlpine(){ local TEMPLATE=($(ls /var/lib/vz/template/cache/alpine-3.18*.tar.xz)) fi pctCreate $1 "${TEMPLATE[-1]}" "$2" "$3" + + @ lxc-attach $ID apk update + @ lxc-attach $ID apk upgrade } diff --git a/gate-traefik/make.sh b/gate-traefik/make.sh index aabb133..c3f17cf 100755 --- a/gate-traefik/make.sh +++ b/gate-traefik/make.sh @@ -23,19 +23,11 @@ DFL_CTHOSTNAME=${DFL_CTHOSTNAME:=gate} DFL_WAN_IP=${DFL_WAN_IP:=192.168.1.101/24} DFL_WAN_GATE=${DFL_WAN_GATE:=192.168.1.252} -# these can be: -# -# / -# dhcp DFL_ADMIN_IP=${DFL_ADMIN_IP:=10.0.0.2/24} ADMIN_GATE=- DFL_LAN_IP=${DFL_LAN_IP:=10.1.1.2/24} LAN_GATE=- -DFL_WAN_BRIDGE=${DFL_WAN_BRIDGE:=2} -DFL_LAN_BRIDGE=${DFL_LAN_BRIDGE:=0} -DFL_ADMIN_BRIDGE=${DFL_ADMIN_BRIDGE:=1} - REBOOT=${REBOOT:=1} readVars @@ -43,9 +35,6 @@ readVars #---------------------------------------------------------------------- -# XXX should we set the initial ip as 10.x.x.2/23, dhcp or empty??? -# --net0 name=lan,bridge=vmbr${LAN_BRIDGE},firewall=1,ip=10.1.1.2/24,type=veth \ -# --net1 name=admin,bridge=vmbr${ADMIN_BRIDGE},firewall=1,ip=10.0.0.2/24,type=veth \ OPTS_STAGE_1="\ --hostname $CTHOSTNAME \ --memory 128 \ @@ -67,36 +56,32 @@ OPTS_STAGE_2="\ #---------------------------------------------------------------------- -echo Building config... +echo "# Building config..." buildAssets "$TEMPLATE_DIR" "$ASSETS_DIR" -echo Creating CT... +echo "# Creating CT..." pctCreateAlpine $ID "${OPTS_STAGE_1}" "$PASS" -echo Updating container... -@ lxc-attach $ID apk update -@ lxc-attach $ID apk upgrade - -echo Installing dependencies... +echo "# Installing dependencies..." @ lxc-attach $ID apk add bash bridge iptables traefik -echo Copying assets... +echo "# Copying assets..." @ pct-push-r $ID ./assets / -echo Setup: traefik... +echo "# Setup: traefik..." @ lxc-attach $ID rc-update add traefik @ lxc-attach $ID rc-service traefik start -echo Setup: iptables... +echo "# Setup: iptables..." @ lxc-attach $ID rc-update add iptables @ lxc-attach $ID bash /root/routing.sh @ lxc-attach $ID rc-service iptables save @ lxc-attach $ID rc-service iptables start -echo "Post config..." +echo "# Post config..." pctSet $ID "${OPTS_STAGE_2}" $REBOOT -echo Done. +echo "# Done." diff --git a/ns/make.sh b/ns/make.sh index 72c7210..2325437 100755 --- a/ns/make.sh +++ b/ns/make.sh @@ -25,7 +25,7 @@ ADMIN_GATE=- DFL_LAN_IP=${DFL_LAN_IP:=10.1.1.1/24} DFL_LAN_GATE=${DFL_LAN_IP:=10.1.1.2/24} -# ignored variables... +REBOOT=${REBOOT:=1} readVars @@ -45,7 +45,7 @@ OPTS_STAGE_1="\ " OPTS_STAGE_2="\ - --startup order=90 \ + --startup order=90,up=10 \ --onboot 1 \ " @@ -53,30 +53,26 @@ OPTS_STAGE_2="\ #---------------------------------------------------------------------- -echo Building config... +echo "# Building config..." buildAssets "$TEMPLATE_DIR" "$ASSETS_DIR" -echo Creating CT... +echo "# Creating CT..." pctCreateAlpine $ID "${OPTS_STAGE_1}" "$PASS" -echo Updating container... -@ lxc-attach $ID apk update -@ lxc-attach $ID apk upgrade - -echo Installing dependencies... +echo "# Installing dependencies..." @ lxc-attach $ID apk add bash dnsmasq -echo Copying assets... +echo "# Copying assets..." @ pct-push-r $ID ./assets / -echo Setup: dnsmasq... +echo "# Setup: dnsmasq..." @ lxc-attach $ID rc-update add dnsmasq @ lxc-attach $ID rc-service dnsmasq start -echo "Post config..." +echo "# Post config..." pctSet $ID "${OPTS_STAGE_2}" $REBOOT -echo Done. +echo "# Done." #----------------------------------------------------------------------