#!/bin/bash ############################################# # VirtualBox VM Scripts v0.9 # by ulisse aka A. Livio Beccaria # # Common functions ############################################# # the user executing these scripts USER=`whoami` # templates folder TEMPLATE_DIR="${SRC_DIR}/templates" #------------------------------------------------------------------------------- declare -a vms=() create_vm_list () { vms=() for f in $(ls $SRC_DIR/settings/*.settings); do vms=("${vms[@]}" "`basename $f .settings`") done } print_vm_list () { create_vm_list echo "Available VM IDs:" for n in ${vms[@]}; do echo " "$n done } get_vm_id_by_name() { f=`grep -liR "VM_NAME=\"$1\"" ${SRC_DIR}/settings/*.settings` if [ "$f" != "" ]; then echo `basename $f .settings` else echo "" fi } die () { echo >&2 "$@" exit 1 } usage_vm-start () { echo >&2 "$@" echo "Usage: $0 <vm_id | vm_name> [--gui | --fullscreen] [--no-init] [--no-run]" print_vm_list exit 1 } usage_vm-setup () { echo >&2 "$@" echo "Usage: $0 <vm_id> [-u | --update] [-d | --debug] [-h | --help]" echo echo -e "\t-u --update:\tSet VM for update (administrator only)" echo -e "\t-d --debug:\tPrint some debug information" echo -e "\t-h --help:\tPrint this help" echo print_vm_list exit 1 } usage_vbox2template () { echo >&2 "$@" echo "Usage: $0 <vm.vbox> <vm id>" exit 1 }