Hans Bezemer wrote:
The following changes have been applied to the script:
- Automatic enabling of the TELNET serial port;
- Support for 10+ snapshots (probably);
- Support for Zenity (GNOME, also Windows);
- Put it explicitly under the GPL license
This script requires Zenity, BGStart and MSYS for Windows.
See also:
http://thebeezspeaks.blogspot.com/2011/02/running-shellscripts-under-windows.html
http://thebeezspeaks.blogspot.com/2011/01/installing-wwf-toolkit-under-windows.html
Hans Bezemer
---8<---
#! /bin/sh
# Script to start Coherent on QEMU - Copyright 2012 J.L. Bezemer
# You can redistribute this file and/or modify it under
# the terms of the GNU General Public License
#
# Coherent disk configuration, change as required
# This configuration assumes a single harddisk and a floppy
# Both in QCOW2 format
#
COHAT0A=/opt/qemu/coherent.dsk
COHFD0=/opt/qemu/null.dsk
#
# Returns non-zero when program found in $PATH, otherwise zero.
#
function installed {
which "$1" 2> /dev/null | wc -l
}
#
# Generalized functions to let the GUI utility show a text or combo box
#
function error_box {
case `basename "$GUI"` in
kdialog) $GUI --error "$1"
;;
zenity) $GUI --error --text="$1"
;;
esac
exit 1
}
function warning_box {
case `basename "$GUI"` in
kdialog) $GUI --sorry "$1"
;;
zenity) $GUI --warning --text="$1"
;;
esac
}
function combo_box {
case `basename "$GUI"` in
kdialog) $GUI --combobox "Select Coherent snapshot:" "$@"
;;
zenity) $GUI --title "Select Coherent
snapshot" --list --column="Available snapshots" "$@"
;;
esac
}
#
# Try to find a GUI utility.
#
if [ `installed kdialog` -gt 0 ]; then
GUI=`which kdialog`
elif [ `installed zenity` -gt 0 ]; then
GUI=`which zenity`
else
echo "(ERROR): Can't find: 'Zenity' or 'KDialog'"
exit 1
fi
#
# Check for all QEMU components
#
if [ `installed qemu-img` -gt 0 ]; then
QEMUIMG=`which qemu-img`
else
error_box "Can't find: 'qemu-img'"
fi
if [ `installed qemu-system-i386` -gt 0 ]; then
QEMU386=`which qemu-system-i386`
else
error_box "Can't find: 'qemu-system-i386'"
fi
#
# If all disks are available, select the snapshot and start Coherent
#
if [ -f $COHAT0A ]; then
if [ -f $COHFD0 ]; then
SNAPSHOT=`$QEMUIMG snapshot -l $COHAT0A | grep -e "^[0-9]" | cut -c
11-33`
SNAPSHOT=`combo_box $SNAPSHOT`; CANCEL=$?
if [ $CANCEL -eq 0 ]; then
$QEMU386 -hda $COHAT0A -fda $COHFD0 -m 16 -serial
telnet:localhost:4444,server,nowait -loadvm $SNAPSHOT
else
warning_box "Coherent start cancelled"
fi
exit 0
fi
fi
#
# This is trapped when the disks are not found
#
error_box "Can't find: $COHAT0A or $COHFD0"
---8<---