update network interface configuration to remove hard coded ethernet names. deprecate...
authorAndy Witter <awitter@georgialibraries.org>
Tue, 2 Apr 2019 14:57:38 +0000 (10:57 -0400)
committerAndy Witter <awitter@georgialibraries.org>
Tue, 2 Apr 2019 14:57:38 +0000 (10:57 -0400)
templates/lvs/iptables-rules.fw
templates/setup-drone.sh
templates/setup-functions
templates/setup-head.sh
templates/setup.sh

index ca25b5f..f4f55e1 100755 (executable)
@@ -7,10 +7,10 @@
 ## to add more rules see rules section below.
 
 ### What is the external interface? eg. eth0
-EXTERNAL_IF="eth1"
+EXTERNAL_IF="XTRNL_IF"
 
 ### What is the internal interface? eg eth1, eth0:1
-INTERNAL_IF="eth0"
+INTERNAL_IF="INTRNL_IF"
 
 ### What is the private network address? eg. Priv_NET.0/24
 PRIVATE_NET="Priv_NET.0/24"
index f2e430d..26e0c53 100755 (executable)
@@ -181,6 +181,7 @@ sleep 1
 /etc/init.d/opensrf restart
 }
 
+GetNics
 ConfigNetwork
 
 ### Setup Monitoring
index 8dca681..0b5d060 100755 (executable)
@@ -2,8 +2,22 @@
 
 ### common functions for setup files.
 
-GetNic () { ### get the active network inteface name
-NETWORK_INTERFACE="$(ip route|grep default|awk '{ print $5 }')"
+#GetNic () { ### get the active network inteface name #TODO remove this function, replaced with GetNics()
+#NETWORK_INTERFACE="$(ip route|grep default|awk '{ print $5 }')"
+#}
+
+GetNics () { ### get the primary and secondary interface of this host.
+
+INTERFACES="$(networkctl | grep -wv 'links' | grep -wv IDX | awk '{ print $2 }')"
+PRIMARY_INTERFACE="$(ip route | grep default | awk '{ print $5 }')"
+FIRST_PHYSICAL_INTERFACE="$(networkctl | grep -wv 'links' | grep -w '2' | awk '{ print $2 }')"
+SECOND_PHYSICAL_INTERFACE="$(networkctl | grep -wv 'links' | grep -w '3' | awk '{ print $3 }')"
+echo;echo
+echo "Interfaces found: "${INTERFACES}
+echo "Primary interface is: ${PRIMARY_INTERFACE}"
+echo "First physical interface is: ${FIRST_PHYSICAL_INTERFACE}"
+echo "Second physical interface is: ${SECOND_PHYSICAL_INTERFACE}"
+sleep 5
 }
 
 SetAliasedIP () { ### Add aliased interface to set the correct IP for installation.
@@ -139,9 +153,9 @@ fi
 }
 
 ConfigNetwork () {
-PRIMARY_IF=$(ip route get 8.8.8.8 | awk '{print $5; exit}')
-if [ ! -z "$PRIMARY_IF" ]; then
-        sed -i "s/Primary_IF/$PRIMARY_IF/g" /etc/network/interfaces
+# PRIMARY_IF=$(ip route get 8.8.8.8 | awk '{print $5; exit}') #TODO remove this as its declared above in the GetNics Function - done
+if [ ! -z "$PRIMARY_INTERFACE" ]; then #TODO update variable - done
+        sed -i "s/Primary_IF/$PRIMARY_INTERFACE/g" /etc/network/interfaces #TODO update variable - done
 else
    echo "ERROR: Unable to set primary interface. You must edit /etc/network/interfaces manually."
 fi
index 665e136..e1b8683 100755 (executable)
@@ -144,10 +144,10 @@ fi
 ### Fix ejabberd/apparmor bug - commented out because it's not working
 #FixAppArmorEJabberD
 
-GetNic ### Get the network interface
+GetNics ### Get the network interface #TODO change function called here from GetNic to GetNics - done
 
 ### Temporary create and alias interface for installation
-ip a add Priv_IP/My_CIDR dev $NETWORK_INTERFACE label ${NETWORK_INTERFACE}:0
+ip a add Priv_IP/My_CIDR dev $PRIMARY_INTERFACE label ${PRIMARY_INTERFACE}:0 #TODO update Variable to $3PRIMARY_INTERFACE - done
 
 ### Install Opensrf and Evergreen debs.
 if [ -e debconf-settings ]
@@ -447,6 +447,7 @@ echo -e "alias attach='su - -c \"brick_ctl.sh -a attach_brick\" opensrf'" >> /ro
 echo 'PS1="\[\033[1;33m\]\`if [[ -e /openils/var/web/ldirectorping.txt ]]; then echo "\\[\\033[32m\\]\[Attached\]\\[\\033[0m\\]"; else echo "\\[\\033[31m\\]\[Detached\]\\[\\033[0m\\]"; fi\`\u@\h:\w\\$ "'>> /root/.bashrc
 echo 'PS1="\[\033[1;33m\]\`if [[ -e /openils/var/web/ldirectorping.txt ]]; then echo "\\[\\033[32m\\]\[Attached\]\\[\\033[0m\\]"; else echo "\\[\\033[31m\\]\[Detached\]\\[\\033[0m\\]"; fi\`\u@\h:\w\\$ "' >> /home/opensrf/.bashrc
 
+GetNics
 ConfigNetwork
 
 ### Setup Monitoring
index a8f9f78..efcd7e1 100755 (executable)
@@ -561,6 +561,7 @@ sleep 2
 tar zxvf tar_file.tar.gz -C /
 
 ConfigLogging
+GetNics
 ConfigNetwork
 
 
@@ -697,11 +698,12 @@ then
                 Config_Apache2_Default_SSL
                 a2ensite default-ssl.conf
         fi
+       GetNics
        # configure firewall for lvs servers
-       sed -i "s/eth1/$PRIMARY_IF/g" "/etc/network/iptables-rules.fw"
+       sed -i "s/XTRNL_IF/$PRIMARY_INTERFACE/g" "/etc/network/iptables-rules.fw" #TODO update variable and switch from hard coded interface name - done
        # find secondary interface
-       SECONDARY_IF=$(ls /sys/class/net |grep -v "lo" |grep -v "$PRIMARY_IF")
-       sed -i "s/eth0/$SECONDARY_IF/g" "/etc/network/iptables-rules.fw"
+       # SECONDARY_IF=$(ls /sys/class/net |grep -v "lo" |grep -v "$PRIMARY_IF") #TODO remove this line completely as its deprecated by GetNics() - done
+       sed -i "s/INTRNL_IF/$SECOND_PHYSICAL_INTERFACE/g" "/etc/network/iptables-rules.fw" #TODO update variable and switch from hard coded interface name - done
 
 fi