#!/bin/bash
-
+#
# Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
# Date: 2009-10-08
# License: GPL v3+
-
+#
+# depends on grub2
# usage:
# di-maker ISOFILE [FILE ...]
# make a new debian installer ISO, packing any additionally-supplied files into the initramfs directly
set -e
-# depends on grub2
-
# specify the first argument as the new installer image:
-
output="$1"
SUITE=${SUITE:-stable}
mkdir -p "$WORKDIR/boot/grub"
-
cat > "$WORKDIR/boot/grub/grub.cfg" <<EOF
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
terminal_output serial
## no longer using genisoimage with grub2:
# genisoimage -R -input-charset utf-8 -b boot/grub/stage2_eltorito -no-emul-boot --boot-load-size 4 -boot-info-table "$WORKDIR"
-(cd "$WORKDIR" && grub-mkrescue --output="$absoutput" .)
+( cd "$WORKDIR" && grub-mkrescue --output="$absoutput" . )
#!/bin/bash
-#set -x
-
+#
# Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
# Date: 2009-10-08
# License: GPL v3+
+#set -x
+
CMD="$1"
shift
[ "$CMD" == "create" ] && mkdir -p /etc/sv/kvm
usage() {
-
die "USAGE: kvm-creator create|destroy|demo guestname [volumegroup [disksize [ram] ] ]"
-
}
die() {
-
echo "$1"
exit_code=1
[ -n "$2" ] && exit_code="$2"
exit $exit_code
-
}
destroy() {
-
update-service --remove "/etc/sv/kvm/$NAME"
rm -rf "/etc/sv/kvm/$NAME"
deluser --remove-home "$NAME"
lvremove "$VG/$NAME"
rm -f "$(udevrulename "$NAME")"
-
}
validate() {
-
errors=""
# Make sure none of the pieces already exist.
[ -e "$(udevrulename "$NAME")" ] && errors=$(printf "%s\n%s" "The udev rules file '$(udevrulename "$NAME")' already exists.") || :
[ -z "$errors" ] || die "$errors"
-
}
udevrule() {
}
create() {
-
set -e
validate
if [ "$CREATE_USER" = "yes" ]; then
echo "$NAME" > "/etc/sv/kvm/$NAME/env/VMNAME"
echo "$RAM" > "/etc/sv/kvm/$NAME/env/RAM"
echo "$DISK" > "/etc/sv/kvm/$NAME/env/HDA"
-
}
demo() {
-
validate
for foo in NAME VG SIZE RAM DISK ; do
echo "$foo : ${!foo}"
done
-
}
[ "$CMD" != "create" ] && [ "$CMD" != "destroy" ] && [ "$CMD" != "demo" ] && usage
#!/bin/bash
-
-set -e
-
+#
# Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
# Date: 2011-01-26
# License: GPL v3+
# SMP=2 # optional, specify number of CPUs
# HDA..HDZ=/path/to/disk # optional
+set -e
+
if [ -z "$VMNAME" ] ; then
exit 1
fi
BOOTCHOICE=c
if [ -e "$KERNEL" -a -e "$INITRD" ] ; then
- KVMARGS="-kernel $KERNEL -initrd $INITRD"
+ KVMARGS="-kernel $KERNEL -initrd $INITRD"
if [ "$CMDLINE" ]; then
KERNEL_CMDLINE="$CMDLINE"
fi
elif [ -e "$NETBOOT" ] ; then
- BOOTCHOICE=n
+ BOOTCHOICE=n
elif [ -e "$CDISO" ] && [ -e $(readlink -f "$CDISO") ] ; then
- KVMARGS="-cdrom $CDISO"
+ KVMARGS="-cdrom $CDISO"
BOOTCHOICE=d
fi
[ -z "$HDA" ] || KVMARGS="$KVMARGS -drive file=$HDA,if=virtio,cache=none,index=$index,format=raw$first_disk_extra_args"
# loop here on everything after HDA:
for disk in HD{B..Z}; do
- index=$(( $index + 1 ))
- [ \! -b "${!disk}" ] || KVMARGS="$KVMARGS -drive file=${!disk},if=virtio,cache=none,index=$index,format=raw"
+ index=$(( $index + 1 ))
+ [ \! -b "${!disk}" ] || KVMARGS="$KVMARGS -drive file=${!disk},if=virtio,cache=none,index=$index,format=raw"
done
if [ -e /usr/share/qemu/sgabios.bin ]; then
LOGNAME="$OWNERHOME/vms/$VMNAME/console"
ln -sfT "$LOGNAME" ./servicelog
if [ -e "$LOGNAME" ] ; then
- chpst -u "$OWNER" mv "$LOGNAME" "$LOGNAME".$(date +%F_%T%z|tr : .)
+ chpst -u "$OWNER" mv "$LOGNAME" "$LOGNAME".$(date +%F_%T%z|tr : .)
fi
MONITORNAME="$OWNERHOME/vms/$VMNAME/monitor.socket"
chpst -u "$OWNER:$OWNERGROUP:kvm" \
/usr/bin/kvm $KVMARGS \
-M "${MACHINE:-pc}" \
- ${KERNEL_CMDLINE:+-append "$KERNEL_CMDLINE"} \
+ ${KERNEL_CMDLINE:+-append "$KERNEL_CMDLINE"} \
-enable-kvm \
-nodefaults \
-nographic \
trap 'kvmsend system_powerdown; wait %1' TERM
trap 'kvmsend cont; wait %1' CONT
trap 'kill -s TERM %1' QUIT
- # use SIGINT instead of SIGSTOP for freezing the guest because
- # trapping SIGSTOP is undefined:
- # http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_28
+ # use SIGINT instead of SIGSTOP for freezing the guest because
+ # trapping SIGSTOP is undefined:
+ # http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_28
trap 'kvmsend stop; wait %1' INT
trap 'kill %1 ; kill %2' EXIT
wait %1
}
-
down() {
brctl delif "$BRIDGE" "$TAP"
ip link set "$TAP" down
ip tuntap del mode tap dev "$TAP"
-# no need to lock up the block device as well, since the owner might
-# prefer to manipulate the disk directly.
+ # no need to lock up the block device as well, since the owner might
+ # prefer to manipulate the disk directly.
}
log() {