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 echo >&2 "Wiping disk…"
177 virsh --connect=$QEMU_URI vol-wipe --pool $STORAGE_POOL --algorithm zero virt-$HOSTNAME
180 if [ $DEBUG = 1 ]; then
182 extra_args="$extra_args DEBCONF_DEBUG=5"
185 virt-install --connect=$QEMU_URI \
189 --disk vol=$STORAGE_POOL/virt-$HOSTNAME \
190 --network bridge=$BRIDGE,mac=$MAC \
193 --watchdog i6300esb,action=reset \
194 --os-variant=debian$SUITE \
195 -l $BASEDIR/installer-amd64 \
196 --initrd-inject=$BASEDIR/preseed/$SUITE/preseed.cfg \
197 --initrd-inject=$tmpdir/commands.tar \
198 --noautoconsole --autostart \
199 --extra-args="$extra_args" \
202 virsh --connect=$QEMU_URI console $HOSTNAME
204 if [ $RESTART = 1]; then
205 virsh --connect=$QEMU_URI "start $HOSTNAME; console $HOSTNAME"