My first official shell script

Here is my first official shell script, had to share!  I’m a VMware vRealize Automation administrator, some of the use cases I’m developing are simple.  As I get more comfortable with the product and how to use it, my hope is share more blog entries.  Hope this sparks some ideas!

Here is my scenerio.

  • Deploy a template, add a script called ./addnetwork.sh on the guest
  • Make a snapshot
  • Add Blueprint in vRA, make a catalog item and entitlement
  • Make a subscription to a workflow,
  • have a workflow to retrieve data from the vRA payload
  • Run a program in-guest and pass the data adding the network.
  • Watch the magic happen!

My first official shell script

This happened to be on a vRealize Orchestrator appliance

mv /etc/HOSTNAME /etc/HOMENAME.original
echo $1 >> /etc/HOSTNAME

mv /etc/sysconfig/networking/devices/ifcfg-eth0 /etc/sysconfig/networking/devices/ifcfg-eth0.original
echo “DEVICE=eth0” >> /etc/sysconfig/networking/devices/ifcfg-eth0
echo “BOOTPROTO=’static'” >> /etc/sysconfig/networking/devices/ifcfg-eth0
echo “STARTMODE=’auto'” >> /etc/sysconfig/networking/devices/ifcfg-eth0
echo “TYPE=Ethernet” >> /etc/sysconfig/networking/devices/ifcfg-eth0
echo “USERCONTROL=’no'” >> /etc/sysconfig/networking/devices/ifcfg-eth0
echo “IPADDR=’$2′” >> /etc/sysconfig/networking/devices/ifcfg-eth0
echo “NETMASK=’$3′ >> /etc/sysconfig/networking/devices/ifcfg-eth0
echo “BROADCAST=’$4′” >> /etc/sysconfig/networking/devices/ifcfg-eth0

mv /etc/sysconfig/network/routes /etc/sysconfig/network/routes.original
echo “default $5 – -” >> /etc/sysconfig/network/routes

#This is the syntax of the script, test on the reference machine before integrating vRA / #./addnetwork ‘hostname’ ‘ipaddr’ ‘netmask’ ‘broadcast’ ‘gateway’