As I’m trying to speed up things while I’m creating my ORACLE environments I started to build up some scripts to help me on doing it faster.
1. Adapt the network and the hosts file
Note: I’m running this script from my local server and not from VM, like this:
# root>ssh [email protected] < $script_location/adapt_network.sh
================================== START ========================================= #!/bin/bash ################################################ # Adapting the /etc/sysconfig/network-scripts ################################################ # Regenerate the IP rules #mv /etc/udev/rules.d/70-persistent-net.rules ~/70-persistent-net.rules.bck #/sbin/udevadm trigger --type=devices --action=add ### adapt the IPADDR cd /etc/sysconfig/network-scripts grep -q '^IPADDR' ifcfg-eth1 && sed -i 's/^IPADDR.*/'IPADDR=192.168.100.10'/' ifcfg-eth1 || echo 'IPADDR=192.168.100.10' >> ifcfg-eth1 grep -q '^IPADDR' ifcfg-eth2 && sed -i 's/^IPADDR.*/'IPADDR=192.168.101.11'/' ifcfg-eth2 || echo 'IPADDR=192.168.101.10' >> ifcfg-eth2 ### adapt the Name grep -q '^NAME' ifcfg-eth1 && sed -i 's/^NAME.*/NAME="eth1"/' ifcfg-eth1 || echo 'NAME="eth1"' >> ifcfg-eth1 grep -q '^NAME' ifcfg-eth2 && sed -i 's/^NAME.*/NAME="eth2"/' ifcfg-eth2 || echo 'NAME="eth2"' >> ifcfg-eth2 ### adapt the BOOTPROTO and remove the UUID for f in ifcfg-eth{1..2}; do grep -q '^BOOTPROTO' $f && sed -i 's/^BOOTPROTO.*/BOOTPROTO=none/' $f || echo 'BOOTPROTO=none' >> $f sed -i '/UUID/d' $f done ==================================== END =========================================
Note: I’m still searching for a way to use variables instead the “fixed” IP addresses; didn’t find a way yet.
Looking forwards for your comments.