From 9406086e53812de1d10b62d430e18e08c17890b4 Mon Sep 17 00:00:00 2001 From: xtraeme Date: Sat, 1 Oct 2005 02:10:10 +0000 Subject: * Add modified scripts for NetBSD (block-file and vif-bridge) from Ceri Storey via port-xen@, previous scripts were only useful for Linux. * Install the scripts with INSTALL_SCRIPT not INSTALL_DATA. Bump PKGREVISION. --- sysutils/xentools20/Makefile | 26 ++++++++--- sysutils/xentools20/files/block-file-nbsd | 34 ++++++++++++++ sysutils/xentools20/files/vif-bridge-nbsd | 77 +++++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 sysutils/xentools20/files/block-file-nbsd create mode 100644 sysutils/xentools20/files/vif-bridge-nbsd (limited to 'sysutils') diff --git a/sysutils/xentools20/Makefile b/sysutils/xentools20/Makefile index 270f151cbcc..f6298c0ea4f 100644 --- a/sysutils/xentools20/Makefile +++ b/sysutils/xentools20/Makefile @@ -1,9 +1,9 @@ -# $NetBSD: Makefile,v 1.20 2005/09/16 18:14:49 bouyer Exp $ +# $NetBSD: Makefile,v 1.21 2005/10/01 02:10:10 xtraeme Exp $ # DISTNAME= xen-2.0.7-src PKGNAME= xentools20-2.0.7 -PKGREVISION= 3 +PKGREVISION= 4 CATEGORIES= sysutils MASTER_SITES= http://www.cl.cam.ac.uk/Research/SRG/netos/xen/downloads/ EXTRACT_SUFX= .tgz @@ -19,6 +19,8 @@ PKG_SYSCONFSUBDIR= xen ONLY_FOR_PLATFORM= Linux-2.[46]*-i386 NetBSD-*-i386 +CONFLICTS+= libxen-[0-9]* + WRKSRC= ${WRKDIR}/xen-2.0/tools EGDIR= ${PREFIX}/share/examples/xen @@ -74,10 +76,11 @@ PROCPATH= /proc RCD_SCRIPTS= xend FILES_SUBST+= RCD_INTERPRETER=${PYTHONBIN} FILES_SUBST+= PROCPATH=${PROCPATH} +FILES_SUBST+= PKG_SYSCONFDIR=${PKG_SYSCONFDIR} INSTALLATION_DIRS= share/examples/xen -XEND_SCRIPTS= network vif-bridge block-enbd block-file \ +XEND_SCRIPTS= network block-enbd vif-bridge block-file \ xmexample1 xmexample2 xmexample3 CONF_FILES= ${EGDIR}/xend-config.sxp \ @@ -95,9 +98,20 @@ pre-build: post-install: ${INSTALL_DATA} ${WRKSRC}/examples/xend-config.sxp \ ${EGDIR}/xend-config.sxp -.for s in ${XEND_SCRIPTS} - ${INSTALL_DATA} ${WRKSRC}/examples/${s} ${EGDIR}/${s} -.endfor +.if ${OPSYS} == "Linux" +. for s in ${XEND_SCRIPTS} + ${INSTALL_SCRIPT} ${WRKSRC}/examples/${s} ${EGDIR}/${s} +. endfor +.else +. for f in vif-bridge block-file + ${SED} -e "s|@PKG_SYSCONFDIR@|${PKG_SYSCONFDIR}|g" \ + ${FILESDIR}/${f}-nbsd > ${WRKSRC}/${f}-nbsd + ${INSTALL_SCRIPT} ${WRKSRC}/${f}-nbsd ${EGDIR}/${f} +. endfor +. for f in ${XEND_SCRIPTS:S/vif-bridge//:S/block-file//} + ${INSTALL_SCRIPT} ${WRKSRC}/examples/${f} ${EGDIR}/${f} +. endfor +.endif .include "../../lang/python/application.mk" .include "../../lang/python/extension.mk" diff --git a/sysutils/xentools20/files/block-file-nbsd b/sysutils/xentools20/files/block-file-nbsd new file mode 100644 index 00000000000..65eb5630fe1 --- /dev/null +++ b/sysutils/xentools20/files/block-file-nbsd @@ -0,0 +1,34 @@ +#!/bin/sh +# +# $NetBSD: block-file-nbsd,v 1.1 2005/10/01 02:10:10 xtraeme Exp $ +# +# Usage: block_file [bind file|unbind node] +# +# The file argument to the bind command is the file we are to bind to a +# vnd device. We print the path to the vnd device node to stdout. +# +# The node argument to unbind is the name of the device node we are to +# unbind. + +case $1 in + bind) + for dev in /dev/vnd?d; do + if /usr/sbin/vnconfig $dev $2; then + echo $dev + exit 0 + fi + done + exit 1 + ;; + + unbind) + /usr/sbin/vnconfig -u $2 + exit 0 + ;; + + *) + echo 'Unknown command: ' $1 + echo 'Valid commands are: bind, unbind' + exit 1 + ;; +esac diff --git a/sysutils/xentools20/files/vif-bridge-nbsd b/sysutils/xentools20/files/vif-bridge-nbsd new file mode 100644 index 00000000000..1f0a6110dd2 --- /dev/null +++ b/sysutils/xentools20/files/vif-bridge-nbsd @@ -0,0 +1,77 @@ +#!/bin/sh +# +# $NetBSD: vif-bridge-nbsd,v 1.1 2005/10/01 02:10:10 xtraeme Exp $ +# +#============================================================================ +# @PKG_SYSCONFDIR@/vif-bridge +# +# Script for configuring a vif in bridged mode. +# Xend calls a vif script when bringing a vif up or down. +# This script is the default - but it can be configured for each vif. +# +# Example invocation: +# +# vif-bridge up domain=VM1 vif=xvif1.0 bridge=bridge0 ip="128.232.38.45/28 10.10.10.55/24" +# +# +# Usage: +# vif-bridge (up|down) {VAR=VAL}* +# +# Vars: +# +# domain name of the domain the interface is on (required). +# vif vif interface name (required). +# mac vif MAC address (required). +# bridge bridge to add the vif to (required). +# ip list of IP networks for the vif, space-separated (optional). +# +# up: +# Enslaves the vif interface to the bridge and adds iptables rules +# for its ip addresses (if any). +# +# down: +# Removes the vif interface from the bridge and removes the iptables +# rules for its ip addresses (if any). +#============================================================================ + +# 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:?} + +# 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 + +# Add/remove vif to/from bridge. +/sbin/brconfig ${bridge} ${brcmd} ${vif} +/sbin/ifconfig ${vif} $OP -- cgit v1.2.3