summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarren 'Tadgy' Austin <darren@afterdark.org.uk>2020-11-28 21:23:25 +0000
committerRobby Workman <rworkman@slackware.com>2021-02-27 23:47:58 -0600
commitbb5d94a4b50b1ba9bcdf9cc3c034492fec509efe (patch)
tree976b25195e545da00ea1b86ed5080729d2e2b15d
parent97cb19aad5d4083b7c684b50609e90a927ebcd62 (diff)
downloadslacknetsetup-bb5d94a4b50b1ba9bcdf9cc3c034492fec509efe.tar.xz
Updated nameserver processing handling to include syntax checks + more.
When creating example for nameserver dialog, take into account multiple IPs. Add the . to the VLAN part When writing rc.inet1.conf. Update SLAAC final confirmation dialog to match output of DHCP confirmation. Update final confirmation for static IPs to include IPv6 and VLAN ID. Include VLAN ID in DHCP final confirmation screen. Unconditionally output final info screen, ref accepted/discarded settings. Update static IP infomarion input/processing.
-rw-r--r--netconfig132
1 files changed, 82 insertions, 50 deletions
diff --git a/netconfig b/netconfig
index 66eb682..acb9a85 100644
--- a/netconfig
+++ b/netconfig
@@ -51,7 +51,7 @@ fi
ENDFILE
if [ -n "$VLAN" ]; then
- echo "IFNAME[0]=\"eth0$VLAN\"" >>$RC
+ echo "IFNAME[0]=\"eth0.$(( 10#$VLAN ))\"" >>$RC
fi
/bin/cat << ENDFILE >> $RC
@@ -553,7 +553,6 @@ else
continue
else
rm -f $TMP/SeTVLAN
- VLAN=".$(( 10#$VLAN ))"
break
fi
fi
@@ -668,7 +667,6 @@ address, just leave it blank or select 'Skip'." \
IPADDRS=($(cat $TMP/SeTIPSv4))
rm -f $TMP/SeTIPSv4
if [ "${IPADDRS[*]}" = "" ]; then
- rm -f $TMP/SeTIPSv4
break
fi
for ((I=0; I < ${#IPADDRS[@]}; I++)); do
@@ -681,7 +679,7 @@ address, just leave it blank or select 'Skip'." \
rm -f $TMP/SeTIPSv4
exit
fi
- continue
+ continue 2
fi
syntax_check_v4 "$IP" 4 WARN || continue 2
if [ "$MASK" = "" ] || [ "$IP" = "$MASK" ]; then
@@ -717,7 +715,12 @@ If you don't have an IPv4 gateway on your network, leave it blank
or select 'Skip'.
Enter IPv4 gateway address:" 14 69 "$GATEWAY" 2> $TMP/SeTgateway4
- if [ $? = 1 -o $? = 255 ]; then
+ ERRNO="$?"
+ if [ "$ERRNO" = "1" ]; then
+ GATEWAY=""
+ rm -f $TMP/SeTgateway4
+ break
+ elif [ "$ERRNO" = "255" ]; then
rm -f $TMP/SeTgateway4
exit
fi
@@ -744,7 +747,7 @@ Enter IPv4 gateway address:" 14 69 "$GATEWAY" 2> $TMP/SeTgateway4
space delimited, IPv6 addresses with their prefixes in the format:
<IP address>/<prefix>
For example:
- 1a:1b:1c:1d::abc/64 or 1a:1b:1c:1d::abc/64 fe80::2:3:4:abc/64
+ 1a:1b:1c:1d::abc/64 or 1a:1b:1c:1d::abc/64 2b2c::2:3:4:abc/64
If a prefix is not specified a default of 64 will be used.
If you do not want to configure a static IPv6 address or don't
@@ -752,7 +755,7 @@ know what to put, just leave it blank or select 'Skip'." \
16 70 "${IP6ADDRS[*]}" 2> $TMP/SeTIPSv6
ERRNO="$?"
if [ "$ERRNO" = "1" ]; then
- IPA6DDRS=()
+ IP6ADDRS=()
rm -f $TMP/SeTIPSv6
break
elif [ "$ERRNO" = "255" ]; then
@@ -762,11 +765,9 @@ know what to put, just leave it blank or select 'Skip'." \
IP6ADDRS=($(cat $TMP/SeTIPSv6))
rm -f $TMP/SeTIPSv6
if [ "${IP6ADDRS[*]}" = "" ]; then
- rm -f $TMP/SeTIPSv6
break
fi
for ((I=0; I < ${#IP6ADDRS[@]}; I++)); do
-# FIXME:
IP="${IP6ADDRS[$I]%/*}"
PREFIX="${IP6ADDRS[$I]#*/}"
if [ "$IP" = "" ]; then
@@ -776,7 +777,7 @@ know what to put, just leave it blank or select 'Skip'." \
rm -f $TMP/SeTIPSv6
exit
fi
- continue
+ continue 2
fi
syntax_check_v6 "$IP" || continue 2
if [ "$PREFIX" = "" ] || [ "$IP" == "$PREFIX" ]; then
@@ -802,9 +803,9 @@ Valid prefixes will be in the range 1-128." 6 70
if [ ! "${IP6ADDRS[*]}" = "" ]; then
while [ 0 ]; do
if [ -r $TMP/SeTgateway6 ]; then
- GATEWAY6=`cat $TMP/SeTgateway6`
+ GATEWAY6="`cat $TMP/SeTgateway6`"
fi
- dialog --title "ENTER IPv6 GATEWAY ADDRESS" --inputbox \
+ dialog --title "ENTER IPv6 GATEWAY ADDRESS" --cancel-label "Skip" --inputbox \
"Enter the address for the IPv6 gateway on your network, such as:
fe80:426c:ffff::1
@@ -814,6 +815,7 @@ or select 'Skip'.
Enter IPv6 gateway address:" 14 69 "$GATEWAY6" 2> $TMP/SeTgateway6
ERRNO="$?"
if [ "$ERRNO" = "1" ]; then
+ GATEWAY6=""
rm -f $TMP/SeTgateway6
break
elif [ "$ERRNO" = "255" ]; then
@@ -821,7 +823,7 @@ Enter IPv6 gateway address:" 14 69 "$GATEWAY6" 2> $TMP/SeTgateway6
exit
fi
GATEWAY6="`cat $TMP/SeTgateway6`"
- # rm -f $TMP/SeTgateway6
+ rm -f $TMP/SeTgateway6
if [ "$GATEWAY6" = "" ]; then
break
fi
@@ -852,37 +854,62 @@ if [ "$LOOPBACK" = "no" ]; then
dialog --title "USE A NAMESERVER?" --yesno "Do you wish to configure \
a nameserver?" 5 42
if [ $? = 0 ]; then
- if [ ! "$IPADDR" = "" ]; then
+ if [ ! "${IPADDRS[*]}" = "" ]; then
if [ ! "$GATEWAY" = "" ]; then
DNSSAMPLE="$GATEWAY"
DNSDEFAULT="$GATEWAY"
else
- DNSSAMPLE="`echo $IPADDR | cut -f 1-3 -d .`.1"
+ DNSSAMPLE="`echo ${IPADDRS[0]} | cut -f 1-3 -d .`.1"
+ DNSDEFAULT="${DNSSAMPLE%.1}."
fi
fi
- if [ ! "$IPADDR6" = "" ]; then
+ if [ ! "${IP6ADDRS[*]}" = "" ]; then
if [ ! "$GATEWAY6" = "" ]; then
- DNSSAMPLE="$DNSSAMPLE or $GATEWAY6"
+ DNSSAMPLE="${DNSSAMPLE:+$DNSSAMPLE or }$GATEWAY6"
# Keep the v4 nameserver the default, for now.
- # DNSDEFAULT="$GATEWAY6"
+ DNSDEFAULT="${DNSDEFAULT:-$GATEWAY6}"
else
- DNSSAMPLE="or fe80:426c:ffff::1"
+ DNSSAMPLE="${DNSSAMPLE:+$DNSSAMPLE or }${IP6ADDRS[0]%:*}:1"
+ DNSDEFAULT="${DNSSAMPLE:-${IP6ADDRS[0]%:*}}:"
fi
fi
while [ "$NAMESERVER" = "" ]; do
- dialog --title "ENTER NAMESERVER IP ADDRESS" --inputbox \
+ dialog --title "ENTER NAMESERVER IP ADDRESS" --cancel-label "Skip" \
+ --inputbox \
"Please give the IP address of the name server to use, such as
$DNSSAMPLE
You can add more Domain Name Servers later by editing
/$RESOLV.
Primary name server to use:" 13 65 $DNSDEFAULT 2> $TMP/SeTns
- if [ $? = 1 -o $? = 255 ]; then
- rm -f $TMP/SeTns
- break
+ ERRNO="$?"
+ if [ $ERRNO = 255 ]; then
+ rm -f $TMP/SeTns
+ exit
+ elif [ $ERRNO = 1 ]; then
+ rm -f $TMP/SeTns
+ NAMESERVER=""
+ break
+ else
+ NAMESERVER="`cat $TMP/SeTns`"
+ rm -f $TMP/SeTns
+ if [[ "$NAMESERVER" =~ ^.*:.*$ ]]; then
+ syntax_check_v6 "$NAMESERVER"
+ if [ ! $? = 0 ]; then
+ DNSDEFAULT="$NAMESERVER"
+ NAMESERVER=""
+ continue
+ fi
+ else
+ syntax_check_v4 "$NAMESERVER" 4 WARN
+ if [ ! $? = 0 ]; then
+ DNSDEFAULT="$NAMESERVER"
+ NAMESERVER=""
+ continue
+ fi
+ fi
+ break
fi
- NAMESERVER="`cat $TMP/SeTns`"
- rm -f $TMP/SeTns
done
fi
fi
@@ -890,7 +917,7 @@ fi
# Check for existing network driver:
unset DONOTPROBE
if cat /proc/net/dev | grep eth0 1> /dev/null 2> /dev/null ; then
- DONOTPROBE=true
+ DONOTPROBE=true
fi
# Really, this rc.netdevice thing is mostly obsolete except for
@@ -986,24 +1013,32 @@ Is this correct? Press 'Yes' to confirm, or 'No' to reconfigure." 10 71
fi
elif [ "$USE_SLAAC" = "yes" ]; then
dialog --title "NETWORK SETUP COMPLETE" --yesno \
-"Your system is now set up to autoconfigure an IPv6 IP address.
-If this is correct, hit 'Yes' to confirm, or 'No' to cancel." 6 66
-RETVAL=$?
+"Your system is now set up to autoconfigure an IPv6 IP address:
+ Hostname: $HOSTNM
+ Domain name: $DOMAIN
+ VLAN ID: ${VLAN:-(none)}
+ IP addresses: (use IPv6 SLAAC)
+ Nameserver: ${NAMESERVER:-(none)}
+
+If this is correct, hit 'Yes' to confirm, or 'No' to cancel." 12 66
+ RETVAL=$?
+ if [ "$RETVAL" = "255" ]; then
+ exit
+ fi
elif [ "$USE_DHCP" = "" -a "$USE_DHCP6" = "" ]; then
while [ 0 ]; do
dialog --title "CONFIRM NETWORK SETUP" \
---ok-label Accept --extra-label Edit --cancel-label Restart --inputmenu \
+--ok-label Accept --extra-label Edit --cancel-label Abandon --inputmenu \
"These are the settings you have entered. To accept them and complete \
the networking setup, press ENTER. If you need to make any changes, you \
can do that now using 'Edit' (or reconfigure later using 'netconfig')." \
24 75 15 \
"Hostname:" "$HOSTNM" \
"Domain Name:" "$DOMAIN" \
-"IPv4 Address:" "$IPADDR" \
-"IPv4 Netmask:" "$NETMASK" \
+"VLAN ID:" "$VLAN" \
+"IPv4 Addresses:" "${IPADDRS[*]}" \
"IPv4 Gateway:" "$GATEWAY" \
-"IPv6 Address:" "$IPADDR6" \
-"IPv6 Prefix:" "$PREFIX6" \
+"IPv6 Addresses:" "${IP6ADDRS[*]}" \
"IPv6 Gateway:" "$GATEWAY6" \
"Nameserver:" "$NAMESERVER" 2> $TMP/tempmsg
RETVAL=$?
@@ -1014,21 +1049,21 @@ can do that now using 'Edit' (or reconfigure later using 'netconfig')." \
HOSTNM=$NEWVAL
elif [ "$FIELD" = "Domain Name" ]; then
DOMAIN=$NEWVAL
- elif [ "$FIELD" = "IPv4 Address" ]; then
- IPADDR=$NEWVAL
- elif [ "$FIELD" = "IPv4 Netmask" ]; then
- NETMASK=$NEWVAL
+ elif [ "$FIELD" = "VLAN ID" ]; then
+ VLAN=$NEWVAL
+ elif [ "$FIELD" = "IPv4 Addresses" ]; then
+ IPADDRS=( $NEWVAL )
elif [ "$FIELD" = "IPv4 Gateway" ]; then
GATEWAY=$NEWVAL
- elif [ "$FIELD" = "IPv6 Address" ]; then
- IPADDR6=$NEWVAL
- elif [ "$FIELD" = "IPv6 Prefix" ]; then
- PREFIX6=$NEWVAL
+ elif [ "$FIELD" = "IPv6 Addresses" ]; then
+ IP6ADDRS=( $NEWVAL )
elif [ "$FIELD" = "IPv6 Gateway" ]; then
GATEWAY6=$NEWVAL
elif [ "$FIELD" = "Nameserver" ]; then
NAMESERVER=$NEWVAL
fi
+ elif [ "$RETVAL" = "255" ]; then
+ exit
else
break
fi
@@ -1039,13 +1074,14 @@ else # DHCP was used
Hostname: $HOSTNM
Domain name: $DOMAIN
- DHCP hostname: $DHCP_HOSTNAME
+ VLAN ID: ${VLAN:-(none)}
+ DHCP hostname: ${DHCP_HOSTNAME:-(none)}
IP addresses: (use DHCP server)
Netmask & Prefix: (use DHCP server)
Gateways: (use DHCP server)
Nameserver: (use DHCP server)
-Is this correct? Press 'Yes' to continue, or 'No' to reconfigure." 15 76
+Is this correct? Press 'Yes' to continue, or 'No' to reconfigure." 16 76
RETVAL=$?
fi
@@ -1060,13 +1096,9 @@ if [ "$RETVAL" = "0" ]; then
if [ "$NETWORKMANAGER" = "yes" -a -r etc/rc.d/rc.networkmanager ]; then
chmod 755 etc/rc.d/rc.networkmanager
fi
- if [ "$1" = "" ]; then
- dialog --msgbox "Settings accepted. Basic network configuration is complete." 6 40
- fi
+ dialog --msgbox "Settings accepted. Basic network configuration is complete." 6 40
else
- if [ "$1" = "" ]; then
- dialog --msgbox "Settings discarded. Run the 'netconfig' command again if you need to reconfigure your network settings." 6 60
- fi
+ dialog --msgbox "Settings discarded. Run the 'netconfig' command again if you need to reconfigure your network settings." 6 60
fi
exit $RETVAL