From: Zoltán Felleg Date: Sat, 2 May 2026 20:43:44 +0000 (+0200) Subject: Updated all containers (updated/parametrized 01_setupnetworking.sh). X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=3d11770945fc30ea93bb0b04829910db4476cbb5;p=user-lxc.git Updated all containers (updated/parametrized 01_setupnetworking.sh). --- diff --git a/sources/db2.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/db2.in/c3d/firstboot/scripts/01_setupnetworking.sh index 9912399..90989c2 100755 --- a/sources/db2.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/db2.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,18 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="db2.in.useribm.hu" +IPV4_ADDRESSES="10.228.109.166/16" +IPV4_DNS="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" +IPV6_ADDRESSES="2001:1aa1:000a:7dae:000c:18ff:fe03:6da6/64" +IPV6_DNS="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" +IPV6_DNS_SEARCH="in.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" sleep 1 @@ -10,7 +22,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,68 +30,104 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.166/16" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:6da6/64" \ - ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" \ - ipv6.dns-search "in.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -90,5 +138,5 @@ EOF nmcli connection show -hostnamectl hostname db2.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/efg.pm/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/efg.pm/c3d/firstboot/scripts/01_setupnetworking.sh index 72556fb..f72fba5 100755 --- a/sources/efg.pm/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/efg.pm/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,24 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_DEVICE_PM="eth0" +CONNECTION_DEVICE_EX="eth1" +CONNECTION_ID_PM="perimeter" +CONNECTION_ID_EX="external" +FQ_HOSTNAME="efg.pm.useribm.hu" +IPV4_ADDRESSES_PM="192.168.173.254/24" +IPV4_DNS_PM="192.168.173.223" +IPV4_DNS_SEARCH_PM="pm.useribm.hu" +IPV4_ROUTES_PM="10.228.0.0/16 192.168.173.1, 192.168.42.0/24 192.168.173.1, 192.168.43.0/24 192.168.173.1" +IPV6_ADDRESSES_PM="2001:1aa1:000a:7c0c:000c:18ff:fe03:adfe/64" +IPV6_DNS_PM="2001:1aa1:000a:7c0c:000c:18ff:fe03:addf" +IPV6_DNS_SEARCH_PM="pm.useribm.hu" +IPV4_ADDRESSES_EX="213.253.216.162/28, 213.253.216.163/28, 213.253.216.164/28, 213.253.216.165/28, 213.253.216.166/28, 213.253.216.167/28, 213.253.216.168/28" +IPV4_GATEWAY_EX="213.253.216.161" +IPV6_ADDRESSES_EX="2001:1aa1:000a:ba2e:000c:18ff:fe03:adfe, 2001:1aa4:0001:0000:0000:0000:0000:000f/127" +IPV6_GATEWAY_EX="2001:1aa4:0001:0000:0000:0000:0000:000e" sleep 1 @@ -10,7 +28,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,51 +36,85 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the three network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the two ethernet connections to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 3 ] +while [ $ACTIVE_CONNECTIONS -lt 2 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "Less than two active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connections" + echo -n "Waiting for the ethernet " + echo -n "connections to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 3 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 2 ] then - echo "Number of connections: $CONNECTIONS instead of 3" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 2" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE_PM="eth0" -CONNECTION_DEVICE_EX="eth1" -CONNECTION_ID_PM="perimeter" -CONNECTION_ID_EX="external" -CONNECTION_LINE_PM=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE_PM}$") -CONNECTION_LINE_EX=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE_EX}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE_PM=$(nmcli --terse connection show \ + | grep ":${CONNECTION_DEVICE_PM}$") +CONNECTION_LINE_EX=$(nmcli --terse connection show \ + | grep ":${CONNECTION_DEVICE_EX}$") CONNECTION_UUID_PM=$(echo $CONNECTION_LINE_PM | cut -f 2 -d ':') CONNECTION_UUID_EX=$(echo $CONNECTION_LINE_EX | cut -f 2 -d ':') @@ -70,22 +122,20 @@ nmcli connection delete uuid "$CONNECTION_UUID_PM" nmcli connection delete uuid "$CONNECTION_UUID_EX" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID_PM \ - connection.interface-name $CONNECTION_DEVICE_PM \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID_PM" \ + connection.interface-name "$CONNECTION_DEVICE_PM" \ connection.type 802-3-ethernet \ - ipv4.addresses "192.168.173.254/24" \ - ipv4.dns "192.168.173.223" \ - ipv4.dns-search "pm.useribm.hu" \ + ipv4.addresses "$IPV4_ADDRESSES_PM" \ + ipv4.dns "$IPV4_DNS_PM" \ + ipv4.dns-search "$IPV4_DNS_SEARCH_PM" \ ipv4.method "manual" \ - ipv4.routes "10.228.0.0/16 192.168.173.1, \ - 192.168.42.0/24 192.168.173.1, \ - 192.168.43.0/24 192.168.173.1" \ - ipv6.addresses "2001:1aa1:000a:7c0c:000c:18ff:fe03:adfe/64" \ - ipv6.dns "2001:1aa1:000a:7c0c:000c:18ff:fe03:addf" \ - ipv6.dns-search "pm.useribm.hu" \ + ipv4.routes "$IPV4_ROUTES_PM" \ + ipv6.addresses "$IPV6_ADDRESSES_PM" \ + ipv6.dns "$IPV6_DNS_PM" \ + ipv6.dns-search "$IPV6_DNS_SEARCH_PM" \ ipv6.method "manual" \ - ipv6.routes "2001:1aa1:000a:7dae::/64 2001:1aa1:000a:7c0c:000c:18ff:fe03:ad01" \ + ipv6.routes "$IPV6_ROUTES_PM" \ save yes cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE_PM}.conf @@ -96,19 +146,16 @@ keep-configuration=no EOF nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID_EX \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID_EX" \ connection.interface-name $CONNECTION_DEVICE_EX \ connection.type 802-3-ethernet \ - ipv4.addresses "213.253.216.162/28, 213.253.216.163/28, \ - 213.253.216.164/28, 213.253.216.165/28, \ - 213.253.216.166/28, 213.253.216.167/28, \ - 213.253.216.168/28" \ - ipv4.gateway "213.253.216.161" \ + ipv4.addresses "$IPV4_ADDRESSES_EX" \ + ipv4.gateway "$IPV4_GATEWAY_EX" \ ipv4.method "manual" \ ipv4.route-metric 100 \ - ipv6.addresses "2001:1aa1:000a:ba2e:000c:18ff:fe03:adfe, 2001:1aa4:0001:0000:0000:0000:0000:000f/127" \ - ipv6.gateway "2001:1aa4:0001:0000:0000:0000:0000:000e" \ + ipv6.addresses "$IPV6_ADDRESSES_EX" \ + ipv6.gateway "$IPV6_GATEWAY_EX" \ ipv6.method "manual" \ ipv6.route-metric 100 \ save yes @@ -122,5 +169,5 @@ EOF nmcli connection show -hostnamectl hostname efg.pm.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/ens.pm/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/ens.pm/c3d/firstboot/scripts/01_setupnetworking.sh index c7a3cea..755d5b3 100755 --- a/sources/ens.pm/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/ens.pm/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,20 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="perimeter" +FQ_HOSTNAME="ens.pm.useribm.hu" +IPV4_ADDRESSES="192.168.173.147/24" +IPV4_DNS="192.168.173.223" +IPV4_DNS_SEARCH="pm.useribm.hu" +IPV4_GATEWAY="192.168.173.254" +IPV4_ROUTES="10.228.0.0/16 192.168.173.1" +IPV6_ADDRESSES="2001:1aa1:000a:7c0c:000c:18ff:fe03:ad93/64" +IPV6_DNS="2001:1aa1:000a:7c0c:000c:18ff:fe03:addf" +IPV6_DNS_SEARCH="pm.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7c0c:000c:18ff:fe03:adfe" +IPV6_ROUTES="2001:1aa1:000a:7dae::/64 2001:1aa1:000a:7c0c:000c:18ff:fe03:ad01" sleep 1 @@ -10,7 +24,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,70 +32,106 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="perimeter" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "192.168.173.147/24" \ - ipv4.dns "192.168.173.223" \ - ipv4.dns-search "pm.useribm.hu" \ - ipv4.gateway "192.168.173.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv4.routes "10.228.0.0/16 192.168.173.1" \ - ipv6.addresses "2001:1aa1:000a:7c0c:000c:18ff:fe03:ad93/64" \ - ipv6.dns "2001:1aa1:000a:7c0c:000c:18ff:fe03:addf" \ - ipv6.dns-search "pm.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7c0c:000c:18ff:fe03:adfe" \ + ipv4.routes "$IPV4_ROUTES" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - ipv6.routes "2001:1aa1:000a:7dae::/64 2001:1aa1:000a:7c0c:000c:18ff:fe03:ad01" \ - save yes + ipv6.routes "$IPV6_ROUTES" \ + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -92,5 +142,5 @@ EOF nmcli connection show -hostnamectl hostname ens.pm.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/fdc.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/fdc.in/c3d/firstboot/scripts/01_setupnetworking.sh index f0f7413..e355ab7 100755 --- a/sources/fdc.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/fdc.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,18 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="fdc.in.useribm.hu" +IPV4_ADDRESSES="10.228.109.131/16" +IPV4_DNS="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" +IPV6_ADDRESSES="2001:1aa1:000a:7dae:000c:18ff:fe03:6d83/64" +IPV6_DNS="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" +IPV6_DNS_SEARCH="in.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" sleep 1 @@ -10,7 +22,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,68 +30,104 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.131/16" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:6d83/64" \ - ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f" \ - ipv6.dns-search "in.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -90,5 +138,5 @@ EOF nmcli connection show -hostnamectl hostname fdc.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/fds.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/fds.in/c3d/firstboot/scripts/01_setupnetworking.sh index b4f2d5e..0c79f47 100755 --- a/sources/fds.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/fds.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,18 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="fds.in.useribm.hu" +IPV4_ADDRESSES="10.228.109.147/16" +IPV4_DNS="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" +IPV6_ADDRESSES="2001:1aa1:000a:7dae:000c:18ff:fe03:6d93/64" +IPV6_DNS="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" +IPV6_DNS_SEARCH="in.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" sleep 1 @@ -10,7 +22,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,68 +30,104 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.147/16" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:6d93/64" \ - ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f" \ - ipv6.dns-search "in.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -90,5 +138,5 @@ EOF nmcli connection show -hostnamectl hostname fds.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/git.pm/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/git.pm/c3d/firstboot/scripts/01_setupnetworking.sh index e4d6802..dc8b12d 100755 --- a/sources/git.pm/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/git.pm/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,20 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="perimeter" +FQ_HOSTNAME="git.pm.useribm.hu" +IPV4_ADDRESSES="192.168.173.42/24" +IPV4_DNS="192.168.173.223" +IPV4_DNS_SEARCH="pm.useribm.hu" +IPV4_GATEWAY="192.168.173.254" +IPV4_ROUTES="10.228.0.0/16 192.168.173.1" +IPV6_ADDRESSES="2001:1aa1:000a:7c0c:000c:18ff:fe03:ad2a/64" +IPV6_DNS="2001:1aa1:000a:7c0c:000c:18ff:fe03:addf" +IPV6_DNS_SEARCH="pm.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7c0c:000c:18ff:fe03:adfe" +IPV6_ROUTES="2001:1aa1:000a:7dae::/64 2001:1aa1:000a:7c0c:000c:18ff:fe03:ad01" sleep 1 @@ -10,7 +24,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,70 +32,106 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="perimeter" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "192.168.173.42/24" \ - ipv4.dns "192.168.173.223" \ - ipv4.dns-search "pm.useribm.hu" \ - ipv4.gateway "192.168.173.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv4.routes "10.228.0.0/16 192.168.173.1" \ - ipv6.addresses "2001:1aa1:000a:7c0c:000c:18ff:fe03:ad2a/64" \ - ipv6.dns "2001:1aa1:000a:7c0c:000c:18ff:fe03:addf" \ - ipv6.dns-search "pm.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7c0c:000c:18ff:fe03:adfe" \ + ipv4.routes "$IPV4_ROUTES" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - ipv6.routes "2001:1aa1:000a:7dae::/64 2001:1aa1:000a:7c0c:000c:18ff:fe03:ad01" \ - save yes + ipv6.routes "$IPV6_ROUTES" \ + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -92,5 +142,5 @@ EOF nmcli connection show -hostnamectl hostname git.pm.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/gitea.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/gitea.in/c3d/firstboot/scripts/01_setupnetworking.sh index 00107e8..57f327f 100755 --- a/sources/gitea.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/gitea.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,18 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="gitea.in.useribm.hu" +IPV4_ADDRESSES="10.228.109.220/16" +IPV4_DNS="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" +IPV6_ADDRESSES="2001:1aa1:000a:7dae:000c:18ff:fe03:6ddc/64" +IPV6_DNS="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" +IPV6_DNS_SEARCH="in.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" sleep 1 @@ -10,7 +22,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,68 +30,104 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.220/16" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:6ddc/64" \ - ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" \ - ipv6.dns-search "in.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -90,5 +138,5 @@ EOF nmcli connection show -hostnamectl hostname gitea.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/ifg.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/ifg.in/c3d/firstboot/scripts/01_setupnetworking.sh index c119875..61e6ac1 100755 --- a/sources/ifg.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/ifg.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,29 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_DEVICE_IN="eth0" +CONNECTION_DEVICE_PM="eth1" +CONNECTION_ID_IN="internal" +CONNECTION_ID_PM="perimeter" +FQ_HOSTNAME="ifg.in.useribm.hu" +IPV4_ADDRESSES_IN="10.228.109.254/16, \ + 192.168.42.254/24, \ + 192.168.43.254/24" +IPV4_DNS_IN="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH_IN="in.useribm.hu" +IPV4_ROUTES_IN="172.16.223.0/24 10.228.109.236, \ + 172.24.232.0/24 10.228.109.236, \ + 10.162.0.0/16 10.228.109.236" +IPV6_ADDRESSES_IN="2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe/64" +IPV6_DNS_IN="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, \ + 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" +IPV6_DNS_SEARCH_IN="in.useribm.hu" +IPV4_ADDRESSES_PM="192.168.173.1/24" +IPV4_GATEWAY_PM="192.168.173.254" +IPV6_ADDRESSES_PM="2001:1aa1:000a:7c0c:000c:18ff:fe03:ad01/64" +IPV6_GATEWAY_PM="2001:1aa1:000a:7c0c:000c:18ff:fe03:adfe" sleep 1 @@ -10,7 +33,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,51 +41,85 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the three network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the two ethernet connections to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 3 ] +while [ $ACTIVE_CONNECTIONS -lt 2 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "Less than two active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connections" + echo -n "Waiting for the ethernet " + echo -n "connections to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 3 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 2 ] then - echo "Number of connections: $CONNECTIONS instead of 4" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 2" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE_IN="eth0" -CONNECTION_DEVICE_PM="eth1" -CONNECTION_ID_IN="internal" -CONNECTION_ID_PM="perimeter" -CONNECTION_LINE_IN=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE_IN}$") -CONNECTION_LINE_PM=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE_PM}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE_IN=$(nmcli --terse connection show \ + | grep ":${CONNECTION_DEVICE_IN}$") +CONNECTION_LINE_PM=$(nmcli --terse connection show \ + | grep ":${CONNECTION_DEVICE_PM}$") CONNECTION_UUID_IN=$(echo $CONNECTION_LINE_IN | cut -f 2 -d ':') CONNECTION_UUID_PM=$(echo $CONNECTION_LINE_PM | cut -f 2 -d ':') @@ -70,18 +127,18 @@ nmcli connection delete uuid "$CONNECTION_UUID_IN" nmcli connection delete uuid "$CONNECTION_UUID_PM" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID_IN \ - connection.interface-name $CONNECTION_DEVICE_IN \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID_IN" \ + connection.interface-name "$CONNECTION_DEVICE_IN" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.254/16, 192.168.42.254/24, 192.168.43.254/24" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ + ipv4.addresses "$IPV4_ADDRESSES_IN" \ + ipv4.dns "$IPV4_DNS_IN" \ + ipv4.dns-search "$IPV4_DNS_SEARCH_IN" \ ipv4.method "manual" \ - ipv4.routes "172.16.223.0/24 10.228.109.236, 172.24.232.0/24 10.228.109.236, 10.162.0.0/16 10.228.109.236" \ - ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe/64" \ - ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" \ - ipv6.dns-search "in.useribm.hu" \ + ipv4.routes "$IPV4_ROUTES_IN" \ + ipv6.addresses "$IPV6_ADDRESSES_IN" \ + ipv6.dns "$IPV6_DNS_IN" \ + ipv6.dns-search "$IPV6_DNS_SEARCH_IN" \ ipv6.method "manual" \ save yes @@ -97,11 +154,11 @@ nmcli connection add \ connection.id $CONNECTION_ID_PM \ connection.interface-name $CONNECTION_DEVICE_PM \ connection.type 802-3-ethernet \ - ipv4.addresses "192.168.173.1/24" \ - ipv4.gateway "192.168.173.254" \ + ipv4.addresses "$IPV4_ADDRESSES_PM" \ + ipv4.gateway "$IPV4_GATEWAY_PM" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7c0c:000c:18ff:fe03:ad01/64" \ - ipv6.gateway "2001:1aa1:000a:7c0c:000c:18ff:fe03:adfe" \ + ipv6.addresses "$IPV6_ADDRESSES_PM" \ + ipv6.gateway "$IPV6_GATEWAY_PM" \ ipv6.method "manual" \ save yes @@ -114,5 +171,5 @@ EOF nmcli connection show -hostnamectl hostname ifg.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/kea.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/kea.in/c3d/firstboot/scripts/01_setupnetworking.sh index 1b9eb70..2258f76 100755 --- a/sources/kea.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/kea.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,14 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="kea.in.useribm.hu" +IPV4_ADDRESSES="10.228.109.127/16" +IPV4_DNS="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" sleep 1 @@ -10,7 +18,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,64 +26,100 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.127/16" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ ipv6.method "disabled" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -86,5 +130,5 @@ EOF nmcli connection show -hostnamectl hostname kea.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/kms.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/kms.in/c3d/firstboot/scripts/01_setupnetworking.sh index 2077422..ff063b4 100755 --- a/sources/kms.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/kms.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,18 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="kms.in.useribm.hu" +IPV4_ADDRESSES="10.228.109.225/16" +IPV4_DNS="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" +IPV6_ADDRESSES="2001:1aa1:000a:7dae:000c:18ff:fe03:6de1/64" +IPV6_DNS="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" +IPV6_DNS_SEARCH="in.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" sleep 1 @@ -10,7 +22,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,68 +30,104 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.225/16" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:6de1/64" \ - ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" \ - ipv6.dns-search "in.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -90,5 +138,5 @@ EOF nmcli connection show -hostnamectl hostname kms.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/log.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/log.in/c3d/firstboot/scripts/01_setupnetworking.sh index c11bc52..694418b 100755 --- a/sources/log.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/log.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,18 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="log.in.useribm.hu" +IPV4_ADDRESSES="10.228.109.77/16" +IPV4_DNS="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" +IPV6_ADDRESSES="2001:1aa1:000a:7dae:000c:18ff:fe03:6d4d/64" +IPV6_DNS="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" +IPV6_DNS_SEARCH="in.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" sleep 1 @@ -10,7 +22,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,68 +30,104 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.77/16" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:6d4d/64" \ - ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f" \ - ipv6.dns-search "in.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -90,5 +138,5 @@ EOF nmcli connection show -hostnamectl hostname log.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/mx.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/mx.in/c3d/firstboot/scripts/01_setupnetworking.sh index 190295c..79d1a0f 100755 --- a/sources/mx.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/mx.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,18 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="mx.in.useribm.hu" +IPV4_ADDRESSES="10.228.109.154/16" +IPV4_DNS="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" +IPV6_ADDRESSES="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9a/64" +IPV6_DNS="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" +IPV6_DNS_SEARCH="in.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" sleep 1 @@ -10,7 +22,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,68 +30,104 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.154/16" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:6d9a/64" \ - ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f" \ - ipv6.dns-search "in.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -90,5 +138,5 @@ EOF nmcli connection show -hostnamectl hostname mx.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/mx.pm/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/mx.pm/c3d/firstboot/scripts/01_setupnetworking.sh index f4fff5f..6ae018b 100755 --- a/sources/mx.pm/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/mx.pm/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,20 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="perimeter" +FQ_HOSTNAME="mx.pm.useribm.hu" +IPV4_ADDRESSES="192.168.173.154/24" +IPV4_DNS="192.168.173.223" +IPV4_DNS_SEARCH="pm.useribm.hu" +IPV4_GATEWAY="192.168.173.254" +IPV4_ROUTES="10.228.0.0/16 192.168.173.1" +IPV6_ADDRESSES="2001:1aa1:000a:7c0c:000c:18ff:fe03:ad9a/64" +IPV6_DNS="2001:1aa1:000a:7c0c:000c:18ff:fe03:addf" +IPV6_DNS_SEARCH="pm.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7c0c:000c:18ff:fe03:adfe" +IPV6_ROUTES="2001:1aa1:000a:7dae::/64 2001:1aa1:000a:7c0c:000c:18ff:fe03:ad01" sleep 1 @@ -10,7 +24,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,70 +32,106 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="perimeter" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "192.168.173.154/24" \ - ipv4.dns "192.168.173.223" \ - ipv4.dns-search "pm.useribm.hu" \ - ipv4.gateway "192.168.173.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv4.routes "10.228.0.0/16 192.168.173.1" \ - ipv6.addresses "2001:1aa1:000a:7c0c:000c:18ff:fe03:ad9a/64" \ - ipv6.dns "2001:1aa1:000a:7c0c:000c:18ff:fe03:addf" \ - ipv6.dns-search "pm.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7c0c:000c:18ff:fe03:adfe" \ + ipv4.routes "$IPV4_ROUTES" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - ipv6.routes "2001:1aa1:000a:7dae::/64 2001:1aa1:000a:7c0c:000c:18ff:fe03:ad01" \ - save yes + ipv6.routes "$IPV6_ROUTES" \ + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -92,5 +142,5 @@ EOF nmcli connection show -hostnamectl hostname mx.pm.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/ns1.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/ns1.in/c3d/firstboot/scripts/01_setupnetworking.sh index bc8e544..e1bb941 100755 --- a/sources/ns1.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/ns1.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,18 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="ns1.in.useribm.hu" +IPV4_ADDRESSES="10.228.109.159/16" +IPV4_DNS="10.228.92.159, 10.228.109.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" +IPV6_ADDRESSES="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f/64" +IPV6_DNS="2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f" +IPV6_DNS_SEARCH="in.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" sleep 1 @@ -10,7 +22,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,68 +30,104 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.159/16" \ - ipv4.dns "10.228.92.159, 10.228.109.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f/64" \ - ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f" \ - ipv6.dns-search "in.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -90,5 +138,5 @@ EOF nmcli connection show -hostnamectl hostname ns1.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/ns2.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/ns2.in/c3d/firstboot/scripts/01_setupnetworking.sh index 9e4cc4e..a36bd0f 100755 --- a/sources/ns2.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/ns2.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,18 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="ns2.in.useribm.hu" +IPV4_ADDRESSES="10.228.92.159/16" +IPV4_DNS="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" +IPV6_ADDRESSES="2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f/64" +IPV6_DNS="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" +IPV6_DNS_SEARCH="in.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" sleep 1 @@ -10,7 +22,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,68 +30,104 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.92.159/16" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f/64" \ - ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" \ - ipv6.dns-search "in.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -90,5 +138,5 @@ EOF nmcli connection show -hostnamectl hostname ns2.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/pgs.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/pgs.in/c3d/firstboot/scripts/01_setupnetworking.sh index 85075cf..ace6b74 100755 --- a/sources/pgs.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/pgs.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,18 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="pgs.in.useribm.hu" +IPV4_ADDRESSES="10.228.109.153/16" +IPV4_DNS="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" +IPV6_ADDRESSES="2001:1aa1:000a:7dae:000c:18ff:fe03:6d99/64" +IPV6_DNS="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" +IPV6_DNS_SEARCH="in.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" sleep 1 @@ -10,7 +22,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,73 +30,104 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -# the two connections being the loopback and eth0 -CONNECTION_DEVICES_UP=$(nmcli --terse connection show --active | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show --active \ - | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show \ - | grep ':802-3-ethernet:' | wc -l) -if [ $CONNECTIONS -ne 1 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "There are $CONNECTIONS ethernet connections (instead of 1):" + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 + exit 1 +fi + +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') +CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') -nmcli --terse connection show \ - | grep ':802-3-ethernet:' \ - | while read CONNECTION_LINE -do - CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') - nmcli connection delete uuid "$CONNECTION_UUID" -done +nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.153/16" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:6d99/64" \ - ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f" \ - ipv6.dns-search "in.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -95,5 +138,5 @@ EOF nmcli connection show -hostnamectl hostname pgs.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/pki.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/pki.in/c3d/firstboot/scripts/01_setupnetworking.sh index 00db1ad..8ac8623 100755 --- a/sources/pki.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/pki.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,18 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="pki.in.useribm.hu" +IPV4_ADDRESSES="10.228.109.183/16" +IPV4_DNS="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" +IPV6_ADDRESSES="2001:1aa1:000a:7dae:000c:18ff:fe03:6db7/64" +IPV6_DNS="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" +IPV6_DNS_SEARCH="in.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" sleep 1 @@ -10,7 +22,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,68 +30,104 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.183/16" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:6db7/64" \ - ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f" \ - ipv6.dns-search "in.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -90,5 +138,5 @@ EOF nmcli connection show -hostnamectl hostname pki.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/pns.pm/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/pns.pm/c3d/firstboot/scripts/01_setupnetworking.sh index 66c198e..132a6b6 100755 --- a/sources/pns.pm/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/pns.pm/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,20 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="perimeter" +FQ_HOSTNAME="pns.pm.useribm.hu" +IPV4_ADDRESSES="192.168.173.223/24" +IPV4_DNS="127.0.0.1" +IPV4_DNS_SEARCH="pm.useribm.hu" +IPV4_GATEWAY="192.168.173.254" +IPV4_ROUTES="10.228.0.0/16 192.168.173.1" +IPV6_ADDRESSES="2001:1aa1:000a:7c0c:000c:18ff:fe03:addf/64" +IPV6_DNS="::1" +IPV6_DNS_SEARCH="pm.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7c0c:000c:18ff:fe03:adfe" +IPV6_ROUTES="2001:1aa1:000a:7dae::/64 2001:1aa1:000a:7c0c:000c:18ff:fe03:ad01" sleep 1 @@ -10,7 +24,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,70 +32,106 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="perimeter" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "192.168.173.223/24" \ - ipv4.dns "127.0.0.1" \ - ipv4.dns-search "pm.useribm.hu" \ - ipv4.gateway "192.168.173.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv4.routes "10.228.0.0/16 192.168.173.1" \ - ipv6.addresses "2001:1aa1:000a:7c0c:000c:18ff:fe03:addf/64" \ - ipv6.dns "2001:1aa1:000a:7c0c:000c:18ff:fe03:addf" \ - ipv6.dns-search "pm.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7c0c:000c:18ff:fe03:adfe" \ + ipv4.routes "$IPV4_ROUTES" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - ipv6.routes "2001:1aa1:000a:7dae::/64 2001:1aa1:000a:7c0c:000c:18ff:fe03:ad01" \ - save yes + ipv6.routes "$IPV6_ROUTES" \ + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -92,5 +142,5 @@ EOF nmcli connection show -hostnamectl hostname pns.pm.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/slycpx.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/slycpx.in/c3d/firstboot/scripts/01_setupnetworking.sh index 7cd7c73..543cc1b 100755 --- a/sources/slycpx.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/slycpx.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,18 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="slycpx.in.useribm.hu" +IPV4_ADDRESSES="10.228.109.44/16" +IPV4_DNS="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" +IPV6_ADDRESSES="2001:1aa1:000a:7dae:000c:18ff:fe03:6d2c/64" +IPV6_DNS="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" +IPV6_DNS_SEARCH="in.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" sleep 1 @@ -10,7 +22,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,68 +30,104 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.44/16" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:6d2c/64" \ - ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" \ - ipv6.dns-search "in.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -90,5 +138,5 @@ EOF nmcli connection show -hostnamectl hostname slycpx.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/slycrm.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/slycrm.in/c3d/firstboot/scripts/01_setupnetworking.sh index 11f89e5..016f44c 100755 --- a/sources/slycrm.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/slycrm.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,18 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="slycrm.in.useribm.hu" +IPV4_ADDRESSES="10.228.109.53/16" +IPV4_DNS="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" +IPV6_ADDRESSES="2001:1aa1:000a:7dae:000c:18ff:fe03:6d35/64" +IPV6_DNS="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" +IPV6_DNS_SEARCH="in.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" sleep 1 @@ -10,7 +22,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,68 +30,104 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.53/16" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:6d35/64" \ - ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" \ - ipv6.dns-search "in.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -90,5 +138,5 @@ EOF nmcli connection show -hostnamectl hostname slycrm.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/sns.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/sns.in/c3d/firstboot/scripts/01_setupnetworking.sh index 74bebbe..3f39e79 100755 --- a/sources/sns.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/sns.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,18 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="sns.in.useribm.hu" +IPV4_ADDRESSES="10.228.109.11/16" +IPV4_DNS="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" +IPV6_ADDRESSES="2001:1aa1:000a:7dae:000c:18ff:fe03:6d0b/64" +IPV6_DNS="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" +IPV6_DNS_SEARCH="in.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" sleep 1 @@ -10,7 +22,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,68 +30,104 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.11/16" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:6d0b/64" \ - ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" \ - ipv6.dns-search "in.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -90,5 +138,5 @@ EOF nmcli connection show -hostnamectl hostname sns.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/vpn.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/vpn.in/c3d/firstboot/scripts/01_setupnetworking.sh index 62cc0fc..528bd6f 100755 --- a/sources/vpn.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/vpn.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,14 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="vpn.in.useribm.hu" +IPV4_ADDRESSES="10.228.109.236/16" +IPV4_DNS="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" sleep 1 @@ -10,7 +18,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,64 +26,100 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.236/16" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ ipv6.method "disabled" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -86,5 +130,5 @@ EOF nmcli connection show -hostnamectl hostname vpn.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/wiki.in/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/wiki.in/c3d/firstboot/scripts/01_setupnetworking.sh index 724f836..6d65c01 100755 --- a/sources/wiki.in/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/wiki.in/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,18 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="internal" +FQ_HOSTNAME="wiki.in.useribm.hu" +IPV4_ADDRESSES="10.228.109.211/16" +IPV4_DNS="10.228.109.159, 10.228.92.159" +IPV4_DNS_SEARCH="in.useribm.hu" +IPV4_GATEWAY="10.228.109.254" +IPV6_ADDRESSES="2001:1aa1:000a:7dae:000c:18ff:fe03:6dd3/64" +IPV6_DNS="2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" +IPV6_DNS_SEARCH="in.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" sleep 1 @@ -10,7 +22,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,68 +30,104 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="internal" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "10.228.109.211/16" \ - ipv4.dns "10.228.109.159, 10.228.92.159" \ - ipv4.dns-search "in.useribm.hu" \ - ipv4.gateway "10.228.109.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7dae:000c:18ff:fe03:6dd3/64" \ - ipv6.dns "2001:1aa1:000a:7dae:000c:18ff:fe03:6d9f, 2001:1aa1:000a:7dae:000c:18ff:fe03:5c9f" \ - ipv6.dns-search "in.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7dae:000c:18ff:fe03:6dfe" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -90,5 +138,5 @@ EOF nmcli connection show -hostnamectl hostname wiki.in.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/ws.pm/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/ws.pm/c3d/firstboot/scripts/01_setupnetworking.sh index 6ca83f7..731ce3d 100755 --- a/sources/ws.pm/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/ws.pm/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,20 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="perimeter" +FQ_HOSTNAME="ws.pm.useribm.hu" +IPV4_ADDRESSES="192.168.173.249/24" +IPV4_DNS="192.168.173.223" +IPV4_DNS_SEARCH="pm.useribm.hu" +IPV4_GATEWAY="192.168.173.254" +IPV4_ROUTES="10.228.0.0/16 192.168.173.1, 192.168.42.0/24 192.168.173.1" +IPV6_ADDRESSES="2001:1aa1:000a:7c0c:000c:18ff:fe03:adf9/64" +IPV6_DNS="2001:1aa1:000a:7c0c:000c:18ff:fe03:addf" +IPV6_DNS_SEARCH="pm.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7c0c:000c:18ff:fe03:adfe" +IPV6_ROUTES="2001:1aa1:000a:7dae::/64 2001:1aa1:000a:7c0c:000c:18ff:fe03:ad01" sleep 1 @@ -10,7 +24,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,70 +32,106 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="perimeter" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "192.168.173.249/24" \ - ipv4.dns "192.168.173.223" \ - ipv4.dns-search "pm.useribm.hu" \ - ipv4.gateway "192.168.173.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv4.routes "10.228.0.0/16 192.168.173.1, 192.168.42.0/24 192.168.173.1" \ - ipv6.addresses "2001:1aa1:000a:7c0c:000c:18ff:fe03:adf9/64" \ - ipv6.dns "2001:1aa1:000a:7c0c:000c:18ff:fe03:addf" \ - ipv6.dns-search "pm.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7c0c:000c:18ff:fe03:adfe" \ + ipv4.routes "$IPV4_ROUTES" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - ipv6.routes "2001:1aa1:000a:7dae::/64 2001:1aa1:000a:7c0c:000c:18ff:fe03:ad01" \ - save yes + ipv6.routes "$IPV6_ROUTES" \ + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -92,5 +142,5 @@ EOF nmcli connection show -hostnamectl hostname ws.pm.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl diff --git a/sources/xfr.pm/c3d/firstboot/scripts/01_setupnetworking.sh b/sources/xfr.pm/c3d/firstboot/scripts/01_setupnetworking.sh index 13651f2..de29979 100755 --- a/sources/xfr.pm/c3d/firstboot/scripts/01_setupnetworking.sh +++ b/sources/xfr.pm/c3d/firstboot/scripts/01_setupnetworking.sh @@ -2,6 +2,19 @@ export PAGER= +AC_CYCLES=10 +NM_CYCLES=60 +CONNECTION_ID="perimeter" +FQ_HOSTNAME="xfr.pm.useribm.hu" +IPV4_ADDRESSES="192.168.173.174/24" +IPV4_DNS="192.168.173.223" +IPV4_DNS_SEARCH="pm.useribm.hu" +IPV4_GATEWAY="192.168.173.254" +IPV4_ROUTES="10.228.0.0/16 192.168.173.1" +IPV6_ADDRESSES="2001:1aa1:000a:7c0c:000c:18ff:fe03:adae/64" +IPV6_DNS="2001:1aa1:000a:7c0c:000c:18ff:fe03:addf" +IPV6_DNS_SEARCH="pm.useribm.hu" +IPV6_GATEWAY="2001:1aa1:000a:7c0c:000c:18ff:fe03:adfe" sleep 1 @@ -10,7 +23,7 @@ NM_RC=$? CYCLES_WAITED=0 while [ $NM_RC -ne 0 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $NM_CYCLES ] then exit 1 fi @@ -18,69 +31,104 @@ do then echo -n "Waiting for NetworkManager" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi systemctl --quiet is-active NetworkManager.service NM_RC=$? done [ $CYCLES_WAITED -gt 0 ] && echo -# wait for the two network connections to come up -CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) +# wait for the (only) ethernet connection to activate/come up +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) CYCLES_WAITED=0 -while [ $CONNECTION_DEVICES_UP -lt 2 ] +while [ $ACTIVE_CONNECTIONS -lt 1 ] do - if [ $CYCLES_WAITED -ge 10 ] + if [ $CYCLES_WAITED -ge $AC_CYCLES ] then - echo - nmcli connection show + echo "No active connections" >&2 + nmcli connection show >&2 exit 1 fi if [ $CYCLES_WAITED -eq 0 ] then - echo -n "Waiting for the network connection" + echo -n "Waiting for the ethernet " + echo -n "connection to activate/come up" fi - echo -n . sleep 1 - CYCLES_WAITED=$(( $CYCLES_WAITED + 1 )) - CONNECTION_DEVICES_UP=$(nmcli --terse connection show \ - | grep --invert-match ':$' | wc -l) + CYCLES_WAITED=$(($CYCLES_WAITED + 1)) + if [ $(($CYCLES_WAITED % 5)) -eq 0 ] + then + echo -n "+" + else + echo -n "." + fi + ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) done [ $CYCLES_WAITED -gt 0 ] && echo -CONNECTIONS=$(nmcli --terse connection show | wc -l) -if [ $CONNECTIONS -ne 2 ] +ACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep --invert-match ':$' | wc -l) +if [ $ACTIVE_CONNECTIONS -ne 1 ] then - echo "Number of connections: $CONNECTIONS instead of 2" >&2 + echo -n "Number of active connections: " >&2 + echo "$ACTIVE_CONNECTIONS instead of 1" >&2 + nmcli connection show >&2 exit 1 fi -CONNECTION_DEVICE="eth0" -CONNECTION_ID="perimeter" -CONNECTION_LINE=$(nmcli --terse connection show | grep ":${CONNECTION_DEVICE}$") +INACTIVE_CONNECTIONS=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' | wc -l) +if [ $INACTIVE_CONNECTIONS -gt 0 ] +then + echo "Deleting inactive/unused connection(s)" + echo "----------------" + nmcli connection show + nmcli --terse connection show \ + | grep ':802-3-ethernet:' \ + | grep ':$' \ + | cut -f 2 -d ':' \ + | while read CONNECTION_UUID + do + nmcli connection delete uuid "$CONNECTION_UUID" + done + echo "----------------" +fi + +CONNECTION_LINE=$(nmcli --terse connection show \ + | grep ':802-3-ethernet:') +CONNECTION_DEVICE=$(echo $CONNECTION_LINE | cut -f 4 -d ':') CONNECTION_UUID=$(echo $CONNECTION_LINE | cut -f 2 -d ':') nmcli connection delete uuid "$CONNECTION_UUID" nmcli connection add \ - connection.autoconnect yes \ - connection.id $CONNECTION_ID \ - connection.interface-name $CONNECTION_DEVICE \ + connection.autoconnect "yes" \ + connection.id "$CONNECTION_ID" \ + connection.interface-name "$CONNECTION_DEVICE" \ connection.type 802-3-ethernet \ - ipv4.addresses "192.168.173.174/24" \ - ipv4.dns "192.168.173.223" \ - ipv4.dns-search "pm.useribm.hu" \ - ipv4.gateway "192.168.173.254" \ + ipv4.addresses "$IPV4_ADDRESSES" \ + ipv4.dns "$IPV4_DNS" \ + ipv4.dns-search "$IPV4_DNS_SEARCH" \ + ipv4.gateway "$IPV4_GATEWAY" \ ipv4.method "manual" \ - ipv6.addresses "2001:1aa1:000a:7c0c:000c:18ff:fe03:adae/64" \ - ipv6.dns "2001:1aa1:000a:7c0c:000c:18ff:fe03:addf" \ - ipv6.dns-search "pm.useribm.hu" \ - ipv6.gateway "2001:1aa1:000a:7c0c:000c:18ff:fe03:adfe" \ + ipv6.addresses "$IPV6_ADDRESSES" \ + ipv6.dns "$IPV6_DNS" \ + ipv6.dns-search "$IPV6_DNS_SEARCH" \ + ipv6.gateway "$IPV6_GATEWAY" \ ipv6.method "manual" \ - ipv6.routes "2001:1aa1:000a:7dae::/64 2001:1aa1:000a:7c0c:000c:18ff:fe03:ad01" \ - save yes + save "yes" cat </etc/NetworkManager/conf.d/${CONNECTION_DEVICE}.conf [device] @@ -91,5 +139,5 @@ EOF nmcli connection show -hostnamectl hostname xfr.pm.useribm.hu +hostnamectl hostname "$FQ_HOSTNAME" hostnamectl