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.
10 QEMU_URI=qemu:///system
12 CONSOLE='console=tty0 console=ttyS0,115200n8'
25 echo >&2 'E: --suite/-S needs suite argument'
33 echo >&2 'E: --name/-n needs hostname argument'
41 echo >&2 'E: --ipaddress/-i needs IP address/netmask'
47 echo >&2 'E: missing netmask'
56 echo >&2 'E: --dns/-d needs IP address'
64 echo >&2 'E: --gateway/-g needs IP address'
72 echo >&2 'E: --ram/-r needs number (megabytes)'
80 echo >&2 'E: --size/-s needs size argument'
88 echo >&2 'E: --arch/-a needs arch argument'
96 echo >&2 'E: --mac/-m needs mac address argument'
104 echo >&2 'E: --cpus/-c needs integer argument'
123 if [ -z "${HOSTNAME:-}" ]; then
124 echo >&2 'E: hostname is required'
128 BASEDIR=$(cd ${0%/*}; pwd)
131 tar -C $BASEDIR/preseed/$SUITE -cf $tmpdir/commands.tar commands
133 extra_kargs="auto $CONSOLE \
134 hostname=${HOSTNAME%%.*} \
135 domain=${HOSTNAME#*.}"
138 if [ -n "$DEBUG" ]; then
142 if [ -n "$IPADDRESS" ]; then
143 if [ -z "$GATEWAY" ] && [ -x $(command -v ipcalc) ]; then
144 # default to the first IP in the network
145 GATEWAY=$(ipcalc $IPADDRESS | grep HostMin | awk '{print $2}')
147 NETMASK="${IPADDRESS#*/}"
148 IPADDRESS="${IPADDRESS%/*}"
149 : ${NAMESERVER:=$GATEWAY}
151 extra_kargs="$extra_kargs netcfg/disable_dhcp=true \
152 netcfg/get_ipaddress=$IPADDRESS \
153 netcfg/get_netmask=$NETMASK \
154 netcfg/get_gateway=$GATEWAY \
155 netcfg/get_nameservers=$NAMESERVER"
160 extra_kargs="$extra_kargs netcfg/disable_dhcp=false"
164 if [ -z "$ARCH" ]; then
165 ARCH=$(dpkg --print-architecture)
168 if [ -z "$MAC" ]; then
169 bytes=$(dd status=noxfer if=/dev/urandom bs=3 count=1 | hexdump -v -e '/1 ":%02X"')
186 if [ -n "$IPADDRESS" ]; then
188 ipaddress: $IPADDRESS
191 nameserver: $NAMESERVER
201 virsh --connect=$QEMU_URI vol-create-as $STORAGE_POOL virt-$HOSTNAME ${DISK}G
202 if [ $WIPE = 1 ]; then
203 echo >&2 "Wiping disk…"
204 virsh --connect=$QEMU_URI vol-wipe --pool $STORAGE_POOL --algorithm zero virt-$HOSTNAME
207 if [ $DEBUG = 1 ]; then
209 extra_args="$extra_args DEBCONF_DEBUG=5"
212 virt-install --connect=$QEMU_URI \
217 --disk vol=$STORAGE_POOL/virt-$HOSTNAME \
218 --network bridge=$BRIDGE,mac=$MAC \
221 --watchdog i6300esb,action=reset \
222 --os-variant=debianwheezy \
223 --initrd-inject=$BASEDIR/preseed/$SUITE/preseed.cfg \
224 --initrd-inject=$tmpdir/commands.tar \
225 --extra-args="$extra_kargs" \
226 --prompt --noautoconsole --autostart $extra_opts \
227 -l $BASEDIR/installer-amd64/$SUITE \
230 virsh --connect=$QEMU_URI console $HOSTNAME
232 if [ $RESTART = 1 ]; then
233 virsh --connect=$QEMU_URI "start $HOSTNAME; console $HOSTNAME"