Compare commits

..

3 Commits

Author SHA1 Message Date
b079498481 added test for bridge overloading...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2024-01-31 03:40:16 +03:00
67d7808f0b notes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2024-01-31 03:10:40 +03:00
6c13fbf24b tweaking the scripting mode...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2024-01-30 22:40:37 +03:00
2 changed files with 41 additions and 10 deletions

View File

@ -1,5 +1,8 @@
#!/usr/bin/bash
#----------------------------------------------------------------------
#
#
#----------------------------------------------------------------------
CT_DIR=${CT_DIR:=/etc/pve/lxc/}
@ -178,6 +181,10 @@ xread(){
shift
local non_empty=1
fi
local prefix=
if [ $SCRIPTING ] ; then
prefix='# '
fi
# skip...
if [[ "${!2}" == "SKIP" ]] \
|| [[ "$(eval "echo \$DFL_$2")" == "SKIP" ]] ; then
@ -185,7 +192,7 @@ xread(){
return
fi
if [ -z ${!2} ] ; then
eval 'read -ep "'$1'" -i "$DFL_'$2'" '${2}''
eval 'read -ep "'$prefix''$1'" -i "$DFL_'$2'" '${2}''
XREAD_VARS+=(${2})
fi
if [ -z $non_empty ] ; then
@ -200,12 +207,16 @@ xread(){
#
xreadYes(){
if [ -z ${2} ] ; then
local var=__X
local __X
local var=__LOCAL
local __LOCAL
else
local var=${2}
local mode=
fi
local prefix=
if [ $SCRIPTING ] ; then
prefix='# '
fi
# XXX check DFL_..???
if [[ "${!var}" == "SKIP" ]] ; then
eval "$var="
@ -221,7 +232,7 @@ xreadYes(){
local no=n
local dfl=1
fi
eval 'read -ep "'$1' ('$yes'/'$no') " '${var}''
eval 'read -ep "'$prefix''$1' ('$yes'/'$no') " '${var}''
XREAD_VARS+=(${var})
# normalize...
eval "${var}=${!var,,}"
@ -235,6 +246,7 @@ xreadYes(){
fi
fi
[ $SCRIPTING ] \
&& [[ "$var" != '__LOCAL' ]] \
&& echo "$var=${!var}"
if [ -z ${!var} ] ; then
@ -249,18 +261,22 @@ xreadpass(){
if [[ ${!1} == 'SKIP' ]] ; then
return
fi
local prefix=
if [ $SCRIPTING ] ; then
prefix='# '
fi
local PASS1
local PASS2
for attempt in 1 2 3 ; do
read -sep "password (Enter to skip): " PASS1
read -sep "${prefix}password (Enter to skip): " PASS1
echo
if [ -z $PASS1 ] ; then
return
fi
read -sep "retype password: " PASS2
read -sep "${prefix}retype password: " PASS2
echo
if [[ $PASS1 != $PASS2 ]] ; then
echo "ERR: passwords do not match."
echo "ERROR: passwords do not match." >&2
continue
fi
eval ''$1'='${PASS1}''

View File

@ -49,7 +49,7 @@ if xreadYes "# Update system?" UPDATE ; then
@ apt upgrade
fi
if xreadYes "# Install additional apps?" APPS ; then
@ apt install $(SOFTWARE[@])
@ apt install ${SOFTWARE[@]}
fi
# Networking
@ -67,11 +67,26 @@ if xreadYes "# Create bridges?" BRIDGES ; then
xread "Gate ADMIN IP: " GATE_ADMIN_IP
readBridgeVars
# check if new bridges already exist in interfaces...
if [ -e /etc/network/interfaces ] \
&& grep -q \
"vmbr\(${WAN_BRIDGE}\|${LAN_BRIDGE}\|${ADMIN_BRIDGE}\)" \
/etc/network/interfaces ; then
conflict=
for br in WAN_BRIDGE LAN_BRIDGE ADMIN_BRIDGE ; do
if grep -q "vmbr${!br}" /etc/network/interfaces ; then
conflict="${conflict}, vmbr${!br} (${br})"
fi
done
echo "ERROR: will not overwrite existing bridges: ${conflict:2}" >&2
exit 1
fi
@ cp /etc/network/interfaces{,.new}
BRIDGES="${\
BRIDGES="$(\
cat bridges.tpl \
| expandPCTTemplate WAN_PORT ADMIN_PORT}"
| expandPCTTemplate WAN_PORT ADMIN_PORT)"
# XXX add $BRIDGES to /etc/network/interfaces either before the
# source command or at the end...