]> git.pld-linux.org Git - packages/VirtualBox.git/blame - vboxautostart.init
- updated multilib deps
[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
2daf9ea4 14VBOXAUTOSTART_DB=/etc/vbox/autostart
2a57ea39 15VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg
82aa9ee6 16VBOXAUTOSTART=@INSTALL_DIR@/VBoxAutostart
2a57ea39 17
c920e7db
ER
18# Get service config - may override defaults
19[ -f /etc/sysconfig/virtualbox ] && . /etc/sysconfig/virtualbox
20
21start_daemon() {
22 local user="$1"
23 shift
601fb330 24 show "VMs for user '%s'" "$user"
c920e7db
ER
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
98a7cd53
ER
35 [ -z "$VBOXAUTOSTART_DB" ] && exit 0
36 [ -z "$VBOXAUTOSTART_CONFIG" ] && exit 0
c920e7db 37
601fb330 38 msg_starting "VirtualBox VMs configured for autostart"; busy; echo
c920e7db 39
601fb330 40 local file user PARAMS="--background --start --config $VBOXAUTOSTART_CONFIG"
c920e7db 41
98a7cd53
ER
42 # prevent inheriting this setting to VBoxSVC
43 unset VBOX_RELEASE_LOG_DEST
c920e7db 44
601fb330
ER
45 for file in $VBOXAUTOSTART_DB/*.start; do
46 test -f "$file" || continue
47 user=${file##*/}; user=${user%.start}
98a7cd53
ER
48 start_daemon $user $VBOXAUTOSTART $PARAMS
49 done
c920e7db
ER
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
98a7cd53
ER
60 [ -z "$VBOXAUTOSTART_DB" ] && exit 0
61 [ -z "$VBOXAUTOSTART_CONFIG" ] && exit 0
c920e7db
ER
62
63 # Stop daemons.
601fb330 64 msg_stopping "VirtualBox Autostart"; busy; echo
c920e7db 65
601fb330 66 local file user PARAMS="--stop --config $VBOXAUTOSTART_CONFIG"
c920e7db 67
98a7cd53
ER
68 # prevent inheriting this setting to VBoxSVC
69 unset VBOX_RELEASE_LOG_DEST
c920e7db 70
601fb330
ER
71 for file in $VBOXAUTOSTART_DB/*.stop; do
72 test -f "$file" || continue
73 user=${file##*/}; user=${user%.stop}
98a7cd53
ER
74 start_daemon $user $VBOXAUTOSTART $PARAMS
75 done
c920e7db
ER
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.042121 seconds and 4 git commands to generate.