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: --name/-n needs hostname argument'
32 echo >&2 'E: --ipaddress/-i needs IP address/netmask'
38 echo >&2 'E: missing netmask'
47 echo >&2 'E: --dns/-d needs IP address'
55 echo >&2 'E: --gateway/-g needs IP address'
63 echo >&2 'E: --ram/-r needs number (megabytes)'
71 echo >&2 'E: --size/-s needs size argument'
79 echo >&2 'E: --arch/-a needs arch argument'
87 echo >&2 'E: --mac/-m needs mac address argument'
106 if [ -z "${HOSTNAME:-}" ]; then
107 echo >&2 'E: hostname is required'
111 BASEDIR=$(cd ${0%/*}; pwd)
114 tar -C $BASEDIR/preseed/$SUITE -cf $tmpdir/commands.tar commands
116 extra_kargs="auto $CONSOLE \
117 hostname=${HOSTNAME%%.*} \
118 domain=${HOSTNAME#*.}"
121 if [ -n "$DEBUG" ]; then
125 if [ -n "$IPADDRESS" ]; then
126 if [ -z "$GATEWAY" ] && [ -x $(command -v ipcalc) ]; then
127 # default to the first IP in the network
128 GATEWAY=$(ipcalc $IPADDRESS | grep HostMin | awk '{print $2}')
130 NETMASK="${IPADDRESS#*/}"
131 IPADDRESS="${IPADDRESS%/*}"
132 : ${NAMESERVER:=$GATEWAY}
134 extra_kargs="$extra_kargs netcfg/disable_dhcp=true \
135 netcfg/get_ipaddress=$IPADDRESS \
136 netcfg/get_netmask=$NETMASK \
137 netcfg/get_gateway=$GATEWAY \
138 netcfg/get_nameservers=$NAMESERVER"
143 extra_kargs="$extra_kargs netcfg/disable_dhcp=false"
147 if [ -z "$ARCH" ]; then
148 ARCH=$(dpkg --print-architecture)
151 if [ -z "$MAC" ]; then
152 bytes=$(dd status=none if=/dev/urandom bs=3 count=1 | hexdump -v -e '/1 ":%02X"')
167 if [ -n "$IPADDRESS" ]; then
169 ipaddress: $IPADDRESS
172 nameserver: $NAMESERVER
182 virsh --connect=$QEMU_URI vol-create-as $STORAGE_POOL virt-$HOSTNAME ${DISK}G
183 if [ $WIPE = 1 ]; then
184 echo >&2 "Wiping disk…"
185 virsh --connect=$QEMU_URI vol-wipe --pool $STORAGE_POOL --algorithm zero virt-$HOSTNAME
188 if [ $DEBUG = 1 ]; then
190 extra_args="$extra_args DEBCONF_DEBUG=5"
193 virt-install --connect=$QEMU_URI \
197 --disk vol=$STORAGE_POOL/virt-$HOSTNAME \
198 --network bridge=$BRIDGE,mac=$MAC \
201 --watchdog i6300esb,action=reset \
202 --os-variant=debian$SUITE \
203 -l $BASEDIR/installer-amd64 \
204 --initrd-inject=$BASEDIR/preseed/$SUITE/preseed.cfg \
205 --initrd-inject=$tmpdir/commands.tar \
206 --prompt --noautoconsole --autostart \
207 --extra-args="$extra_kargs" \
210 virsh --connect=$QEMU_URI console $HOSTNAME
212 if [ $RESTART = 1 ]; then
213 virsh --connect=$QEMU_URI "start $HOSTNAME; console $HOSTNAME"