X-Git-Url: https://git.madduck.net/code/vinst.git/blobdiff_plain/e5ea710926dc73f39dc9920237d8557c79ad0e5a..d97649fb0bfe21f6cc37571d47ae447083f7bb94:/vinst?ds=inline diff --git a/vinst b/vinst index 5ebd3ca..73d50c4 100755 --- a/vinst +++ b/vinst @@ -5,6 +5,7 @@ set -e # defaults RAM=512 DISK=20 +STORAGE_POOL=default QEMU_URI=qemu:///system SUITE=wheezy CONSOLE='console=tty0 console=ttyS0,115200n8' @@ -34,6 +35,22 @@ while [ -n "$1" ]; do esac IPADDRESS="$1" ;; + (-d|--dns) + shift + if [ -z "$1" ]; then + echo >&2 'E: --dns/-d needs IP address' + exit 1 + fi + NAMESERVER="$1" + ;; + (-g|--gateway) + shift + if [ -z "$1" ]; then + echo >&2 'E: --gateway/-g needs IP address' + exit 1 + fi + GATEWAY="$1" + ;; (-r|--ram) shift if [ -z "$1" ]; then @@ -69,7 +86,7 @@ hostname=${HOSTNAME%%.*} \ domain=${HOSTNAME#*.}" if [ -n "$IPADDRESS" ]; then - if [ -z "$GATEWAY" ]; then + if [ -z "$GATEWAY" ] && [ -x $(command -v ipcalc) ]; then # default to the first IP in the network GATEWAY=$(ipcalc $IPADDRESS | grep HostMin | awk '{print $2}') fi @@ -83,8 +100,11 @@ if [ -n "$IPADDRESS" ]; then netcfg/get_gateway=$GATEWAY \ netcfg/get_nameservers=$NAMESERVER" + BRIDGE=wan + else extra_args="$extra_args netcfg/disable_dhcp=false" + BRIDGE=virt-br fi cat >&2 <<_eof @@ -92,6 +112,7 @@ cat >&2 <<_eof ram: $RAM MiB disk: $DISK GiB console: $CONSOLE +net bridge: $BRIDGE _eof if [ -n "$IPADDRESS" ]; then cat >&2 <<_eof @@ -112,7 +133,7 @@ exec virt-install --connect=$QEMU_URI \ -n $HOSTNAME \ -r $RAM \ --disk pool=default,size=$SIZE \ - -w bridge=virt-br \ + -w bridge=$BRIDGE \ --graphics=vnc \ --serial=pty \ --watchdog i6300esb,action=reset \