]> git.pld-linux.org Git - packages/VirtualBox.git/commitdiff
add initscript for vboxservice
authorElan Ruusamäe <glen@delfi.ee>
Fri, 31 May 2013 18:59:55 +0000 (21:59 +0300)
committerElan Ruusamäe <glen@delfi.ee>
Fri, 31 May 2013 19:02:07 +0000 (22:02 +0300)
VirtualBox.spec
vboxservice.init [new file with mode: 0755]

index 48456920eef52dac8163cc418478fe13aafb77c2..3aacd98e64e16e2a3b2d4f6fd3492750354a1e48 100644 (file)
@@ -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 (executable)
index 0000000..79ebd25
--- /dev/null
@@ -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
This page took 0.042944 seconds and 4 git commands to generate.