Last active
September 13, 2021 01:58
-
-
Save mainframe/5615446 to your computer and use it in GitHub Desktop.
Setup OpenNode OS networking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright (C) 2013, OpenNode LLC. All rights reserved. | |
# Email: [email protected] | |
# | |
# This program is free software; you can redistribute it and/or | |
# modify it under the terms of the GNU General Public License | |
# as published by the Free Software Foundation; either version 2 | |
# of the License, or (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with this program; if not, write to the Free Software | |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
# | |
# DESCRIPTION: | |
# on-net-setup.sh is used for reconfiguring host networking | |
# to be compatible with OpenNode OS | |
# Config | |
INTBRIDGE=vmbr0 | |
IFCFG_PATH=/etc/sysconfig/network-scripts | |
BRIDGE_FILE=ifcfg-${INTBRIDGE} | |
ETHDEV=$(ip route show default | awk '/default/ {print $5}') | |
ETHDEV_FILE=ifcfg-${ETHDEV} | |
TMPLOC=/tmp | |
TMPFILE=network-config | |
echo "INFO: Setting up OpenNode OS bridge networking" | |
echo "INFO: Detected current default gateway device as: ${ETHDEV}" | |
sleep 3 | |
echo "INFO: Backing up ${IFCFG_PATH}/${ETHDEV_FILE} into ${TMPLOC}/${ETHDEV_FILE}.bup" | |
cp -p ${IFCFG_PATH}/${ETHDEV_FILE} ${TMPLOC}/${ETHDEV_FILE}.bup | |
echo "INFO: Creating ${INTBRIDGE} integration bridge configuration" | |
echo "ONBOOT=yes" > ${IFCFG_PATH}/${BRIDGE_FILE} | |
echo "TYPE=Bridge" >> ${IFCFG_PATH}/${BRIDGE_FILE} | |
echo "DEVICE=vmbr0" >> ${IFCFG_PATH}/${BRIDGE_FILE} | |
echo "STP=off" >> ${IFCFG_PATH}/${BRIDGE_FILE} | |
grep BOOTPROTO ${IFCFG_PATH}/${ETHDEV_FILE} >> ${IFCFG_PATH}/${BRIDGE_FILE} | |
grep IPADDR ${IFCFG_PATH}/${ETHDEV_FILE} >> ${IFCFG_PATH}/${BRIDGE_FILE} | |
grep NETMASK ${IFCFG_PATH}/${ETHDEV_FILE} >> ${IFCFG_PATH}/${BRIDGE_FILE} | |
grep GATEWAY ${IFCFG_PATH}/${ETHDEV_FILE} >> ${IFCFG_PATH}/${BRIDGE_FILE} | |
grep DNS ${IFCFG_PATH}/${ETHDEV_FILE} >> ${IFCFG_PATH}/${BRIDGE_FILE} | |
grep IPV6 ${IFCFG_PATH}/${ETHDEV_FILE} >> ${IFCFG_PATH}/${BRIDGE_FILE} | |
echo "INFO: Re-configuring ${ETHDEV} as ${INTBRIDGE} bridge member" | |
echo "DEVICE=${ETHDEV}" > ${TMPLOC}/${TMPFILE} | |
echo "BOOTPROTO=none" >> ${TMPLOC}/${TMPFILE} | |
echo "ONBOOT=yes" >> ${TMPLOC}/${TMPFILE} | |
echo "TYPE=Ethernet" >> ${TMPLOC}/${TMPFILE} | |
echo "BRIDGE=${INTBRIDGE}" >> ${TMPLOC}/${TMPFILE} | |
grep HWADDR ${IFCFG_PATH}/${ETHDEV_FILE} >> ${TMPLOC}/${TMPFILE} | |
grep BONDING_OPTS ${IFCFG_PATH}/${ETHDEV_FILE} >> ${TMPLOC}/${TMPFILE} | |
# Override existing ETHDEV conf | |
cat ${TMPLOC}/${TMPFILE} > ${IFCFG_PATH}/${ETHDEV_FILE} | |
echo "INFO: OpenNode OS bridge networking setup - DONE!" | |
sleep 3 | |
echo "--------------------------------------------" | |
echo "INFO: Displaying ${INTBRIDGE} configuration:" | |
echo "--------------------------------------------" | |
cat ${IFCFG_PATH}/${BRIDGE_FILE} | |
echo "--------------------------------------------" | |
sleep 3 | |
echo "INFO: Displaying ${ETHDEV} configuration:" | |
echo "--------------------------------------------" | |
cat ${IFCFG_PATH}/${ETHDEV_FILE} | |
echo "--------------------------------------------" | |
sleep 3 | |
echo "INFO: Please execute 'service network restart' for activating the changes..." | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wget -q -O - https://gist.github.com/mainframe/5615446/raw/on-net-setup.sh | bash