]> git.pld-linux.org Git - packages/VirtualBox.git/blame - vboxautostart.init
autostart initscript
[packages/VirtualBox.git] / vboxautostart.init
CommitLineData
c920e7db
ER
1#!/bin/sh
2#
3# VirtualBox autostart service init script.
4#
5# chkconfig: 35 35 65
6# description: VirtualBox autostart service
7# processname: VBoxAutostart
8# config: /etc/vbox/autostart.cfg
9#
10
11# Source function library
12. /etc/rc.d/init.d/functions
13
14# Get service config - may override defaults
15[ -f /etc/sysconfig/virtualbox ] && . /etc/sysconfig/virtualbox
16
17start_daemon() {
18 local user="$1"
19 shift
20 daemon --user $user "$@"
21}
22
23start() {
24 # Check if the service is already running?
25 if [ -f /var/lock/subsys/vboxautostart ]; then
26 msg_already_running "VirtualBox Autostart"
27 return
28 fi
29
30 [ -z "$VBOXAUTOSTART_DB" ] && exit 0
31 [ -z "$VBOXAUTOSTART_CONFIG" ] && exit 0
32
33 msg_starting "Starting VirtualBox VMs configured for autostart"
34
35 local user PARAMS="--background --start --config $VBOXAUTOSTART_CONFIG"
36
37 # prevent inheriting this setting to VBoxSVC
38 unset VBOX_RELEASE_LOG_DEST
39
40 for user in `ls $VBOXAUTOSTART_DB/*.start 2>/dev/null`; do
41 user=$(basename $user | sed -ne "s/\(.*\).start/\1/p")
42 start_daemon $user $binary $PARAMS
43 done
44
45 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/vboxautostart
46}
47
48stop() {
49 if [ ! -f /var/lock/subsys/vboxautostart ]; then
50 msg_not_running "VirtualBox Autostart"
51 return
52 fi
53
54 [ -z "$VBOXAUTOSTART_DB" ] && exit 0
55 [ -z "$VBOXAUTOSTART_CONFIG" ] && exit 0
56
57 # Stop daemons.
58 msg_stopping "VirtualBox Autostart"
59
60 local user PARAMS="--stop --config $VBOXAUTOSTART_CONFIG"
61
62 # prevent inheriting this setting to VBoxSVC
63 unset VBOX_RELEASE_LOG_DEST
64
65 for user in `ls $VBOXAUTOSTART_DB/*.stop 2>/dev/null`; do
66 user=$(basename $user | sed -ne "s/\(.*\).stop/\1/p")
67 start_daemon $user $binary $PARAMS
68 done
69
70 rm -f /var/lock/subsys/vboxautostart
71}
72
73condrestart() {
74 if [ ! -f /var/lock/subsys/vboxautostart ]; then
75 msg_not_running "VirtualBox Autostart"
76 RETVAL=$1
77 return
78 fi
79
80 stop
81 start
82}
83
84RETVAL=0
85# See how we were called.
86case "$1" in
87 start)
88 start
89 ;;
90 stop)
91 stop
92 ;;
93 restart)
94 stop
95 start
96 ;;
97 try-restart)
98 condrestart 0
99 ;;
100 force-reload)
101 condrestart 7
102 ;;
103 *)
104 msg_usage "$0 {start|stop|restart|try-restart|force-reload}"
105 exit 3
106esac
107
108exit $RETVAL
This page took 0.161404 seconds and 4 git commands to generate.