#!/bin/bash
#
# Sets Default VM folder structure
#
if [ "$UID" -eq 0 ]
then echo "This script should NOT be run as root."
exit 1
fi
#
echo "Define a default directory structure for VMs"
echo "Define an alternate (optional) location of VM by updating VB_BASE_LOC"
echo
echo "The following is completed by the script:
(1) Creates the defined directories
(2) Set permission to dis-allow world reads
(3) Creates a config file under '~/.vbconfig'
This config file will be sourced by other scripts
as required.
"
echo
read -p "Press [Enter] key to start or Ctrl-C to break and update script ..."
echo
#
# Define the location for VirtualBox
# Update the directory locations to suit individual needs (but not variable names)
VB_BASE_LOC=$HOME/avm
VB_DLS_LOC=$VB_BASE_LOC/downloads
VB_DVD_LOC=$VB_BASE_LOC/dvd
VB_VMS_LOC=$VB_BASE_LOC/vms
VB_BIN_LOC=$VB_BASE_LOC/bin
VB_SHR_LOC=$VB_BASE_LOC/shares
VB_LOG_LOC=$VB_BASE_LOC/log
#
set | grep "VB_[A-Z][A-Z][A-Z]_LOC"
echo
echo "Validate if location is acceptable"
echo
read -p "Press [Enter] key to start or Ctrl-C to break and update script ..."
#
# Create directories for VB locations
echo
echo "Creating directories ..."
mkdir -p $VB_BASE_LOC
mkdir -p $VB_DLS_LOC
mkdir -p $VB_DVD_LOC
mkdir -p $VB_VMS_LOC
mkdir -p $VB_BIN_LOC
mkdir -p $VB_SHR_LOC
mkdir -p $VB_LOG_LOC
#
# Set permissions to VM location
chmod 770 $VB_VMS_LOC
#
echo "Create config file for use with other scripts ..."
echo "VB_BASE_LOC=$VB_BASE_LOC
VB_DLS_LOC=$VB_DLS_LOC
VB_DVD_LOC=$VB_DVD_LOC
VB_VMS_LOC=$VB_VMS_LOC
VB_BIN_LOC=$VB_BIN_LOC
VB_SHR_LOC=$VB_SHR_LOC
VB_LOG_LOC=$VB_LOG_LOC" > ~/.vbconfig
echo
echo "Done!"
#
exit