diff options
author | Bernhard Froehlich <decke@FreeBSD.org> | 2011-05-22 09:15:09 +0000 |
---|---|---|
committer | Bernhard Froehlich <decke@FreeBSD.org> | 2011-05-22 09:15:09 +0000 |
commit | 6fe0379a7b14f3d5f4b7b0b9d75a438ba3771048 (patch) | |
tree | 443ec063151631124bf6709070f089b50214843b /emulators/virtualbox-ose-legacy | |
parent | 5a8e3290525d9e23513f2f678658a1c389ebafa5 (diff) |
Notes
Diffstat (limited to 'emulators/virtualbox-ose-legacy')
-rw-r--r-- | emulators/virtualbox-ose-legacy/Makefile | 19 | ||||
-rw-r--r-- | emulators/virtualbox-ose-legacy/files/vboxheadless.in | 125 | ||||
-rw-r--r-- | emulators/virtualbox-ose-legacy/files/vboxwebsrv.in | 49 |
3 files changed, 188 insertions, 5 deletions
diff --git a/emulators/virtualbox-ose-legacy/Makefile b/emulators/virtualbox-ose-legacy/Makefile index d0cb42456601..ff85060cb4d5 100644 --- a/emulators/virtualbox-ose-legacy/Makefile +++ b/emulators/virtualbox-ose-legacy/Makefile @@ -1,4 +1,4 @@ -# New ports collection makefile for: virtualbox-ose +# New ports collection makefile for: virtualbox-ose-legacy # Date created: 2009-05-02 # Whom: Bernhard Froehlich <decke@bluelife.at> # @@ -7,13 +7,13 @@ PORTNAME= virtualbox-ose DISTVERSION= 3.2.12 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= emulators MASTER_SITES= http://tmp.chruetertee.ch/ \ http://freebsd.unixfreunde.de/sources/ \ http://disasterarea.chruetertee.ch/ \ - http://mirror.4bit.ws/ \ http://dlc.sun.com/virtualbox/${VBOX_GUEST_VER}/:guestadditions +PKGNAMESUFFIX= -legacy DISTFILES= VirtualBox-${DISTVERSION}-OSE${EXTRACT_SUFX} ${GADISTFILES} EXTRACT_ONLY= VirtualBox-${DISTVERSION}-OSE${EXTRACT_SUFX} @@ -28,7 +28,7 @@ BUILD_DEPENDS= yasm:${PORTSDIR}/devel/yasm \ LIB_DEPENDS= png.6:${PORTSDIR}/graphics/png \ xslt.2:${PORTSDIR}/textproc/libxslt \ curl.6:${PORTSDIR}/ftp/curl -RUN_DEPENDS= /boot/modules/vboxdrv.ko:${PORTSDIR}/emulators/virtualbox-ose-kmod +RUN_DEPENDS= /boot/modules/vboxdrv.ko:${PORTSDIR}/emulators/virtualbox-ose-kmod-legacy LICENSE= GPLv2 LICENSE_FILE= ${WRKSRC}/COPYING @@ -47,9 +47,13 @@ HAS_CONFIGURE= yes CONFIGURE_ARGS+=--with-gcc="${CC}" --with-g++="${CXX}" --passive-mesa USE_LDCONFIG= ${PREFIX}/lib/virtualbox -CONFLICTS= bcc-[0-9]* virtualbox-ose-devel-3* virtualbox-ose-additions-3* virtualbox-ose-additions-devel-3* +CONFLICTS= bcc-[0-9]* +CONFLICTS_INSTALL= virtualbox-ose-[3,4]* virtualbox-ose-devel-[3,4]* virtualbox-ose-additions-[3,4]* virtualbox-ose-additions-devel-[3,4]* +VBOXUSER?= vboxusers +VBOXWSUSER?= vboxusers VBOXGROUP?= vboxusers +USERS= ${VBOXUSER} GROUPS= ${VBOXGROUP} VBOX_FRONTENDS= VBoxHeadless VBOX_GUEST_VER= ${PORTVERSION} @@ -71,6 +75,9 @@ PLIST_SUB+= PYTHON_VER=${PYTHON_VER} \ PYTHON_VERU=${PYTHON_VER:S/./_/} \ GUEST_VER=${VBOX_GUEST_VER} +SUB_LIST+= VBOXUSER=${VBOXUSER} +USE_RC_SUBR+= vboxheadless + KMK_BUILDTYPE= release KMK_CONFIG= VBOX_LIBPATH_X11=${LOCALBASE} VBOX_FREEBSD_SRC=${SRC_BASE}/sys KMK_FLAGS= @@ -151,6 +158,8 @@ CONFIGURE_ARGS+=--enable-vde .if defined(WITH_WEBSERVICE) BUILD_DEPENDS+= soapcpp2:${PORTSDIR}/devel/gsoap VBOX_WEB= vboxwebsrv webtest +USE_RC_SUBR+= vboxwebsrv +SUB_LIST+= VBOXWSUSER=${VBOXWSUSER} PLIST_SUB+= WEB="" .else PLIST_SUB+= WEB="@comment " diff --git a/emulators/virtualbox-ose-legacy/files/vboxheadless.in b/emulators/virtualbox-ose-legacy/files/vboxheadless.in new file mode 100644 index 000000000000..f0a04a6b1aa1 --- /dev/null +++ b/emulators/virtualbox-ose-legacy/files/vboxheadless.in @@ -0,0 +1,125 @@ +#!/bin/sh + +# $FreeBSD$ +# +# PROVIDE: vboxheadless +# REQUIRE: LOGIN vboxnet +# KEYWORD: shutdown +# +# Add the following line to /etc/rc.conf[.local] to enable vboxheadless +# +# vboxheadless_enable (bool): Set to "NO" by default. +# Set it to "YES" to enable vboxheadless. +# vboxheadless_machines (str): Space separated list of machines +# vboxheadless_user (str): Default user account to run with. +# (default: %%VBOXUSER%%) +# vboxheadless_<machine>_name (str): Virtualbox machine name or UUID. +# vboxheadless_<machine>_user (str): User account to run with. +# vboxheadless_<machine>_flags (str): Additional flags for VBoxHeadless. + +. /etc/rc.subr + +name="vboxheadless" +rcvar=`set_rcvar` + +command="%%PREFIX%%/bin/VBoxHeadless" +pidbase="/var/run/${name}" + +start_cmd="${name}_start" +stop_cmd="${name}_stop" +status_cmd="${name}_status" + +vboxheadless_start() +{ + local machine mpidfile pid vmname vmuser vmflags + + echo "Starting Virtual Machines:" + for machine in ${vboxheadless_machines}; do + mpidfile="${pidbase}_${machine}.pid" + pid=$(check_pidfile $mpidfile $command) + eval vmname="\${vboxheadless_${machine}_name:-${machine}}" + eval vmuser="\${vboxheadless_${machine}_user:-${vboxheadless_user}}" + eval vmflags="\${vboxheadless_${machine}_flags:-}" + + HOME=$(/usr/sbin/pw usershow -7 -n "${vmuser}" | /usr/bin/cut -d: -f6) + + /usr/bin/printf "%25s " "${vmname}" + + /usr/bin/su ${vmuser} -c "%%PREFIX%%/bin/VBoxManage showvminfo '${vmname}' >/dev/null" 2>/dev/null + + if [ $? != 0 ]; then + echo "Unknown machine" + continue + fi + + if [ -n "${pid}" ]; then + echo "Already running? (pid=${pid})" + continue + fi + + /usr/bin/install -o ${vmuser} -g wheel -m 644 /dev/null ${mpidfile} + /usr/sbin/daemon -f -p ${mpidfile} -u ${vmuser} ${command} --startvm "${vmname}" ${vmflags} + echo "Started" + done +} + +vboxheadless_stop() +{ + local machine mpidfile pid vmname vmuser + + echo "Saving states for Virtual Machines:" + for machine in ${vboxheadless_machines}; do + mpidfile="${pidbase}_${machine}.pid" + pid=$(check_pidfile $mpidfile $command) + eval vmname="\${vboxheadless_${machine}_name:-${machine}}" + eval vmuser="\${vboxheadless_${machine}_user:-${vboxheadless_user}}" + + /usr/bin/printf "%25s " "${vmname}" + + if [ -n "${pid}" ]; then + /usr/bin/su ${vmuser} -c "%%PREFIX%%/bin/VBoxManage controlvm '${vmname}' savestate >/dev/null" 2>/dev/null + wait_for_pids $pid >/dev/null + echo "Stopped" + else + echo "Not running?" + fi + done +} + +vboxheadless_status() +{ + local machine mpidfile pid vmname vmuser + + /usr/bin/printf "%25s %s\n" "Machine" "Status" + /usr/bin/printf "%25s %s\n" "-------------------------" "------------" + + for machine in ${vboxheadless_machines}; do + mpidfile="${pidbase}_${machine}.pid" + pid=$(check_pidfile $mpidfile $command) + eval vmname="\${vboxheadless_${machine}_name:-${machine}}" + eval vmuser="\${vboxheadless_${machine}_user:-${vboxheadless_user}}" + + /usr/bin/su ${vmuser} -c "/usr/local/bin/VBoxManage showvminfo '${vmname}' >/dev/null" 2>/dev/null + + if [ $? != 0 ]; then + /usr/bin/printf "%20s %s\n" "${vmname}" "Unknown Machine" + elif [ -n "${pid}" ]; then + /usr/bin/printf "%25s %s\n" "${vmname}" "Running" + else + /usr/bin/printf "%25s %s\n" "${vmname}" "Powered Off" + fi + done +} + +load_rc_config $name + +: ${vboxheadless_enable="NO"} +: ${vboxheadless_user="%%VBOXUSER%%"} + +cmd_arg="$1" ; shift + +if [ -n "$*" ]; then + vboxheadless_machines="$*" +fi + +run_rc_command "${cmd_arg}" diff --git a/emulators/virtualbox-ose-legacy/files/vboxwebsrv.in b/emulators/virtualbox-ose-legacy/files/vboxwebsrv.in new file mode 100644 index 000000000000..2905effbb3a8 --- /dev/null +++ b/emulators/virtualbox-ose-legacy/files/vboxwebsrv.in @@ -0,0 +1,49 @@ +#!/bin/sh + +# $FreeBSD$ +# +# PROVIDE: vboxwebsrv +# REQUIRE: LOGIN +# KEYWORD: shutdown +# +# Add the following line to /etc/rc.conf[.local] to enable vboxwebsrv +# +# vboxwebsrv_enable (bool): Set to "NO" by default. +# Set it to "YES" to enable vboxwebsrv. +# vboxwebsrv_user (str): User account to run with. +# vboxwebsrv_flags (str): Custom flags for vboxwebsrv. + +. /etc/rc.subr + +name=vboxwebsrv +rcvar=`set_rcvar` + +command="%%PREFIX%%/bin/vboxwebsrv" +pidfile="/var/run/${name}.pid" + +start_cmd="${name}_start" + +vboxwebsrv_start() +{ + local pid + + HOME=$(/usr/sbin/pw usershow -7 -n "${vboxwebsrv_user}" | /usr/bin/cut -d: -f6) + pid=$(check_pidfile $pidfile $command) + + if [ -n "${pid}" ]; then + echo "${name} already running? (pid=${pid})." + return 1 + fi + + echo -n "Starting ${name}" + /usr/bin/install -o ${vboxwebsrv_user} -g wheel -m 644 /dev/null ${pidfile} + /usr/sbin/daemon -f -p ${pidfile} -u ${vboxwebsrv_user} ${command} ${vboxwebsrv_flags} + echo '.' +} + +load_rc_config $name + +: ${vboxwebsrv_enable="NO"} +: ${vboxwebsrv_user="%%VBOXWSUSER%%"} + +run_rc_command "$1" |