GhettoVCB - clone.sh Script
Jump to navigation
Jump to search
This script does not yet have any options (other than editing the script itself, to select the datastore where the new VM will live.
!/bin/sh
export PATH=/bin:/sbin
# ----------------------------------
# Step #1: Define variables
# ----------------------------------
RED='\033[0;41;30m'
STD='\033[0;0;39m'
VMName=$1
Destination="/vmfs/volumes/0-VMs"
# ----------------------------------
# Step #2: User defined function
# ----------------------------------
pause(){
read -p "Press [Enter] key to continue..." fackEnterKey
}
clone(){
echo "ghettoVCB/clone.sh is creating "$VMName" from "$BaseLine
logger "ghettoVCB/clone.sh is creating "$VMName" from "$BaseLine
echo "/vmfs/volumes/Admin/CloneMe/"$BaseLine/$BaseLine"-0;"$Destination";1;"$VMName > CloneIt
/vmfs/volumes/Admin/Utilities/ghettoVCB/ghettoVCB-restore.sh -c CloneIt
logger "ghettoVCB/clone.sh "$VMName" finished"
echo "ghettoVCB/clone.sh "$VMName" finished"
}
# function to display menus
show_menus() {
clear
echo "Preparing to create "$VMName
echo "Placing the VM on "$Destination
echo "~~~~~~~~~~~~~~~~~~~~~~~~~"
echo " Select your Baseline VM "
echo "~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "1: Linux Mint 19.3"
echo "2: SparkyLinux-CLI 5.11"
echo "3: SparkyLinux-GUI 5.11"
echo "4: Windows 10"
echo "5: Windows 7"
echo ""
echo "0. Exit"
}
# read input from the keyboard and take an action
# Exit when user the user selects 0 form the menu option.
read_options(){
local choice
read -p "Enter choice [ 1-5 or 0] " choice
case $choice in
1) echo "Linux Mint 19.3"
BaseLine="CloneMe-Mint-19.3"
clone
exit 0
;;
2) echo "SparkyLinux-CLI 5.11"
BaseLine="CloneMe-SparkyLinux-CLI-5.11"
clone
exit 0
;;
3) echo "SparkyLinux-GUI 5.11"
BaseLine="CloneMe-SparkyLinux-GUI-5.11"
clone
exit 0
;;
4) echo "Windows 10"
BaseLine="CloneMe-Windows-10"
clone
exit 0
;;
5) echo "Windows 7"
BaseLine="CloneMe-Windows-7"
clone
exit 0
;;
0) exit 0
;;
*) echo -e "${RED}Error...${STD}" && sleep 2
esac
}
# ----------------------------------------------
# Step #3: Trap CTRL+C, CTRL+Z and quit singles
# ----------------------------------------------
trap SIGINT SIGQUIT SIGTSTP
# -----------------------------------
# Step #4: Main logic - infinite loop
# -----------------------------------
while true
do
show_menus
read_options
done
Usage:
cd /vmfs/volumes/Admin/Utilities/ghettoVCBclone.sh VMNAME