[packages/VirtualBox] autostart initscript
glen
glen at pld-linux.org
Sun Mar 2 22:37:14 CET 2014
commit c920e7dbcee156bc6732e87c2d4c29a1157aa8ed
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Sun Mar 2 23:12:47 2014 +0200
autostart initscript
based on src/VBox/Installer/linux/vboxautostart-service.sh
vboxautostart.init | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 108 insertions(+)
---
diff --git a/vboxautostart.init b/vboxautostart.init
new file mode 100755
index 0000000..fb1142f
--- /dev/null
+++ b/vboxautostart.init
@@ -0,0 +1,108 @@
+#!/bin/sh
+#
+# VirtualBox autostart service init script.
+#
+# chkconfig: 35 35 65
+# description: VirtualBox autostart service
+# processname: VBoxAutostart
+# config: /etc/vbox/autostart.cfg
+#
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/virtualbox ] && . /etc/sysconfig/virtualbox
+
+start_daemon() {
+ local user="$1"
+ shift
+ daemon --user $user "$@"
+}
+
+start() {
+ # Check if the service is already running?
+ if [ -f /var/lock/subsys/vboxautostart ]; then
+ msg_already_running "VirtualBox Autostart"
+ return
+ fi
+
+ [ -z "$VBOXAUTOSTART_DB" ] && exit 0
+ [ -z "$VBOXAUTOSTART_CONFIG" ] && exit 0
+
+ msg_starting "Starting VirtualBox VMs configured for autostart"
+
+ local user PARAMS="--background --start --config $VBOXAUTOSTART_CONFIG"
+
+ # prevent inheriting this setting to VBoxSVC
+ unset VBOX_RELEASE_LOG_DEST
+
+ for user in `ls $VBOXAUTOSTART_DB/*.start 2>/dev/null`; do
+ user=$(basename $user | sed -ne "s/\(.*\).start/\1/p")
+ start_daemon $user $binary $PARAMS
+ done
+
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/vboxautostart
+}
+
+stop() {
+ if [ ! -f /var/lock/subsys/vboxautostart ]; then
+ msg_not_running "VirtualBox Autostart"
+ return
+ fi
+
+ [ -z "$VBOXAUTOSTART_DB" ] && exit 0
+ [ -z "$VBOXAUTOSTART_CONFIG" ] && exit 0
+
+ # Stop daemons.
+ msg_stopping "VirtualBox Autostart"
+
+ local user PARAMS="--stop --config $VBOXAUTOSTART_CONFIG"
+
+ # prevent inheriting this setting to VBoxSVC
+ unset VBOX_RELEASE_LOG_DEST
+
+ for user in `ls $VBOXAUTOSTART_DB/*.stop 2>/dev/null`; do
+ user=$(basename $user | sed -ne "s/\(.*\).stop/\1/p")
+ start_daemon $user $binary $PARAMS
+ done
+
+ rm -f /var/lock/subsys/vboxautostart
+}
+
+condrestart() {
+ if [ ! -f /var/lock/subsys/vboxautostart ]; then
+ msg_not_running "VirtualBox Autostart"
+ 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
+ ;;
+ *)
+ msg_usage "$0 {start|stop|restart|try-restart|force-reload}"
+ exit 3
+esac
+
+exit $RETVAL
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/VirtualBox.git/commitdiff/38d06cb917f0cc76d823b55f3b3a4a424f8130cd
More information about the pld-cvs-commit
mailing list