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 size argument'
95 if [ -z "${HOSTNAME:-}" ]; then
96 echo >&2 'E: hostname is required'
100 BASEDIR=$(cd ${0%/*}; pwd)
103 tar -C $BASEDIR/preseed/$SUITE -cf $tmpdir/commands.tar commands
105 extra_args="auto $CONSOLE \
106 hostname=${HOSTNAME%%.*} \
107 domain=${HOSTNAME#*.}"
109 if [ -n "$IPADDRESS" ]; then
110 if [ -z "$GATEWAY" ] && [ -x $(command -v ipcalc) ]; then
111 # default to the first IP in the network
112 GATEWAY=$(ipcalc $IPADDRESS | grep HostMin | awk '{print $2}')
114 NETMASK="${IPADDRESS#*/}"
115 IPADDRESS="${IPADDRESS%/*}"
116 : ${NAMESERVER:=$GATEWAY}
118 extra_args="$extra_args netcfg/disable_dhcp=true \
119 netcfg/get_ipaddress=$IPADDRESS \
120 netcfg/get_netmask=$NETMASK \
121 netcfg/get_gateway=$GATEWAY \
122 netcfg/get_nameservers=$NAMESERVER"
127 extra_args="$extra_args netcfg/disable_dhcp=false"
131 if [ -z "$ARCH" ]; then
132 ARCH=$(dpkg --print-architecture)
145 if [ -n "$IPADDRESS" ]; then
147 ipaddress: $IPADDRESS
150 nameserver: $NAMESERVER
160 virsh --connect=$QEMU_URI vol-create-as $STORAGE_POOL virt-$HOSTNAME ${DISK}G
161 if [ $WIPE = 1 ]; then
162 virsh --connect=$QEMU_URI vol-wipe --pool $STORAGE_POOL --algorithm zero virt-$HOSTNAME
165 if [ $DEBUG = 1 ]; then
167 extra_args="$extra_args DEBCONF_DEBUG=5"
170 virt-install --connect=$QEMU_URI \
174 --disk vol=$STORAGE_POOL/virt-$HOSTNAME \
178 --watchdog i6300esb,action=reset \
179 --os-variant=debian$SUITE \
180 -l $BASEDIR/installer-amd64 \
181 --initrd-inject=$BASEDIR/preseed/$SUITE/preseed.cfg \
182 --initrd-inject=$tmpdir/commands.tar \
183 --noautoconsole --autostart \
184 --extra-args="$extra_args" \
187 virsh --connect=$QEMU_URI console $HOSTNAME
189 if [ $RESTART = 1]; then
190 virsh --connect=$QEMU_URI "start $HOSTNAME; console $HOSTNAME"