## 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"
/etc/init.d/opensrf restart
}
+GetNics
ConfigNetwork
### Setup Monitoring
### 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.
}
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
### 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 ]
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
tar zxvf tar_file.tar.gz -C /
ConfigLogging
+GetNics
ConfigNetwork
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