All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
   9 QEMU_URI=qemu:///system
 
  11 CONSOLE='console=tty0 console=ttyS0,115200n8'
 
  21         echo >&2 'E: --name/-n needs hostname argument'
 
  29         echo >&2 'E: --ipaddress/-i needs IP address/netmask'
 
  35           echo >&2 'E: missing netmask'
 
  44         echo >&2 'E: --dns/-d needs IP address'
 
  52         echo >&2 'E: --gateway/-g needs IP address'
 
  60         echo >&2 'E: --ram/-r needs number (megabytes)'
 
  68         echo >&2 'E: --size/-s needs size argument'
 
  76         echo >&2 'E: --arch/-a needs arch argument'
 
  84         echo >&2 'E: --mac/-m needs mac address argument'
 
 103 if [ -z "${HOSTNAME:-}" ]; then
 
 104   echo >&2 'E: hostname is required'
 
 108 BASEDIR=$(cd ${0%/*}; pwd)
 
 111 tar -C $BASEDIR/preseed/$SUITE -cf $tmpdir/commands.tar commands
 
 113 extra_args="auto $CONSOLE \
 
 114 hostname=${HOSTNAME%%.*} \
 
 115 domain=${HOSTNAME#*.}"
 
 117 if [ -n "$IPADDRESS" ]; then
 
 118   if [ -z "$GATEWAY" ] && [ -x $(command -v ipcalc) ]; then
 
 119     # default to the first IP in the network
 
 120     GATEWAY=$(ipcalc $IPADDRESS | grep HostMin | awk '{print $2}')
 
 122   NETMASK="${IPADDRESS#*/}"
 
 123   IPADDRESS="${IPADDRESS%/*}"
 
 124   : ${NAMESERVER:=$GATEWAY}
 
 126   extra_args="$extra_args netcfg/disable_dhcp=true \
 
 127   netcfg/get_ipaddress=$IPADDRESS \
 
 128   netcfg/get_netmask=$NETMASK \
 
 129   netcfg/get_gateway=$GATEWAY \
 
 130   netcfg/get_nameservers=$NAMESERVER"
 
 135   extra_args="$extra_args netcfg/disable_dhcp=false"
 
 139 if [ -z "$ARCH" ]; then
 
 140   ARCH=$(dpkg --print-architecture)
 
 143 if [ -z "$MAC" ]; then
 
 144   bytes=$(dd status=none if=/dev/urandom bs=3 count=1 | hexdump -v -e '/1 ":%02X"')
 
 159 if [ -n "$IPADDRESS" ]; then
 
 161  ipaddress: $IPADDRESS
 
 164 nameserver: $NAMESERVER
 
 174 virsh --connect=$QEMU_URI vol-create-as $STORAGE_POOL virt-$HOSTNAME ${DISK}G
 
 175 if [ $WIPE = 1 ]; then
 
 176   virsh --connect=$QEMU_URI vol-wipe --pool $STORAGE_POOL --algorithm zero virt-$HOSTNAME
 
 179 if [ $DEBUG = 1 ]; then
 
 181   extra_args="$extra_args DEBCONF_DEBUG=5"
 
 184 virt-install --connect=$QEMU_URI \
 
 188   --disk vol=$STORAGE_POOL/virt-$HOSTNAME \
 
 189   --network bridge=$BRIDGE,mac=$MAC \
 
 192   --watchdog i6300esb,action=reset \
 
 193   --os-variant=debian$SUITE \
 
 194   -l $BASEDIR/installer-amd64 \
 
 195   --initrd-inject=$BASEDIR/preseed/$SUITE/preseed.cfg \
 
 196   --initrd-inject=$tmpdir/commands.tar \
 
 197   --noautoconsole --autostart \
 
 198   --extra-args="$extra_args" \
 
 201 virsh --connect=$QEMU_URI console $HOSTNAME
 
 203 if [ $RESTART = 1]; then
 
 204   virsh --connect=$QEMU_URI "start $HOSTNAME; console $HOSTNAME"