fix: removing ",gw=" from GATE variable when reading/writing from/to config. (#6177)

Previously when creating a config, GATE variable would incluse ",gw="
which was crashing the installer script when read later on.
This fix:
1. writes GATE variable to config without ",gw="
2. removes ",gw=" from GATE variable when reading existing config

Co-authored-by: teohz <git@teohz.com>
This commit is contained in:
teohz 2025-07-28 13:11:52 +00:00 committed by GitHub
parent 7b82199a36
commit 15e3958687
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -249,6 +249,7 @@ write_config() {
# This function writes the configuration to a file.
if whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "Write configfile" --yesno "Do you want to write the selections to a config file?" 10 60; then
FILEPATH="/opt/community-scripts/${NSAPP}.conf"
[[ "$GATE" =~ ",gw=" ]] && local GATE="${GATE##,gw=}"
if [[ ! -f $FILEPATH ]]; then
cat <<EOF >"$FILEPATH"
# ${NSAPP} Configuration File

View File

@ -272,7 +272,8 @@ config_file() {
GATE=""
elif [[ "$NET" =~ $ip_cidr_regex ]]; then
echo -e "${NETWORK}${BOLD}${DGN}IP Address: ${BGN}$NET${CL}"
if [ ! -z "$GATE" ]; then
if [[ -n "$GATE" ]]; then
[[ "$GATE" =~ ",gw=" ]] && GATE="${GATE##,gw=}"
if [[ "$GATE" =~ $ip_regex ]]; then
echo -e "${GATEWAY}${BOLD}${DGN}Gateway IP Address: ${BGN}$GATE${CL}"
GATE=",gw=$GATE"