From: Chris Sharp Date: Thu, 29 Jun 2017 17:37:10 +0000 (-0400) Subject: Add feature to find primary network interface and configure at runtime. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=34a8711e604340f64b2128aa955dbd1c0a4e8a4d;p=contrib%2Fpines%2Fgenasys.git Add feature to find primary network interface and configure at runtime. --- diff --git a/templates/interfaces b/templates/interfaces index 22f039b..66bc901 100644 --- a/templates/interfaces +++ b/templates/interfaces @@ -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 diff --git a/templates/setup-drone.sh b/templates/setup-drone.sh index eced7c8..f2e430d 100755 --- a/templates/setup-drone.sh +++ b/templates/setup-drone.sh @@ -181,6 +181,8 @@ sleep 1 /etc/init.d/opensrf restart } +ConfigNetwork + ### Setup Monitoring ## Monitored hosts SetupMonitoring diff --git a/templates/setup-functions b/templates/setup-functions index b9fd8a5..f5bacd4 100644 --- a/templates/setup-functions +++ b/templates/setup-functions @@ -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 diff --git a/templates/setup-head.sh b/templates/setup-head.sh index 0c386c3..fc452b8 100755 --- a/templates/setup-head.sh +++ b/templates/setup-head.sh @@ -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 diff --git a/templates/setup.sh b/templates/setup.sh index 97691c2..733d5b6 100755 --- a/templates/setup.sh +++ b/templates/setup.sh @@ -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