mirror of
https://gitdl.cn/https://github.com/chakralinux/desktop.git
synced 2025-02-03 13:07:14 +08:00
virtualbox: add missing files
This commit is contained in:
parent
0797ff42f9
commit
05a2537886
67
virtualbox/install
Normal file
67
virtualbox/install
Normal file
@ -0,0 +1,67 @@
|
||||
post_install() {
|
||||
# Add vboxusers group, GID 108 is reserved (http://wiki.archlinux.org/index.php/UID_and_GID_list),
|
||||
getent group vboxusers &> /dev/null || groupadd -f -g 108 vboxusers
|
||||
|
||||
# Load new udev rule for module vboxdrv
|
||||
udevadm control --reload-rules
|
||||
|
||||
# Update mime database
|
||||
[[ -x =update-mime-database ]] && update-mime-database /usr/share/mime &>/dev/null
|
||||
|
||||
# Update desktop database
|
||||
[[ -x =update-desktop-database ]] && update-desktop-database -q &>/dev/null
|
||||
|
||||
# Build new module
|
||||
/etc/rc.d/vboxdrv setup
|
||||
|
||||
# Show warnings
|
||||
/bin/cat <<EOF
|
||||
|
||||
==> 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 fix missing usb devices, you can call rc.d fixusb vboxdrv or reboot your computer
|
||||
EOF
|
||||
}
|
||||
|
||||
pre_upgrade() {
|
||||
pre_remove
|
||||
|
||||
# Remove any stuff remaining from the module compilation
|
||||
rm -Rf "/opt/VirtualBox"
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
# Remove modules
|
||||
[[ -x /etc/rc.d/vboxdrv ]] && /etc/rc.d/vboxdrv remove
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
# Remove any stuff remaining from the module compilation
|
||||
rm -Rf "/opt/VirtualBox"
|
||||
|
||||
# Remove any run files
|
||||
rm -Rf "/var/run/VirtualBox"
|
||||
|
||||
# Update mime database
|
||||
[[ -x =update-mime-database ]] && update-mime-database /usr/share/mime &>/dev/null
|
||||
|
||||
# Update desktop database
|
||||
[[ -x =update-desktop-database ]] && update-desktop-database -q &>/dev/null
|
||||
|
||||
# remove vboxusers group
|
||||
groupdel vboxusers &>/dev/null || true
|
||||
}
|
||||
|
||||
# vim:set ts=2 sw=2 ft=sh et:
|
7
virtualbox/vboxdrv.conf
Normal file
7
virtualbox/vboxdrv.conf
Normal file
@ -0,0 +1,7 @@
|
||||
# Try to build module if don't exist when calling start
|
||||
# This variable is automatically set to no when DKMS is in use
|
||||
START_BUILD=Yes
|
||||
|
||||
# Disable use of DKMS
|
||||
# Elsewhere script try to detect DKMS
|
||||
DISABLE_DKMS=No
|
147
virtualbox/vboxdrv.rc
Normal file
147
virtualbox/vboxdrv.rc
Normal file
@ -0,0 +1,147 @@
|
||||
#!/bin/bash
|
||||
|
||||
. /etc/rc.conf
|
||||
. /etc/rc.d/functions
|
||||
. /etc/vbox/vbox.cfg
|
||||
. /etc/conf.d/vboxdrv
|
||||
|
||||
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 /etc/vbox/vbox.cfg"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# detection of dkms (if not disabled)
|
||||
if [[ "$DISABLE_DKMS" =~ [yY][eE][sS] ]]; then
|
||||
USE_DKMS=0
|
||||
else
|
||||
which dkms &>/dev/null
|
||||
USE_DKMS=$((! $?))
|
||||
fi
|
||||
|
||||
# STARTBUILD cannot be used with dkms
|
||||
(( USE_DKMS == 1 )) && START_BUILD=no
|
||||
|
||||
|
||||
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 == 0 )) && setup
|
||||
fi
|
||||
stat_busy "Loading VirtualBox kernel modules"
|
||||
# trivial loading
|
||||
for module in vbox{drv,netadp,netflt}; do
|
||||
modprobe $module &>/dev/null
|
||||
done
|
||||
# check
|
||||
for module in vbox{drv,netadp,netflt}; do
|
||||
if ! grep -q "^${module}" /proc/modules; then
|
||||
stat_fail
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
add_daemon vboxdrv
|
||||
stat_done
|
||||
}
|
||||
|
||||
unload() {
|
||||
stat_busy "Unloading VirtualBox kernel modules"
|
||||
# trivial unload
|
||||
for module in vbox{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
|
||||
if grep -q "^${module}" /proc/modules; then
|
||||
stat_fail
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
rm_daemon vboxdrv
|
||||
stat_done
|
||||
}
|
||||
|
||||
remove() {
|
||||
if (( USE_DKMS == 1 )); then
|
||||
status "Removing VirtualBox kernel modules with DKMS" dkms remove -m vboxhost -v "$INSTALL_VER" --all
|
||||
else
|
||||
stat_busy "Removing VirtualBox kernel modules"
|
||||
find "/lib/modules/$(uname -r)" -type f -regex '.*/vbox\(drv\|netadp\|netflt\).ko' -delete
|
||||
stat_done
|
||||
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"
|
||||
else
|
||||
remove
|
||||
stat_busy "Compiling VirtualBox kernel modules"
|
||||
LOG="/tmp/vbox-install.log"
|
||||
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
|
||||
depmod -A
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
fixusb() {
|
||||
# Build our device tree
|
||||
for i in /sys/bus/usb/devices/*; do
|
||||
if test -r "$i/dev"; then
|
||||
dev="`cat "$i/dev" 2> /dev/null`"
|
||||
major="`expr "$dev" : '\(.*\):' 2> /dev/null`"
|
||||
minor="`expr "$dev" : '.*:\(.*\)' 2> /dev/null`"
|
||||
class="`cat $i/bDeviceClass 2> /dev/null`"
|
||||
sh "$INSTALL_DIR/VBoxCreateUSBNode.sh" "$major" "$minor" "$class" 2>/dev/null
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
load
|
||||
;;
|
||||
stop)
|
||||
unload
|
||||
;;
|
||||
restart)
|
||||
unload
|
||||
load
|
||||
;;
|
||||
setup)
|
||||
setup
|
||||
;;
|
||||
remove)
|
||||
remove
|
||||
;;
|
||||
fixusb)
|
||||
fixusb
|
||||
;;
|
||||
*)
|
||||
echo "usage: $0 {start|stop|restart|setup|remove|fixusb}"
|
||||
esac
|
||||
|
||||
# vim:set ts=2 sw=2 ft=sh et:
|
11
virtualbox/vboxweb.conf
Normal file
11
virtualbox/vboxweb.conf
Normal file
@ -0,0 +1,11 @@
|
||||
# WebService Mandatory Variables
|
||||
#VBOXWEB_USER=
|
||||
|
||||
# WebService Variables
|
||||
#VBOXWEB_LOGFILE=
|
||||
#$VBOXWEB_HOST=
|
||||
#$VBOXWEB_PORT=
|
||||
#$VBOXWEB_TIMEOUT=
|
||||
#$VBOXWEB_CHECK_INTERVAL=
|
||||
#$VBOXWEB_THREADS=
|
||||
#$VBOXWEB_KEEPALIVE=
|
86
virtualbox/vboxweb.rc
Normal file
86
virtualbox/vboxweb.rc
Normal file
@ -0,0 +1,86 @@
|
||||
#!/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:
|
Loading…
Reference in New Issue
Block a user