netplan script

Here is the script that I am using to deploy new ubuntu virtual machine:

#!/bin/bash -x
 
if [ -z ${1} ]; then
 
        echo "please give hostname and IP address"
        echo "${0} hostname IP"
 
 
else
 
        hostname=${1}
 
        echo "$hostname" > /etc/hostname
        if [ $? -eq 0 ]; then
                echo "-- SUCCESS"
        else
                echo "-- SOMETHING WENT WRONG!"
                exit 1
        fi
        echo "Hostname set"
 
 
        get_net=$(ip address | grep 2: | awk '{print $2}' | sed 's/://')
 
        echo
        cat > /etc/netplan/00-installer-config.yaml  <

 


	

Leave a Reply