Add feature to find primary network interface and configure at runtime.
authorChris Sharp <csharp@georgialibraries.org>
Thu, 29 Jun 2017 17:37:10 +0000 (13:37 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Thu, 29 Jun 2017 17:37:10 +0000 (13:37 -0400)
templates/interfaces
templates/setup-drone.sh
templates/setup-functions
templates/setup-head.sh
templates/setup.sh

index 22f039b..66bc901 100644 (file)
@@ -6,8 +6,8 @@ auto lo
 iface lo inet loopback
 
 # The primary network interface
-auto eth0 
-iface eth0 inet static
+auto Primary_IF
+iface Primary_IF inet static
        address Priv_IP
        netmask 255.255.255.0
        gateway Priv_NET.1
index eced7c8..f2e430d 100755 (executable)
@@ -181,6 +181,8 @@ sleep 1
 /etc/init.d/opensrf restart
 }
 
+ConfigNetwork
+
 ### Setup Monitoring
 ## Monitored hosts
 SetupMonitoring
index b9fd8a5..f5bacd4 100644 (file)
@@ -124,6 +124,15 @@ else
 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
+else
+   echo "ERROR: Unable to set primary interface. You must edit /etc/network/interfaces manually."
+fi
+}
+
 ### Setup monitoring.
 SetupMonitoring () {
 ## Monitored hosts
index 0c386c3..fc452b8 100755 (executable)
@@ -333,6 +333,8 @@ 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
 
+ConfigNetwork
+
 ### Setup Monitoring
 ## Monitored hosts
 SetupMonitoring
index 97691c2..733d5b6 100755 (executable)
@@ -318,6 +318,7 @@ else
 fi
 }
 
+
 ### Setup DB #and repoter
 DBInstallErr () { ### DB install error.
 echo
@@ -526,6 +527,7 @@ sleep 2
 tar zxvf tar_file.tar.gz -C /
 
 ConfigLogging
+ConfigNetwork