Prepared VirtualBox for systemd

This commit is contained in:
Michael 2012-09-15 18:18:07 +00:00
parent 570d68bb2b
commit 5343687c47
6 changed files with 75 additions and 253 deletions

View File

@ -5,9 +5,9 @@
# Contributor: Sebastien Luttringer <seblu[plus]arch[at]seblu[dot]net>
pkgname=virtualbox
pkgver=4.1.22
_build=80657
pkgrel=1
pkgver=4.2.0
_build=80737
pkgrel=4
pkgdesc='Oracle VM VirtualBox Binary Edition'
arch=('i686' 'x86_64')
url='http://virtualbox.org/'
@ -28,7 +28,7 @@ provides=("virtualbox=${pkgver}")
conflicts=('virtualbox' 'virtualbox-ose' 'virtualbox-modules')
categories=('system')
backup=('etc/vbox/vbox.cfg' 'etc/conf.d/vboxdrv' 'etc/conf.d/vboxweb')
install='install'
install="${pkgname}.install"
screenshot='https://www.virtualbox.org/raw-attachment/wiki/Screenshots/gnome.png'
_sarch='x86'
@ -37,24 +37,19 @@ _sarch='x86'
source=(
"VirtualBox-${pkgver}-${_build}-Linux_${_sarch}.run::http://download.virtualbox.org/virtualbox/${pkgver}/VirtualBox-${pkgver}-${_build}-Linux_${_sarch}.run"
'10-vboxdrv.rules'
'vboxdrv.rc'
'vboxsetup.sh'
'vboxdrv.conf'
'vboxweb.rc'
'vboxweb.conf'
'vboxdrv.service'
'vboxweb.service'
)
sha256sums=('d53a5cc2d1b9431d4f9443462b84549678e943be1d8b4a714d7844c741507c76'
sha256sums=('04030998f15b656e9b76064cde3e6cb43c5a41b1e25e700f123f5a629578fe5e'
'69417a9e8855cab8e4878886abe138f559fd17ae487d4cd19c8a24974a8bbec2'
'578b63ab173cdcd9169d8aff00caf48668e46a6886bb90fd34a0fbe63e180a4e'
'9f70a97db16c85d347297a9fd5a416931990591686f0b3279bc9c32aab800688'
'71740893a5f226f9d9fcc607ab9d39b7de816b2759625b34da19162bc7e579ff'
'656905de981ffa24f6f921c920538854a235225053f44baedacc07b46ca0cf56'
'12dbba3b59991f2b68cddeeeda20236aeff63e11b7e2d1b08d9d6a82225f6651'
'b8d4d82c90f81af67f7449d880430bda4d1d73c571851f40c339faee809d7239'
'e6e875ef186578b53106d7f6af48e426cdaf1b4e86834f01696b8ef1c685787f')
[[ "${CARCH}" = i686 ]] && sha256sums[0]='e084db553064fb85136df22d13f262fef602daca56b95799cef7df761310a8d5'
[[ "${CARCH}" = i686 ]] && sha256sums[0]='d859981312c2b6ed9e596375fc180378763b09e5a3cf0d6dd61bc252789006c4'
_installdir='/opt/VirtualBox'
package() {
@ -93,18 +88,20 @@ package() {
sed -i -e 's,sudo /etc/init.d/vboxdrv restart,/etc/rc.d/vboxdrv restart,g' \
"${pkgdir}/${_installdir}/VBox.sh"
# Install vboxdrv initscript
install -D -m 0755 "${srcdir}/vboxdrv.rc" "${pkgdir}/etc/rc.d/vboxdrv"
# Install vboxdrv configuration
install -D -m 0644 "${srcdir}/vboxdrv.conf" "${pkgdir}/etc/conf.d/vboxdrv"
# Install vboxweb initscript
install -D -m 0755 "${srcdir}/vboxweb.rc" "${pkgdir}/etc/rc.d/vboxweb"
install -D -m 0644 "${srcdir}/vboxweb.conf" "${pkgdir}/etc/conf.d/vboxweb"
install -D -m 0755 "${srcdir}/vboxweb.service" "${pkgdir}/usr/lib/systemd/system/vboxweb.service"
# Install udev rules
install -D -m 0644 "${srcdir}/10-vboxdrv.rules" "${pkgdir}/lib/udev/rules.d/10-vboxdrv.rules"
ln -s "${_installdir}/VBoxCreateUSBNode.sh" "${pkgdir}/lib/udev/VBoxCreateUSBNode.sh"
# Install setup script for modules and usb devices
install -D -m 0755 "${srcdir}/vboxsetup.sh" "${pkgdir}/usr/bin/vboxsetup"
# Install the SDK
cd "${pkgdir}/${_installdir}/sdk/installer"
VBOX_INSTALL_PATH="${_installdir}" python2 vboxapisetup.py install --root "${pkgdir}"
@ -162,8 +159,4 @@ package() {
# Create the directory below if it doesn't exist
install -d -m 0755 "${pkgdir}/var/run/VirtualBox"
# Install systemd services
install -D -m644 "$srcdir/vboxweb.service" "$pkgdir/usr/lib/systemd/system/vboxweb.service"
install -D -m644 "$srcdir/vboxdrv.service" "$pkgdir/usr/lib/systemd/system/vboxdrv.service"
}

View File

@ -1,80 +0,0 @@
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
. /etc/vbox/vbox.cfg
MODLIST=()
LOG="/var/log/vbox-install.log"
if [ -n "$INSTALL_DIR" ]; then
VBOXMANAGE="$INSTALL_DIR/VBoxManage"
BUILDVBOXDRV="$INSTALL_DIR/src/vboxhost/vboxdrv/build_in_tmp"
BUILDVBOXNETFLT="$INSTALL_DIR/src/vboxhost/vboxnetflt/build_in_tmp"
BUILDVBOXNETADP="$INSTALL_DIR/src/vboxhost/vboxnetadp/build_in_tmp"
else
echo "missing vbox.cfg"
exit 0
fi
case "$1" in
setup)
stat_busy "Unloading VirtualBox kernel modules"
for module in vbox{netflt,netadp,drv}; do
if grep -q "^${module}" /proc/modules; then
MODLIST+=($module)
modprobe -r $module
fi
done
stat_done
for p in /lib/modules/*; do
if [ ! -d "$p/kernel" ]; then
if [ -e "$p/misc/vboxdrv.ko" ]; then
stat_busy "Removing old VirtualBox kernel modules from $p"
rm -f "$p/misc/vbox"{drv,netadp,netflt}.ko 2>/dev/null
rmdir -p --ignore-fail-on-non-empty "$p/misc/" 2>/dev/null
stat_done
fi
fi
done
if find /lib/modules/`uname -r` -name "vboxnetadp\.*" 2>/dev/null|grep -q vboxnetadp; then
stat_busy "Removing old VirtualBox netadp kernel module"
find /lib/modules/`uname -r` -name "vboxnetadp\.*" 2>/dev/null|xargs rm -f 2>/dev/null
stat_done
fi
if find /lib/modules/`uname -r` -name "vboxnetflt\.*" 2>/dev/null|grep -q vboxnetflt; then
stat_busy "Removing old VirtualBox netflt kernel module"
find /lib/modules/`uname -r` -name "vboxnetflt\.*" 2>/dev/null|xargs rm -f 2>/dev/null
stat_done
fi
if find /lib/modules/`uname -r` -name "vboxdrv\.*" 2>/dev/null|grep -q vboxdrv; then
stat_busy "Removing old VirtualBox kernel module"
find /lib/modules/`uname -r` -name "vboxdrv\.*" 2>/dev/null|xargs rm -f 2>/dev/null
stat_done
fi
stat_busy "Recompiling VirtualBox kernel modules"
if ! $BUILDVBOXDRV \
--save-module-symvers /tmp/vboxdrv-Module.symvers \
--no-print-directory install > $LOG 2>&1; then
echo "Look at $LOG to find out what went wrong"
fi
if ! $BUILDVBOXNETFLT \
--use-module-symvers /tmp/vboxdrv-Module.symvers \
--no-print-directory install >> $LOG 2>&1; then
echo "Look at $LOG to find out what went wrong"
fi
if ! $BUILDVBOXNETADP \
--use-module-symvers /tmp/vboxdrv-Module.symvers \
--no-print-directory install >> $LOG 2>&1; then
echo "Look at $LOG to find out what went wrong"
fi
stat_done
stat_busy "Reloading VirtualBox kernel modules"
for module in "${MODLIST[@]}"; do
modprobe $module
done
stat_done
;;
*)
echo "usage: $0 {setup}"
esac

View File

@ -1,9 +0,0 @@
[Unit]
Description=VirtualBox Guest Service
ConditionVirtualization=oracle
[Service]
ExecStart=/usr/bin/VBoxService -f
[Install]
WantedBy=multi-user.target

View File

@ -1,19 +1,21 @@
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
. /etc/vbox/vbox.cfg
. /etc/conf.d/vboxdrv
if [ "$EUID" -ne "0" ]; then
echo "Please run this script with root privileges"
exit 0
fi
if [[ -n "$INSTALL_DIR" ]]; then
VBOXMANAGE="$INSTALL_DIR/VBoxManage"
BUILDVBOXDRV="$INSTALL_DIR/src/vboxhost/vboxdrv/build_in_tmp"
BUILDVBOXNETFLT="$INSTALL_DIR/src/vboxhost/vboxnetflt/build_in_tmp"
BUILDVBOXNETADP="$INSTALL_DIR/src/vboxhost/vboxnetadp/build_in_tmp"
MODULE_SRC="$INSTALL_DIR/src/vboxhost"
else
echo "Missing /etc/vbox/vbox.cfg"
exit 0
fi
BUILDINTMP="$MODULE_SRC/build_in_tmp"
DODKMS="$MODULE_SRC/do_dkms"
# detection of dkms (if not disabled)
if [[ "$DISABLE_DKMS" =~ [yY][eE][sS] ]]; then
@ -30,81 +32,90 @@ fi
load() {
if [[ "$START_BUILD" =~ [yY][eE][sS] ]]; then
# check if module exists
c=$('find' "/lib/modules/$(uname -r)" -type f -regex '.*/vbox\(drv\|netadp\|netflt\).ko' | wc -l)
c=$('find' "/lib/modules/$(uname -r)" -type f -regex '.*/vbox\(drv\|netadp\|netflt\|pci\).ko' | wc -l)
((c == 0 )) && setup
fi
stat_busy "Loading VirtualBox kernel modules"
echo "Loading VirtualBox kernel modules"
# trivial loading
for module in vbox{drv,netadp,netflt}; do
for module in vbox{drv,netadp,netflt,pci}; do
modprobe $module &>/dev/null
done
# check
for module in vbox{drv,netadp,netflt}; do
for module in vbox{drv,netadp,netflt,pci}; do
if ! grep -q "^${module}" /proc/modules; then
stat_fail
echo "Module ${module} could not be loaded"
return 1
fi
done
add_daemon vboxdrv
stat_done
}
unload() {
stat_busy "Unloading VirtualBox kernel modules"
echo "Unloading VirtualBox kernel modules"
# trivial unload
for module in vbox{netflt,netadp,drv}; do
for module in vbox{pci,netflt,netadp,drv}; do
if grep -q "^${module}" /proc/modules; then
modprobe -r $module &>/dev/null
fi
done
# check
for module in vbox{drv,netadp,netflt}; do
for module in vbox{pci,drv,netadp,netflt}; do
if grep -q "^${module}" /proc/modules; then
stat_fail
echo "Module ${module} could not be unloaded"
return 1
fi
done
rm_daemon vboxdrv
stat_done
}
remove() {
unload
if (( USE_DKMS == 1 )); then
status "Removing VirtualBox kernel modules with DKMS" dkms remove -m vboxhost -v "$INSTALL_VER" --all
echo "Removing VirtualBox kernel modules with DKMS"
$DODKMS uninstall vboxhost vboxdrv vboxnetflt vboxnetadp > $LOG
else
stat_busy "Removing VirtualBox kernel modules"
find "/lib/modules/$(uname -r)" -type f -regex '.*/vbox\(drv\|netadp\|netflt\).ko' -delete
stat_done
echo "Removing VirtualBox kernel modules"
find "/lib/modules/$(uname -r)" -type f -regex '.*/vbox\(pci\|drv\|netadp\|netflt\).ko' -delete
fi
}
setup() {
if (( USE_DKMS == 1 )); then
status "Adding VirtualBox kernel modules in DKMS" dkms add -m vboxhost -v "$INSTALL_VER"
status "Bulding VirtualBox kernel modules with DKMS" dkms build -m vboxhost -v "$INSTALL_VER"
status "Installing VirtualBox kernel modules with DKMS" dkms install -m vboxhost -v "$INSTALL_VER"
echo "Trying to register the VirtualBox kernel modules using DKMS"
$DODKMS install vboxhost "$INSTALL_VER" >> $LOG
else
remove
stat_busy "Compiling VirtualBox kernel modules"
echo "Compiling VirtualBox kernel modules"
LOG="/tmp/vbox-install.log"
if ! $BUILDVBOXDRV \
if ! $BUILDINTMP \
--save-module-symvers /tmp/vboxdrv-Module.symvers \
--module-source "$MODULE_SRC/vboxdrv" \
--no-print-directory install > $LOG 2>&1; then
echo "Look at $LOG to find out what went wrong"
return 1
fi
if ! $BUILDVBOXNETFLT \
if ! $BUILDINTMP \
--use-module-symvers /tmp/vboxdrv-Module.symvers \
--module-source "$MODULE_SRC/vboxnetflt" \
--no-print-directory install >> $LOG 2>&1; then
echo "Look at $LOG to find out what went wrong"
return 1
fi
if ! $BUILDVBOXNETADP \
if ! $BUILDINTMP \
--use-module-symvers /tmp/vboxdrv-Module.symvers \
--module-source "$MODULE_SRC/vboxnetadp" \
--no-print-directory install >> $LOG 2>&1; then
echo "Look at $LOG to find out what went wrong"
return 1
fi
if ! $BUILDINTMP \
--use-module-symvers /tmp/vboxdrv-Module.symvers \
--module-source "$MODULE_SRC/vboxpci" \
--no-print-directory install >> $LOG 2>&1; then
echo "Look at $LOG to find out what went wrong"
return 1
fi
depmod -A
stat_done
fi
fi
echo -e "\n==> Make sure to load the required modules to use VirtualBox"
}
fixusb() {
@ -121,27 +132,15 @@ fixusb() {
}
case "$1" in
start)
load
;;
stop)
unload
;;
restart)
unload
load
;;
setup)
setup
;;
remove)
remove
;;
fixusb)
fixusb
;;
remove)
remove
;;
*)
echo "usage: $0 {start|stop|restart|setup|remove|fixusb}"
echo "usage: $0 {setup|fixusb}"
esac
# vim:set ts=2 sw=2 ft=sh et:

View File

@ -1,86 +0,0 @@
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
. /etc/vbox/vbox.cfg
. /etc/conf.d/vboxweb
BINARY="$INSTALL_DIR/vboxwebsrv"
start() {
stat_busy "Starting VirtualBox Web Service";
if ! pidof -o %PPID $BINARY >/dev/null; then
[[ "$VBOXWEB_USER" ]] || stat_die
lsmod | grep -q "vboxdrv[^_-]" || stat_die
PARAMS="--background"
[[ "$VBOXWEB_HOST" ]] && PARAMS+=" -H $VBOXWEB_HOST"
[[ "$VBOXWEB_PORT" ]] && PARAMS+=" -p $VBOXWEB_PORT"
[[ "$VBOXWEB_TIMEOUT" ]] && PARAMS+=" -t $VBOXWEB_TIMEOUT"
[[ "$VBOXWEB_CHECK_INTERVAL" ]] && PARAMS+=" -i $VBOXWEB_CHECK_INTERVAL"
[[ "$VBOXWEB_THREADS" ]] && PARAMS+=" -T $VBOXWEB_THREADS"
[[ "$VBOXWEB_KEEPALIVE" ]] && PARAMS+=" -k $VBOXWEB_KEEPALIVE"
[[ "$VBOXWEB_LOGFILE" ]] && PARAMS+=" -F $VBOXWEB_LOGFILE"
# prevent inheriting this setting to VBoxSVC
unset VBOX_RELEASE_LOG_DEST
su - $VBOXWEB_USER -c "$BINARY $PARAMS" &>/dev/null
# ugly: wait until the final process has forked
sleep .2
if pidof -o %PPID $BINARY >/dev/null; then
add_daemon vboxweb
stat_done
else
stat_die
fi
else
stat_die
fi
}
stop() {
stat_busy "Stopping VirtualBox Web Service"
PID=$(pidof -o %PPID $BINARY)
[[ $PID ]] && kill $PID &>/dev/null
if ! pidof -o %PPID $BINARY >/dev/null; then
rm_daemon vboxweb
stat_done
else
stat_die
fi
}
restart() {
stop && start
}
status() {
stat_busy "Checking for VirtualBox Web Service"
if pidof -o %PPID $BINARY >/dev/null; then
stat_done
else
stat_fail
false
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
force-reload)
restart
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
# vim:set ts=2 sw=2 ft=sh et:

View File

@ -12,7 +12,7 @@ post_install() {
[[ -x =update-desktop-database ]] && update-desktop-database -q &>/dev/null
# Build new module
/etc/rc.d/vboxdrv setup
/usr/bin/vboxsetup setup
# Show warnings
/bin/cat <<EOF
@ -20,10 +20,10 @@ post_install() {
==> Remember to add allowed users to the vboxusers group:
==> # gpasswd -a USERNAME vboxusers
==>
==> To load virtualbox modules automatically you can add vboxdrv in your DAEMONS
==> To start virtualbox web service automatically you can add vboxweb in your DAEMONS
==> To load virtualbox modules automatically you can add vboxdrv to a file /etc/modules-load.d/vbox.conf
==> To start virtualbox web service automatically you can add vboxweb to this file, too
==>
==> To fix missing usb devices, you can call rc.d fixusb vboxdrv or reboot your computer
==> To fix missing usb devices, you can call 'vboxsetup fixusb' or reboot your computer
EOF
}
@ -40,11 +40,18 @@ post_upgrade() {
pre_remove() {
# Stop running services
[[ -x /etc/rc.d/vboxdrv ]] && /etc/rc.d/vboxdrv stop
[[ -x /etc/rc.d/vboxweb ]] && /etc/rc.d/vboxweb stop
_service="vboxweb.service"
systemctl is-active ${_service} &>/dev/null
if [[ $? -eq 0 ]] ; then
systemctl stop ${_service}
fi
systemctl is-enabled ${_service} &>/dev/null
if [[ $? -eq 0 ]] ; then
systemctl disable ${_service}
fi
# Remove modules
[[ -x /etc/rc.d/vboxdrv ]] && /etc/rc.d/vboxdrv remove
/usr/bin/vboxsetup remove
}
post_remove() {
@ -63,5 +70,3 @@ post_remove() {
# remove vboxusers group
groupdel vboxusers &>/dev/null || true
}
# vim:set ts=2 sw=2 ft=sh et: