]> git.pld-linux.org Git - packages/VirtualBox.git/blame_incremental - vboxautostart.init
up to 5.0.16
[packages/VirtualBox.git] / vboxautostart.init
... / ...
CommitLineData
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
14VBOXAUTOSTART_DB=/etc/vbox/autostart
15VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg
16VBOXAUTOSTART=@INSTALL_DIR@/VBoxAutostart
17
18# Get service config - may override defaults
19[ -f /etc/sysconfig/virtualbox ] && . /etc/sysconfig/virtualbox
20
21start_daemon() {
22 local user="$1"
23 shift
24 show "VMs for user '%s'" "$user"
25 daemon --user $user "$@"
26}
27
28start() {
29 # Check if the service is already running?
30 if [ -f /var/lock/subsys/vboxautostart ]; then
31 msg_already_running "VirtualBox Autostart"
32 return
33 fi
34
35 [ -z "$VBOXAUTOSTART_DB" ] && exit 0
36 [ -z "$VBOXAUTOSTART_CONFIG" ] && exit 0
37
38 msg_starting "VirtualBox VMs configured for autostart"; busy; echo
39
40 local file user PARAMS="--background --start --config $VBOXAUTOSTART_CONFIG"
41
42 # prevent inheriting this setting to VBoxSVC
43 unset VBOX_RELEASE_LOG_DEST
44
45 for file in $VBOXAUTOSTART_DB/*.start; do
46 test -f "$file" || continue
47 user=${file##*/}; user=${user%.start}
48 start_daemon $user $VBOXAUTOSTART $PARAMS
49 done
50
51 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/vboxautostart
52}
53
54stop() {
55 if [ ! -f /var/lock/subsys/vboxautostart ]; then
56 msg_not_running "VirtualBox Autostart"
57 return
58 fi
59
60 [ -z "$VBOXAUTOSTART_DB" ] && exit 0
61 [ -z "$VBOXAUTOSTART_CONFIG" ] && exit 0
62
63 # Stop daemons.
64 msg_stopping "VirtualBox Autostart"; busy; echo
65
66 local file user PARAMS="--stop --config $VBOXAUTOSTART_CONFIG"
67
68 # prevent inheriting this setting to VBoxSVC
69 unset VBOX_RELEASE_LOG_DEST
70
71 for file in $VBOXAUTOSTART_DB/*.stop; do
72 test -f "$file" || continue
73 user=${file##*/}; user=${user%.stop}
74 start_daemon $user $VBOXAUTOSTART $PARAMS
75 done
76
77 rm -f /var/lock/subsys/vboxautostart
78}
79
80condrestart() {
81 if [ ! -f /var/lock/subsys/vboxautostart ]; then
82 msg_not_running "VirtualBox Autostart"
83 RETVAL=$1
84 return
85 fi
86
87 stop
88 start
89}
90
91RETVAL=0
92# See how we were called.
93case "$1" in
94 start)
95 start
96 ;;
97 stop)
98 stop
99 ;;
100 restart)
101 stop
102 start
103 ;;
104 try-restart)
105 condrestart 0
106 ;;
107 force-reload)
108 condrestart 7
109 ;;
110 *)
111 msg_usage "$0 {start|stop|restart|try-restart|force-reload}"
112 exit 3
113esac
114
115exit $RETVAL
This page took 0.028175 seconds and 4 git commands to generate.