mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
qemu-boot.sh: Add support for -n (network card model)
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
a7dc00db87
commit
f6af9442c1
1 changed files with 24 additions and 9 deletions
|
|
@ -21,6 +21,16 @@ EOT
|
|||
exit 0
|
||||
}
|
||||
|
||||
err()
|
||||
{
|
||||
echo $* >&2
|
||||
}
|
||||
|
||||
fatal()
|
||||
{
|
||||
err $@
|
||||
exit 1
|
||||
}
|
||||
|
||||
do_sudo()
|
||||
{
|
||||
|
|
@ -41,6 +51,7 @@ ldap_search()
|
|||
local ldap_server=ldap.lcl
|
||||
local binddn=cn=ldapadm,dc=jannet,dc=de
|
||||
local password_file=$HOME/.feedfs-ldap/passwords/$binddn@$ldap_server
|
||||
[ -r "$password_file" ] || fatal "Password file $password_file doesn't exist"
|
||||
ldapsearch -y $password_file -xZ -h $ldap_server -D $binddn -b $base,ou=networks,dc=jannet,dc=de $@
|
||||
}
|
||||
|
||||
|
|
@ -52,7 +63,7 @@ list_hostnames()
|
|||
boot_net()
|
||||
{
|
||||
[ "$hostname" ] && {
|
||||
local short_hostname=`echo $hostname | sed 's/\..*//'`
|
||||
set -x
|
||||
macaddr=`ldap_search -LLL "(cn=$short_hostname) dhcpHWAddress" |
|
||||
sed '/dhcpHWAddress:/ !d; s/dhcpHWAddress: ethernet *//'`
|
||||
}
|
||||
|
|
@ -63,12 +74,13 @@ boot_net()
|
|||
ps aux | grep -v grep | grep -q dhcpd || /etc/init.d/dhcpd start
|
||||
ps aux | grep -v grep | grep -q nfsd || /etc/init.d/nfsserver start
|
||||
|
||||
[ "$nic_model" ] || nic_model=",model=e1000"
|
||||
# need this for net access, would be nicer if it didn't run as root
|
||||
# -nographic
|
||||
do_sudo -E /usr/bin/$exe \
|
||||
-boot n \
|
||||
-net tap,ifname=tap0,vlan=0,script=$tmpdir/qemu-ifup,downscript=$tmpdir/qemu-ifdown \
|
||||
-net nic,vlan=0,model=e1000,macaddr=$macaddr \
|
||||
-net nic,vlan=0$nic_model,macaddr=$macaddr \
|
||||
"$qemu_opts"
|
||||
}
|
||||
|
||||
|
|
@ -76,17 +88,14 @@ boot_image()
|
|||
{
|
||||
local boot_image="$1"
|
||||
|
||||
test -r "$boot_image" || {
|
||||
echo "inaccessible boot image \"$boot_image\"" >&2
|
||||
exit 1
|
||||
}
|
||||
test -r "$boot_image" || fatal "inaccessible boot image \"$boot_image\""
|
||||
|
||||
xhost +
|
||||
do_sudo -E /usr/bin/$exe \
|
||||
-net tap,ifname=tap0,vlan=0,script=$tmpdir/qemu-ifup,downscript=$tmpdir/qemu-ifdown \
|
||||
-net nic,vlan=0$nic_model,macaddr=$macaddr \
|
||||
"$qemu_opts" \
|
||||
$boot_image
|
||||
-drive format=raw,file=$boot_image
|
||||
}
|
||||
|
||||
boot()
|
||||
|
|
@ -113,7 +122,7 @@ boot()
|
|||
# -- here we go
|
||||
|
||||
OPTIND=1
|
||||
while getopts lhb:o:x: flag; do
|
||||
while getopts lhb:o:x:n: flag; do
|
||||
case $flag in
|
||||
h)
|
||||
usage 0;;
|
||||
|
|
@ -121,11 +130,17 @@ while getopts lhb:o:x: flag; do
|
|||
list_hostnames
|
||||
exit 0;;
|
||||
b)
|
||||
hostname="$OPTARG";;
|
||||
hostname="$OPTARG"
|
||||
short_hostname=`echo $hostname | sed 's/\..*//'`
|
||||
dns_domain=`echo $hostname | cut -d. -f2-`
|
||||
base=`echo $dns_domain | sed 's/\./,/g; s/\(^\|,\)/\1dc=/g'`
|
||||
;;
|
||||
x)
|
||||
exe="$OPTARG";;
|
||||
o)
|
||||
qemu_opts="$OPTARG";;
|
||||
n)
|
||||
nic_model=",model=$OPTARG";;
|
||||
*)
|
||||
usage 1;;
|
||||
esac
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue