# Source0-md5: 654e45054ae6589452508d37403dc800
Source1: http://download.virtualbox.org/virtualbox/%{version}/VBoxGuestAdditions_%{version}.iso
# Source1-md5: 403098e688f9e7f4273de680f6734983
+Source2: vboxservice.init
Source3: %{pname}-vboxdrv.init
Source4: %{pname}-vboxguest.init
Source5: %{pname}-vboxnetflt.init
%if %{with kernel}
install -d $RPM_BUILD_ROOT{/etc/{rc.d/init.d,modules-load.d},%{_sbindir},%{systemdunitdir}}
+install -p %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/vboxservice
install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/vboxdrv
install -p %{SOURCE4} $RPM_BUILD_ROOT/etc/rc.d/init.d/vboxguest
install -p %{SOURCE5} $RPM_BUILD_ROOT/etc/rc.d/init.d/vboxnetflt
%groupremove vbox
fi
+%post guest
+/sbin/chkconfig --add vboxdrv
+
+%postun guest
+if [ "$1" = "0" ]; then
+ /sbin/chkconfig --del vboxdrv
+fi
+
%post -n kernel%{_alt_kernel}-misc-vboxdrv
%depmod %{_kernel_ver}
%vbox_kernel_post -d vboxdrv VirtualBox Support Driver
%files guest
%defattr(644,root,root,755)
-# TODO: initscript for VBoxService
+%attr(754,root,root) /etc/rc.d/init.d/vboxservice
%attr(755,root,root) %{_bindir}/VBoxControl
%attr(755,root,root) %{_bindir}/VBoxService
--- /dev/null
+#!/bin/sh
+#
+# vboxservice VirtualBox guest services
+# chkconfig: 345 85 15
+# description: VirtualBox guest services
+# processname: VBoxService
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get network config
+. /etc/sysconfig/network
+
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+ if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+ msg_network_down "VBox Service"
+ exit 1
+ fi
+else
+ exit 0
+fi
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/vboxservice ] && . /etc/sysconfig/vboxservice
+
+start() {
+ # Check if the service is already running?
+ if [ -f /var/lock/subsys/vboxservice ]; then
+ msg_already_running "VBox Service"
+ return
+ fi
+
+ msg_starting "VBox Service"
+ daemon /usr/bin/VBoxService
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/vboxservice
+}
+
+stop() {
+ if [ ! -f /var/lock/subsys/vboxservice ]; then
+ msg_not_running "VBox Service"
+ return
+ fi
+
+ # Stop daemons.
+ msg_stopping "VBox Service"
+ killproc VBoxService
+ rm -f /var/lock/subsys/vboxservice
+}
+
+condrestart() {
+ if [ ! -f /var/lock/subsys/vboxservice ]; then
+ msg_not_running "VBox Service"
+ RETVAL=$1
+ return
+ fi
+
+ stop
+ start
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ try-restart)
+ condrestart 0
+ ;;
+ force-reload)
+ condrestart 7
+ ;;
+ status)
+ status vboxservice VBoxService
+ RETVAL=$?
+ ;;
+ *)
+ msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+ exit 3
+esac
+
+exit $RETVAL