From 1cb6e2fbd6e3be4eff101493dde60164faefadae Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sat, 12 Aug 2023 14:03:40 -0500 Subject: [PATCH] Update linupx-scripts.sh --- linupx-scripts.sh | 68 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/linupx-scripts.sh b/linupx-scripts.sh index 5f158d2..be6bf79 100755 --- a/linupx-scripts.sh +++ b/linupx-scripts.sh @@ -3,7 +3,7 @@ action="$1" FOLDER='/opt/idssys/linupx' -VERS='6.7-08122023' +VERS='6.8-08122023' if [ -d /opt/idssys/settings ]; then [ $(ls /opt/idssys/settings | wc -l) -eq 0 ] && rm -rf /opt/idssys/settings @@ -711,6 +711,31 @@ RECONFIGURE_NETWORK(){ fi netplan apply >/dev/null 2>&1 echo "${idsCL[Green]}Done${idsCL[Default]}\n\n" + + elif grep /etc/sysconfig/network-scripts/ifcfg-eth0 -e "Generated by VMWare" >/dev/null; then + rm -f /etc/sysconfig/network-scripts/ifcfg-eth0 >/dev/null 2>&1 + echo -e "TYPE=Ethernet +PROXY_METHOD=none +BROWSER_ONLY=no +BOOTPROTO=none +DEFROUTE=yes +IPV4_FAILURE_FATAL=no +IPV6INIT=no +NAME="eth0" +UUID=43def898-c3e6-402b-ad94-e8047a2c2a63 +DEVICE="eth0" +ONBOOT=yes +IPADDR=10.10.4.20 +PREFIX=16 +GATEWAY=10.10.0.1 +DNS1=10.10.10.10 +DNS2=10.10.10.11 +DOMAIN="scity.us schroedercity.com" +IPV6_DISABLED=yes +" > /etc/sysconfig/network-scripts/ifcfg-eth0 >/dev/null 2>&1 + + /usr/bin/nmcli connection up ETH0 + fi echo -en "\n${idsCL[LightCyan]}Would you like to configure the hostname and network settings (y/N)? ${idsCL[Default]}" @@ -771,30 +796,41 @@ RECONFIGURE_NETWORK(){ *) echo -en "${idsCL[LightCyan]}Making configuration changes ... ${idsCL[Default]}" - - hostnamectl set-hostname ${HOSTNAME} >/dev/null 2>&1 sed -i '/127.0.1.1/d' /etc/hosts >/dev/null 2>&1 - [ "${DOMAIN}" == "" ] && echo "127.0.1.1 ${HOSTNAME}" >> /etc/hosts || echo "127.0.1.1 ${HOSTNAME}.${DOMAIN} ${HOSTNAME}" >> /etc/hosts - + sed -i '/::1/d' /etc/hosts >/dev/null 2>&1 NEWSUB=`IPprefix_by_netmask ${SUBNET}` REPSUB=`IPprefix_by_netmask ${REPSUB}` - sed -i "s/${REPIP}\/${REPSUB}/${IPADDRESS}\/${NEWSUB}/g" /etc/netplan/eth0.yaml >/dev/null 2>&1 - sed -i "s/${REPIP}\/${REPSUB}/${IPADDRESS}\/${NEWSUB}/g" /etc/netplan/eth0.yaml >/dev/null 2>&1 + [ "${DOMAIN}" == "" ] && echo "127.0.1.1 ${HOSTNAME}" >> /etc/hosts || echo "127.0.1.1 ${HOSTNAME}.${DOMAIN} ${HOSTNAME}" >> /etc/hosts + + if [ -f /etc/netplan/eth0.yaml ]; then + sed -i "s/${REPIP}\/${REPSUB}/${IPADDRESS}\/${NEWSUB}/g" /etc/netplan/eth0.yaml >/dev/null 2>&1 + sed -i "s/${REPIP}\/${REPSUB}/${IPADDRESS}\/${NEWSUB}/g" /etc/netplan/eth0.yaml >/dev/null 2>&1 - [ "${SECDNS}" != "" ] && DNS="${PRIDNS},${SECDNS}" || DNS="${PRIDNS}" - [ "${REPSECDNS}" != "" ] && REPDNS="${REPPRIDNS},${REPSECDNS}" || REPDNS="${REPPRIDNS}" - sed -i "s/${REPDNS}/${DNS}/g" /etc/netplan/eth0.yaml >/dev/null 2>&1 + [ "${SECDNS}" != "" ] && DNS="${PRIDNS},${SECDNS}" || DNS="${PRIDNS}" + [ "${REPSECDNS}" != "" ] && REPDNS="${REPPRIDNS},${REPSECDNS}" || REPDNS="${REPPRIDNS}" + sed -i "s/${REPDNS}/${DNS}/g" /etc/netplan/eth0.yaml >/dev/null 2>&1 - sed -i "s/${REPGW}/${GATEWAY}/g" /etc/netplan/eth0.yaml >/dev/null 2>&1 + sed -i "s/${REPGW}/${GATEWAY}/g" /etc/netplan/eth0.yaml >/dev/null 2>&1 - sed -i '/search/d' /etc/netplan/eth0.yaml >/dev/null 2>&1 - if [ "${DOMAIN}" != "" ]; then - echo " search: [${DOMAIN}]" >> /etc/netplan/eth0.yaml + sed -i '/search/d' /etc/netplan/eth0.yaml >/dev/null 2>&1 + if [ "${DOMAIN}" != "" ]; then + echo " search: [${DOMAIN}]" >> /etc/netplan/eth0.yaml + fi + + netplan apply + + elif [ -f /etc/sysconfig/network-scripts/ifcfg-eth0 ]; then + /usr/bin/nmcli connection modify ETH0 ipv4.addresses ${IPADDRESS}/${NEWSUB} + + /usr/bin/nmcli connection modify ETH0 ipv4.dns "${PRIDNS}" + [ "${SECDNS}" != "" ] && nmcli connection modify ETH0 ipv4.dns "${SECDNS}" + + /usr/bin/nmcli connection modify ETH0 ipv4.gateway ${GATEWAY} + + /usr/bin/nmcli connection up ETH0 fi - netplan apply - echo -e "${idsCL[Green]}Done${idsCL[Default]}" echo