[packages/VirtualBox] add initscript for vboxservice

glen glen at pld-linux.org
Fri May 31 21:03:16 CEST 2013


commit 07e9b84d831cd40bbb620f0bf790ea5e4f0d4dcd
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Fri May 31 21:59:55 2013 +0300

    add initscript for vboxservice

 VirtualBox.spec  | 12 +++++++-
 vboxservice.init | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 102 insertions(+), 1 deletion(-)
---
diff --git a/VirtualBox.spec b/VirtualBox.spec
index 4845692..3aacd98 100644
--- a/VirtualBox.spec
+++ b/VirtualBox.spec
@@ -45,6 +45,7 @@ Source0:	http://download.virtualbox.org/virtualbox/%{version}/%{pname}-%{version
 # 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
@@ -678,6 +679,7 @@ cp -p src/VBox/Additions/x11/Installer/vboxclient.desktop \
 
 %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
@@ -750,6 +752,14 @@ if [ "$1" = "0" ]; then
 	%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
@@ -990,7 +1000,7 @@ fi
 
 %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
 
diff --git a/vboxservice.init b/vboxservice.init
new file mode 100755
index 0000000..79ebd25
--- /dev/null
+++ b/vboxservice.init
@@ -0,0 +1,91 @@
+#!/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
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/VirtualBox.git/commitdiff/07e9b84d831cd40bbb620f0bf790ea5e4f0d4dcd



More information about the pld-cvs-commit mailing list