From 789a6e376943b768befa43a8abd668665f9cf6a5 Mon Sep 17 00:00:00 2001 From: Darren 'Tadgy' Austin Date: Sun, 29 Nov 2020 03:09:51 +0000 Subject: Update write out of rc.inet1.conf to new format. +more Change to new format IP6ADDRS when writing out /etc/networks. Remove old syntax variables. Use 'Exit' as cancel button label on some dialogs. Changed a couple of occurances of cancel to abandon for clarity. --- netconfig | 122 ++++++++++++++++++++++++++++---------------------------------- 1 file changed, 54 insertions(+), 68 deletions(-) (limited to 'netconfig') diff --git a/netconfig b/netconfig index 0f1ce44..4d8fbc9 100644 --- a/netconfig +++ b/netconfig @@ -13,17 +13,13 @@ write_config_files() { # If we're doing loopback, we don't want 127.0.0.1 and 255.255.255.0 in # rc.inet1.conf... it's better to leave the values null. However, since # we use the IP in other places, we need to make a copy for here. -RCIPCOPY=$IPADDR -RCMASKCOPY=$NETMASK -RCIP6COPY=$IPADDR6 -RCPREFIXCOPY=$PREFIX6 -if [ "$RCIPCOPY" = "127.0.0.1" ]; then - RCIPCOPY="" - RCMASKCOPY="" +RCIPCOPY=("${IPADDRS[@]}") +RCIP6COPY=("${IP6ADDRS[@]}") +if [ "${RCIPCOPY[0]}" = "127.0.0.1/8" ]; then + RCIPCOPY=() fi -if [ "$RCIP6COPY" = "::1" ]; then - RCIP6COPY="" - RCPREFIXCOPY="" +if [ "${RCIP6COPY[0]}" = "::1/128" ]; then + RCIP6COPY=() fi # echo "Creating /$RC..." @@ -47,56 +43,53 @@ fi # ============================================================================= -# IPv4 config information for eth0: ENDFILE if [ -n "$VLAN" ]; then - echo "IFNAME[0]=\"eth0.$(( 10#$VLAN ))\"" >>$RC + VLAN=".$(( 10#$VLAN ))" + echo "IFNAME[0]=\"eth0$VLAN\"" >>$RC fi /bin/cat << ENDFILE >> $RC -IPADDR[0]="$RCIPCOPY" -NETMASK[0]="$RCMASKCOPY" -IPALIASES[0]="" +# IPv4 config options for eth0$VLAN: +IPADDRS[0]="${RCIPCOPY[@]}" USE_DHCP[0]="$USE_DHCP" -DHCP_HOSTNAME[0]="$DHCP_HOSTNAME" -# IPv6 config information for eth0: -IP6ADDRS[0]="`if [ ! \"$RCIP6COPY\" = \"\" ]; then echo \"$RCIP6COPY/$RCPREFIXCOPY\"; fi`" +# IPv6 config options for eth0$VLAN: +IP6ADDRS[0]="${RCIP6COPY[@]}" USE_SLAAC[0]="$USE_SLAAC" USE_DHCP6[0]="$USE_DHCP6" +# Generic options for eth0$VLAN: +DHCP_HOSTNAME[0]="$DHCP_HOSTNAME" -# IPv4 config information for eth1: -IPADDR[1]="" -NETMASK[1]="" -IPALIASES[1]="" +# IPv4 config options for eth1: +IPADDRS[1]="" USE_DHCP[1]="" -DHCP_HOSTNAME[1]="" -# IPv6 config information for eth1: +# IPv6 config options for eth1: IP6ADDRS[1]="" USE_SLAAC[1]="" USE_DHCP6[1]="" +# Generic options for eth1: +DHCP_HOSTNAME[1]="" -# IPv4 config information for eth2: -IPADDR[2]="" -NETMASK[2]="" -IPALIASES[2]="" +# IPv4 config options for eth2: +IPADDRS[2]="" USE_DHCP[2]="" -DHCP_HOSTNAME[2]="" -# IPv6 config information for eth2: +# IPv6 config options for eth2: IP6ADDRS[2]="" USE_SLAAC[2]="" USE_DHCP6[2]="" +# Generic options for eth2: +DHCP_HOSTNAME[2]="" -# IPv4 config information for eth3: -IPADDR[3]="" -NETMASK[3]="" -IPALIASES[3]="" +# IPv4 config options for eth3: +IPADDRS[3]="" USE_DHCP[3]="" -DHCP_HOSTNAME[3]="" -# IPv6 config information for eth3: +# IPv6 config options for eth3: IP6ADDRS[3]="" USE_SLAAC[3]="" USE_DHCP6[3]="" +# Generic options for eth3: +DHCP_HOSTNAME[3]="" # IPv4 default gateway IP address: GATEWAY="$GATEWAY" @@ -215,12 +208,16 @@ GATEWAY6="$GATEWAY6" #WLAN_WPADRIVER[4]="wext" #WLAN_WPAWAIT[4]=30 - # ============================================================================= # Some examples of additional network parameters that you can use. #IFNAME[4]="wlan0" # Use a different interface name instead of # the default 'eth4' +#IFOPTS[4]="" # A pipe (|) delimited list of interface type + # specific options to apply. These options + # can be found in the ip-link(8) man page in + # the approprite section for the interface + # type being configured. #IPALIASES[4]="192.168.5.10/24" # A space delimited list of CIDR formatted IP # aliases to assign to the interface after it # has come up. If no / is given after @@ -268,13 +265,14 @@ GATEWAY6="$GATEWAY6" # ============================================================================= -# Change this to "yes" for debugging output to stdout. +# Change this to "yes" for debugging output to syslog (if available, stdout if +# not). DEBUG_ETH_UP="no" # MAXNICS is the maximum number of interfaces that will be configured. # You may need to increase the MAXNICS value if you have many interfaces, or # you use multiple VLANs and/or bridges. The default is 6. -# MAXNICS="6" +#MAXNICS="6" ENDFILE # ############################################################################ @@ -319,8 +317,8 @@ chmod 644 $ETCNETWORKS 127.0.0.1 localhost ::1 localhost EOF -[ -n "$IPADDR" ] && echo -e "$IPADDR\t\t$HOSTNM.$DOMAIN $HOSTNM" >>$HOSTS -[ -n "$IPADDR6" ] && echo -e "$IPADDR6\t\t$HOSTNM.$DOMAIN $HOSTNM" >>$HOSTS +[ -n "${IPADDRS[0]}" ] && echo -e "${IPADDRS[0]}\t\t$HOSTNM.$DOMAIN $HOSTNM" >>$HOSTS +[ -n "${IP6ADDRS[0]}" ] && echo -e "${IP6ADDRS[0]}\t\t$HOSTNM.$DOMAIN $HOSTNM" >>$HOSTS chmod 644 $HOSTS # ############################################################################ @@ -445,17 +443,12 @@ HOSTS=etc/hosts # Where hosts file is. ETCNETWORKS=etc/networks # Where networks file is. # # defaults: +IPADDRS=() +IP6ADDRS=() USE_DHCP="" # Use DHCP? "" == no. USE_DHCP6="" DHCP_HOSTNAME="" # This is our DHCP hostname. NETWORK=127.0.0.0 -IPADDRS=() -IP6ADDRS=() -# FIXME: Now deprecated: -IPADDR=127.0.0.1 -NETMASK=24 # Use CIDR now. -IPADDR6=::1 -PREFIX6=64 while [ 0 ]; do cat << EOF > $TMP/tempmsg @@ -465,8 +458,8 @@ For example: darkstar Enter hostname: EOF - dialog --title "ENTER HOSTNAME" --inputbox "`cat $TMP/tempmsg`" 12 64 \ - "$HOSTNM" 2> $TMP/SeThost + dialog --title "ENTER HOSTNAME" --cancel-label "Exit" --inputbox \ + "`cat $TMP/tempmsg`" 12 64 "$HOSTNM" 2> $TMP/SeThost if [ $? = 1 -o $? = 255 ]; then rm -f $TMP/SeThost $TMP/tempmsg exit @@ -495,8 +488,8 @@ Do not supply a leading '.' Enter domain name for $HOSTNM: EOF - dialog --title "ENTER DOMAINNAME FOR '$HOSTNM'" --inputbox \ - "`cat $TMP/tempmsg`" 12 59 "$DOMAIN" 2> $TMP/SeTdom + dialog --title "ENTER DOMAINNAME FOR '$HOSTNM'" --cancel-label "Exit" \ + --inputbox "`cat $TMP/tempmsg`" 12 59 "$DOMAIN" 2> $TMP/SeTdom if [ $? = 1 -o $? = 255 ]; then rm -f $TMP/SeTdom $TMP/tempmsg exit @@ -518,15 +511,6 @@ and dots, and may not begin or end with a hyphen or dot." 7 68 fi done -# Write the hostname with domain to /etc/HOSTNAME: -# Do this at the end when writing all the config files. -# echo $HOSTNM.$DOMAIN > etc/HOSTNAME -## OBSOLETE with recent NetworkManager: -## Also make sure the hostname is written to /etc/NetworkManager/NetworkManager.conf: -#if [ -w etc/NetworkManager/NetworkManager.conf ]; then -# sed -i "s/^hostname=.*$/hostname=$HOSTNM/g" etc/NetworkManager/NetworkManager.conf -#fi - dialog --title "CONNECT VIA VLAN" --defaultno --yesno \ "Some advanced networking set ups require a VLAN ID in order to \ connect to the network. Do you wish to configure a VLAN ID now?\n\n\ @@ -884,11 +868,11 @@ a nameserver?" 5 42 dialog --title "ENTER NAMESERVER IP ADDRESS" --cancel-label "Skip" \ --inputbox \ "Please give the IP address of the name server to use, such as - $DNSSAMPLE + ${DNSSAMPLE:-1:2:3:4::1} You can add more Domain Name Servers later by editing /$RESOLV. -Primary name server to use:" 13 65 $DNSDEFAULT 2> $TMP/SeTns +Primary name server to use:" 13 65 "$DNSDEFAULT" 2> $TMP/SeTns ERRNO="$?" if [ $ERRNO = 255 ]; then rm -f $TMP/SeTns @@ -919,6 +903,10 @@ Primary name server to use:" 13 65 $DNSDEFAULT 2> $TMP/SeTns fi done fi +elif [ "$LOOPBACK" = "yes" ]; then + IPADDRS=(127.0.0.1/8) + IP6ADDRS=(::1/128) + VLAN="" fi # Check for existing network driver: @@ -999,13 +987,11 @@ system is now configured to use loopback: IP addresses: 127.0.0.1/8 ::1/128 -Is this correct? Press 'Yes' to continue, or 'No' to reconfigure." 9 70 +Is this correct? Press 'Yes' to continue, or 'No' to abandon." 9 70 RETVAL=$? if [ "$RETVAL" = "255" ]; then exit fi - IPADDRS=( 127.0.0.1/8 ) - IP6ADDRS=( ::1/128 ) elif [ "$LOOPBACK" = "yes" -a "$NETWORKMANAGER" = "yes" ]; then dialog --title "NETWORK SETUP COMPLETE" --yesno "Your networking \ system is now configured to use NetworkManager for @@ -1013,7 +999,7 @@ wired and wireless network management. To set up wireless networks and view status, add the Network Management control panel widget to your desktop. -Is this correct? Press 'Yes' to confirm, or 'No' to reconfigure." 10 71 +Is this correct? Press 'Yes' to confirm, or 'No' to abandon." 10 71 RETVAL=$? if [ "$RETVAL" = "255" ]; then exit @@ -1027,7 +1013,7 @@ elif [ "$USE_SLAAC" = "yes" ]; then IP addresses: (use IPv6 SLAAC) Nameserver: ${NAMESERVER:-(none)} -If this is correct, hit 'Yes' to confirm, or 'No' to cancel." 12 66 +If this is correct, hit 'Yes' to confirm, or 'No' to abandon." 12 66 RETVAL=$? if [ "$RETVAL" = "255" ]; then exit -- cgit v1.2.3