1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # InnoTek VirtualBox
|
---|
4 | #
|
---|
5 | # Linux Additions timesync daemon init script
|
---|
6 | #
|
---|
7 | # Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
8 | #
|
---|
9 | # Use only with permission.
|
---|
10 | #
|
---|
11 |
|
---|
12 | # chkconfig: 35 35 56
|
---|
13 | # description: VirtualBox Additions timesync
|
---|
14 | #
|
---|
15 | ### BEGIN INIT INFO
|
---|
16 | # Provides: vboxadd-timesync
|
---|
17 | # Required-Start: vboxadd
|
---|
18 | # Required-Stop: vboxadd
|
---|
19 | # Default-Start: 3 5
|
---|
20 | # Default-Stop:
|
---|
21 | # Description: VirtualBox Additions timesync
|
---|
22 | ### END INIT INFO
|
---|
23 |
|
---|
24 | PATH=$PATH:/bin:/sbin:/usr/sbin
|
---|
25 |
|
---|
26 | system=unknown
|
---|
27 | if [ -f /etc/redhat-release ]; then
|
---|
28 | system=redhat
|
---|
29 | PIDFILE="/var/lock/subsys/vboxadd-timesync"
|
---|
30 | elif [ -f /etc/SuSE-release ]; then
|
---|
31 | system=suse
|
---|
32 | PIDFILE="/var/lock/subsys/vboxadd-timesync"
|
---|
33 | elif [ -f /etc/debian_version ]; then
|
---|
34 | system=debian
|
---|
35 | PIDFILE="/var/run/vboxadd-timesync"
|
---|
36 | elif [ -f /etc/gentoo-release ]; then
|
---|
37 | system=gentoo
|
---|
38 | PIDFILE="/var/run/vboxadd-timesync"
|
---|
39 | elif [ -f /etc/slackware-version ]; then
|
---|
40 | system=slackware
|
---|
41 | else
|
---|
42 | echo "$0: Unknown system" 1>&2
|
---|
43 | fi
|
---|
44 |
|
---|
45 | if [ "$system" = "redhat" ]; then
|
---|
46 | . /etc/init.d/functions
|
---|
47 | fail_msg() {
|
---|
48 | echo_failure
|
---|
49 | echo
|
---|
50 | }
|
---|
51 |
|
---|
52 | succ_msg() {
|
---|
53 | echo_success
|
---|
54 | echo
|
---|
55 | }
|
---|
56 | fi
|
---|
57 |
|
---|
58 | if [ "$system" = "suse" ]; then
|
---|
59 | . /etc/rc.status
|
---|
60 | daemon() {
|
---|
61 | startproc ${1+"$@"}
|
---|
62 | }
|
---|
63 |
|
---|
64 | fail_msg() {
|
---|
65 | rc_failed 1
|
---|
66 | rc_status -v
|
---|
67 | }
|
---|
68 |
|
---|
69 | succ_msg() {
|
---|
70 | rc_reset
|
---|
71 | rc_status -v
|
---|
72 | }
|
---|
73 | fi
|
---|
74 |
|
---|
75 | if [ "$system" = "debian" ]; then
|
---|
76 | daemon() {
|
---|
77 | start-stop-daemon --start --exec $1 -- $2
|
---|
78 | }
|
---|
79 |
|
---|
80 | killproc() {
|
---|
81 | start-stop-daemon --stop --exec $@
|
---|
82 | }
|
---|
83 |
|
---|
84 | fail_msg() {
|
---|
85 | echo " ...fail!"
|
---|
86 | }
|
---|
87 |
|
---|
88 | succ_msg() {
|
---|
89 | echo " ...done."
|
---|
90 | }
|
---|
91 | fi
|
---|
92 |
|
---|
93 | if [ "$system" = "gentoo" ]; then
|
---|
94 | . /sbin/functions.sh
|
---|
95 | daemon() {
|
---|
96 | start-stop-daemon --start --exec $1 -- $2
|
---|
97 | }
|
---|
98 |
|
---|
99 | killproc() {
|
---|
100 | start-stop-daemon --stop --exec $@
|
---|
101 | }
|
---|
102 |
|
---|
103 | fail_msg() {
|
---|
104 | echo " ...fail!"
|
---|
105 | }
|
---|
106 |
|
---|
107 | succ_msg() {
|
---|
108 | echo " ...done."
|
---|
109 | }
|
---|
110 |
|
---|
111 | if [ "`which $0`" = "/sbin/rc" ]; then
|
---|
112 | shift
|
---|
113 | fi
|
---|
114 | fi
|
---|
115 |
|
---|
116 | if [ "$system" = "slackware" ]; then
|
---|
117 | fail_msg() {
|
---|
118 | echo " ...fail!"
|
---|
119 | }
|
---|
120 |
|
---|
121 | succ_msg() {
|
---|
122 | echo " ...done."
|
---|
123 | }
|
---|
124 |
|
---|
125 | begin() {
|
---|
126 | echo -n "$1"
|
---|
127 | }
|
---|
128 | fi
|
---|
129 |
|
---|
130 | binary=/usr/sbin/vboxadd-timesync
|
---|
131 |
|
---|
132 | test -x "$binary" || {
|
---|
133 | echo "Cannot run $binary"
|
---|
134 | exit 1
|
---|
135 | }
|
---|
136 |
|
---|
137 | vboxaddrunning() {
|
---|
138 | lsmod | grep -q vboxadd[^_-]
|
---|
139 | }
|
---|
140 |
|
---|
141 | start() {
|
---|
142 | if ! test -f $PIDFILE; then
|
---|
143 | echo -n "Starting VirtualBox host to guest time synchronisation ";
|
---|
144 | vboxaddrunning || {
|
---|
145 | echo "VirtualBox Additions module not loaded!"
|
---|
146 | exit 1
|
---|
147 | }
|
---|
148 | daemon $binary --daemonize
|
---|
149 | RETVAL=$?
|
---|
150 | test $RETVAL -eq 0 && touch $PIDFILE
|
---|
151 | succ_msg
|
---|
152 | fi
|
---|
153 | return $RETVAL
|
---|
154 | }
|
---|
155 |
|
---|
156 | stop() {
|
---|
157 | if test -f $PIDFILE; then
|
---|
158 | echo -n "Stopping VirtualBox host to guest time synchronisation ";
|
---|
159 | vboxaddrunning || {
|
---|
160 | echo "VirtualBox Additions module not loaded!"
|
---|
161 | exit 1
|
---|
162 | }
|
---|
163 | killproc $binary
|
---|
164 | RETVAL=$?
|
---|
165 | test $RETVAL -eq 0 && rm -f $PIDFILE
|
---|
166 | succ_msg
|
---|
167 | fi
|
---|
168 | return $RETVAL
|
---|
169 | }
|
---|
170 |
|
---|
171 | restart() {
|
---|
172 | stop && start
|
---|
173 | }
|
---|
174 |
|
---|
175 | dmnstatus() {
|
---|
176 | status vboxadd-timesync
|
---|
177 | }
|
---|
178 |
|
---|
179 | case "$1" in
|
---|
180 | start)
|
---|
181 | start
|
---|
182 | ;;
|
---|
183 | stop)
|
---|
184 | stop
|
---|
185 | ;;
|
---|
186 | restart)
|
---|
187 | restart
|
---|
188 | ;;
|
---|
189 | status)
|
---|
190 | dmnstatus
|
---|
191 | ;;
|
---|
192 | *)
|
---|
193 | echo "Usage: $0 {start|stop|restart|status}"
|
---|
194 | exit 1
|
---|
195 | esac
|
---|
196 |
|
---|
197 | exit $RETVAL
|
---|