8e6f1ae3d1
installations. * Modify the package to not install all of the configuration files with the execute bit set -- only install the helper scripts that way. * Update the block-file-nbsd script to not blindly try to configure (and often fail to configure) every vnd(4) device until it finds one that works. We now just determine what the next free vnd(4) device is and configure it directly. * Add a netbsd-nbsd script that avoids trying to do all the Linux-specific that just filled the log files with garbage on NetBSD. * Update the vif-bridge-nbsd script to check that the bridge device is configured before using it. * Add clear comments at the top of scripts that can be customized so that the user has enough information to know how to do the customization. * Add a xendomains rc.d script that can be used to start and stop guest domains at system boot- or shutdown-time. Bump the PKGREVISION to 5.
73 lines
1.8 KiB
Bash
73 lines
1.8 KiB
Bash
#!/bin/sh
|
|
#============================================================================
|
|
# $NetBSD: vif-bridge-nbsd,v 1.3 2005/11/08 00:47:35 jlam Exp $
|
|
#
|
|
# @PKG_SYSCONFDIR@/vif-bridge
|
|
#
|
|
# Script for configuring a vif in bridged mode with a dom0 interface.
|
|
# The xend(8) daemon calls a vif script when bringing a vif up or down.
|
|
# The script name to use is defined in @PKG_SYSCONFDIR@/xend-config.sxp
|
|
# in the ``vif-script'' field.
|
|
#
|
|
# Usage: vif-bridge up|down [var=value ...]
|
|
#
|
|
# Actions:
|
|
# up Adds the vif interface to the bridge.
|
|
# down Removes the vif interface from the bridge.
|
|
#
|
|
# Variables:
|
|
# domain name of the domain the interface is on (required).
|
|
# vifq vif interface name (required).
|
|
# mac vif MAC address (required).
|
|
# bridge bridge to add the vif to (required).
|
|
#
|
|
# Example invocation:
|
|
#
|
|
# vif-bridge up domain=VM1 vif=xvif1.0 mac="ee:14:01:d0:ec:af" bridge=bridge0
|
|
#
|
|
#============================================================================
|
|
|
|
# Exit if anything goes wrong
|
|
set -e
|
|
|
|
echo "vif-bridge $*"
|
|
|
|
# Operation name.
|
|
OP=$1; shift
|
|
|
|
# Pull variables in args into environment
|
|
for arg ; do export "${arg}" ; done
|
|
|
|
# Required parameters. Fail if not set.
|
|
domain=${domain:?}
|
|
vif=${vif:?}
|
|
mac=${mac:?}
|
|
bridge=${bridge:?}
|
|
|
|
# Optional parameters. Set defaults.
|
|
ip=${ip:-''} # default to null (do nothing)
|
|
|
|
# Are we going up or down?
|
|
case $OP in
|
|
up) brcmd='add' ;;
|
|
down) brcmd='delete' ;;
|
|
*)
|
|
echo 'Invalid command: ' $OP
|
|
echo 'Valid commands are: up, down'
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# Don't do anything if the bridge is "null".
|
|
if [ "${bridge}" = "null" ] ; then
|
|
exit
|
|
fi
|
|
|
|
# Don't do anything if the bridge doesn't exist.
|
|
if ! ifconfig -l | grep "${bridge}" >/dev/null; then
|
|
exit
|
|
fi
|
|
|
|
# Add/remove vif to/from bridge.
|
|
ifconfig x${vif} $OP
|
|
brconfig ${bridge} ${brcmd} x${vif}
|