X-Git-Url: https://git.madduck.net/code/vinst.git/blobdiff_plain/c5d7227a2c01b7ca53d7cd135d930d57ce43f004..917844557b969b6d41fcfa2e87e7a8a2a37a915c:/vinst?ds=sidebyside diff --git a/vinst b/vinst index 9a8eb90..51a87e9 100755 --- a/vinst +++ b/vinst @@ -35,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 @@ -70,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 @@ -84,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 @@ -93,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 @@ -107,13 +127,15 @@ else _eof fi -exit 0 -exec virt-install --connect=$QEMU_URI \ +set -v +virsh --connect=$QEMU_URI vol-create-as $STORAGE_POOL virt-$HOSTNAME ${DISK}G + +virt-install --connect=$QEMU_URI \ -n $HOSTNAME \ -r $RAM \ - --disk pool=default,size=$SIZE \ - -w bridge=virt-br \ + --disk vol=$STORAGE_POOL/virt-$HOSTNAME \ + -w bridge=$BRIDGE \ --graphics=vnc \ --serial=pty \ --watchdog i6300esb,action=reset \ @@ -121,6 +143,9 @@ exec virt-install --connect=$QEMU_URI \ -l $BASEDIR/installer-amd64 \ --initrd-inject=$BASEDIR/preseed/$SUITE/preseed.cfg \ --initrd-inject=$tmpdir/commands.tar \ + --prompt --noautoconsole --autostart \ --extra-args="$extra_args" \ - --autostart \ "$@" + +virsh --connect=$QEMU_URI console $HOSTNAME +virsh --connect=$QEMU_URI "start $HOSTNAME; console $HOSTNAME"