#!/bin/sh
# Copyright (C) 2014-2015 Jurriaan Bremer.
# This file is part of VMCloak - http://www.vmcloak.org/.
# See the file 'docs/LICENSE.txt' for copying permission.

# Only create a new hostonly interface if it does not already exist.
if [ -z "$(VBoxManage list hostonlyifs)" ]; then
    VBoxManage hostonlyif create
fi

# Configure the hostonly interface and automatically enable it (also in
# case it already existed but was disabled).

if [ $# -ne 0 ]; then
   if [[ $1 == '-h' ]]; then
       echo "Usage:"
       echo "    $0 ip"
       echo "    $0 192.168.56.1"
       echo ""
       echo "By default will be:"
       echo "    $0 192.168.56.1"
       echo ""
       exit
    elif [[ $1 != '-h' ]]; then
        VBoxManage hostonlyif ipconfig vboxnet0 --ip $1
    else
        VBoxManage hostonlyif ipconfig vboxnet0 --ip 192.168.56.1
   fi
fi
