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'
24 echo >&2 'E: --suite/-S needs suite argument'
32 echo >&2 'E: --name/-n needs hostname argument'
40 echo >&2 'E: --ipaddress/-i needs IP address/netmask'
46 echo >&2 'E: missing netmask'
55 echo >&2 'E: --dns/-d needs IP address'
63 echo >&2 'E: --gateway/-g needs IP address'
71 echo >&2 'E: --ram/-r needs number (megabytes)'
79 echo >&2 'E: --size/-s needs size argument'
87 echo >&2 'E: --arch/-a needs arch argument'
95 echo >&2 'E: --mac/-m needs mac address argument'
114 if [ -z "${HOSTNAME:-}" ]; then
115 echo >&2 'E: hostname is required'
119 BASEDIR=$(cd ${0%/*}; pwd)
122 tar -C $BASEDIR/preseed/$SUITE -cf $tmpdir/commands.tar commands
124 extra_kargs="auto $CONSOLE \
125 hostname=${HOSTNAME%%.*} \
126 domain=${HOSTNAME#*.}"
129 if [ -n "$DEBUG" ]; then
133 if [ -n "$IPADDRESS" ]; then
134 if [ -z "$GATEWAY" ] && [ -x $(command -v ipcalc) ]; then
135 # default to the first IP in the network
136 GATEWAY=$(ipcalc $IPADDRESS | grep HostMin | awk '{print $2}')
138 NETMASK="${IPADDRESS#*/}"
139 IPADDRESS="${IPADDRESS%/*}"
140 : ${NAMESERVER:=$GATEWAY}
142 extra_kargs="$extra_kargs netcfg/disable_dhcp=true \
143 netcfg/get_ipaddress=$IPADDRESS \
144 netcfg/get_netmask=$NETMASK \
145 netcfg/get_gateway=$GATEWAY \
146 netcfg/get_nameservers=$NAMESERVER"
151 extra_kargs="$extra_kargs netcfg/disable_dhcp=false"
155 if [ -z "$ARCH" ]; then
156 ARCH=$(dpkg --print-architecture)
159 if [ -z "$MAC" ]; then
160 bytes=$(dd status=none if=/dev/urandom bs=3 count=1 | hexdump -v -e '/1 ":%02X"')
176 if [ -n "$IPADDRESS" ]; then
178 ipaddress: $IPADDRESS
181 nameserver: $NAMESERVER
191 virsh --connect=$QEMU_URI vol-create-as $STORAGE_POOL virt-$HOSTNAME ${DISK}G
192 if [ $WIPE = 1 ]; then
193 echo >&2 "Wiping disk…"
194 virsh --connect=$QEMU_URI vol-wipe --pool $STORAGE_POOL --algorithm zero virt-$HOSTNAME
197 if [ $DEBUG = 1 ]; then
199 extra_args="$extra_args DEBCONF_DEBUG=5"
202 virt-install --connect=$QEMU_URI \
206 --disk vol=$STORAGE_POOL/virt-$HOSTNAME \
207 --network bridge=$BRIDGE,mac=$MAC \
210 --watchdog i6300esb,action=reset \
211 -l $BASEDIR/installer-amd64 \
212 --os-variant=debianwheezy \
213 --initrd-inject=$BASEDIR/preseed/$SUITE/preseed.cfg \
214 --initrd-inject=$tmpdir/commands.tar \
215 --prompt --noautoconsole --autostart \
216 --extra-args="$extra_kargs" \
219 virsh --connect=$QEMU_URI console $HOSTNAME
221 if [ $RESTART = 1 ]; then
222 virsh --connect=$QEMU_URI "start $HOSTNAME; console $HOSTNAME"