VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/utils/TestExecServ/linux/vboxtxs.sh@ 52776

Last change on this file since 52776 was 52776, checked in by vboxsync, 10 years ago

fix OSE

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 KB
Line 
1#!/bin/sh
2## @file
3# VirtualBox Test Execution Service Init Script.
4#
5
6#
7# Copyright (C) 2006-2014 Oracle Corporation
8#
9# This file is part of VirtualBox Open Source Edition (OSE), as
10# available from http://www.virtualbox.org. This file is free software;
11# you can redistribute it and/or modify it under the terms of the GNU
12# General Public License (GPL) as published by the Free Software
13# Foundation, in version 2 as it comes in the "COPYING" file of the
14# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16#
17# The contents of this file may alternatively be used under the terms
18# of the Common Development and Distribution License Version 1.0
19# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20# VirtualBox OSE distribution, in which case the provisions of the
21# CDDL are applicable instead of those of the GPL.
22#
23# You may elect to license modified versions of this file under the
24# terms and conditions of either the GPL or the CDDL or both.
25#
26
27# chkconfig: 35 35 65
28# description: VirtualBox Test Execution Service
29#
30### BEGIN INIT INFO
31# Provides: vboxtxs
32# Required-Start: $network
33# Required-Stop:
34# Default-Start: 2 3 4 5
35# Default-Stop: 0 1 6
36# Description: VirtualBox Test Execution Service
37### END INIT INFO
38
39PATH=$PATH:/bin:/sbin:/usr/sbin
40
41CDROM_PATH=/media/cdrom
42SCRATCH_PATH=/tmp/vboxtxs-scratch
43
44system=unknown
45if [ -f /etc/redhat-release ]; then
46 system=redhat
47 PIDFILE="/var/lock/subsys/vboxtxs"
48elif [ -f /etc/SuSE-release ]; then
49 system=suse
50 PIDFILE="/var/lock/subsys/vboxtxs"
51elif [ -f /etc/debian_version ]; then
52 system=debian
53 PIDFILE="/var/run/vboxtxs"
54elif [ -f /etc/gentoo-release ]; then
55 system=gentoo
56 PIDFILE="/var/run/vboxtxs"
57elif [ -f /etc/arch-release ]; then
58 system=arch
59 PIDFILE="/var/run/vboxtxs"
60elif [ -f /etc/slackware-version ]; then
61 system=slackware
62 PIDFILE="/var/run/vboxtxs"
63elif [ -f /etc/lfs-release ]; then
64 system=lfs
65 PIDFILE="/var/run/vboxtxs.pid"
66else
67 system=other
68 if [ -d /var/run -a -w /var/run ]; then
69 PIDFILE="/var/run/vboxtxs"
70 fi
71fi
72
73if [ "$system" = "redhat" ]; then
74 . /etc/init.d/functions
75 fail_msg() {
76 echo_failure
77 echo
78 }
79
80 succ_msg() {
81 echo_success
82 echo
83 }
84
85 begin() {
86 echo -n "$1"
87 }
88fi
89
90if [ "$system" = "suse" ]; then
91 . /etc/rc.status
92 daemon() {
93 startproc ${1+"$@"}
94 }
95
96 fail_msg() {
97 rc_failed 1
98 rc_status -v
99 }
100
101 succ_msg() {
102 rc_reset
103 rc_status -v
104 }
105
106 begin() {
107 echo -n "$1"
108 }
109fi
110
111if [ "$system" = "debian" ]; then
112 daemon() {
113 start-stop-daemon --start --exec $1 -- $2
114 }
115
116 killproc() {
117 start-stop-daemon --stop --exec $@
118 }
119
120 fail_msg() {
121 echo " ...fail!"
122 }
123
124 succ_msg() {
125 echo " ...done."
126 }
127
128 begin() {
129 echo -n "$1"
130 }
131fi
132
133if [ "$system" = "gentoo" ]; then
134 if [ -f /sbin/functions.sh ]; then
135 . /sbin/functions.sh
136 elif [ -f /etc/init.d/functions.sh ]; then
137 . /etc/init.d/functions.sh
138 fi
139 daemon() {
140 start-stop-daemon --start --exec $1 -- $2
141 }
142
143 killproc() {
144 start-stop-daemon --stop --exec $@
145 }
146
147 fail_msg() {
148 echo " ...fail!"
149 }
150
151 succ_msg() {
152 echo " ...done."
153 }
154
155 begin() {
156 echo -n "$1"
157 }
158
159 if [ "`which $0`" = "/sbin/rc" ]; then
160 shift
161 fi
162fi
163
164if [ "$system" = "arch" ]; then
165 USECOLOR=yes
166 . /etc/rc.d/functions
167 daemon() {
168 $@
169 test $? -eq 0 && add_daemon rc.`basename $1`
170 }
171
172 killproc() {
173 killall $@
174 rm_daemon `basename $@`
175 }
176
177 fail_msg() {
178 stat_fail
179 }
180
181 succ_msg() {
182 stat_done
183 }
184
185 begin() {
186 stat_busy "$1"
187 }
188
189fi
190
191if [ "$system" = "slackware" ]; then
192 daemon() {
193 $1 $2
194 }
195
196 killproc() {
197 killall $1
198 rm -f $PIDFILE
199 }
200
201 fail_msg() {
202 echo " ...fail!"
203 }
204
205 succ_msg() {
206 echo " ...done."
207 }
208
209 begin() {
210 echo -n "$1"
211 }
212
213fi
214
215if [ "$system" = "lfs" ]; then
216 . /etc/rc.d/init.d/functions
217 daemon() {
218 loadproc $1 $2
219 }
220
221 fail_msg() {
222 echo_failure
223 }
224
225 succ_msg() {
226 echo_ok
227 }
228
229 begin() {
230 echo $1
231 }
232
233 status() {
234 statusproc $1
235 }
236fi
237
238if [ "$system" = "other" ]; then
239 fail_msg() {
240 echo " ...fail!"
241 }
242
243 succ_msg() {
244 echo " ...done."
245 }
246
247 begin() {
248 echo -n "$1"
249 }
250fi
251
252case "`uname -m`" in
253 AMD64|amd64|X86_64|x86_64)
254 binary=/root/validationkit/linux/amd64/TestExecService
255 ;;
256
257 i386|x86|i486|i586|i686|i787)
258 binary=/root/validationkit/linux/x86/TestExecService
259 ;;
260
261 *)
262 binary=/root/validationkit/linux/x86/TestExecService
263 ;;
264esac
265
266fixAndTestBinary() {
267 chmod a+x "$binary" 2> /dev/null > /dev/null
268 test -x "$binary" || {
269 echo "Cannot run $binary"
270 exit 1
271 }
272}
273
274start() {
275 if ! test -f $PIDFILE; then
276 begin "Starting VirtualBox Test Execution Service ";
277 fixAndTestBinary
278 mount /dev/cdrom "${CDROM_PATH}" 2> /dev/null > /dev/null
279 daemon $binary --auto-upgrade --scratch="${SCRATCH_PATH}" --cdrom="${CDROM_PATH}" --no-display-output > /dev/null
280 RETVAL=$?
281 test $RETVAL -eq 0 && sleep 2 && echo `pidof TestExecService` > $PIDFILE
282 if ! test -s "${PIDFILE}"; then
283 RETVAL=5
284 fi
285 if test $RETVAL -eq 0; then
286 succ_msg
287 else
288 fail_msg
289 fi
290 fi
291 return $RETVAL
292}
293
294stop() {
295 if test -f $PIDFILE; then
296 begin "Stopping VirtualBox Test Execution Service ";
297 killproc $binary
298 RETVAL=$?
299 test $RETVAL -eq 0 && rm -f $PIDFILE
300 succ_msg
301 fi
302 return $RETVAL
303}
304
305restart() {
306 stop && start
307}
308
309status() {
310 echo -n "Checking for vboxtxs"
311 if [ -f $PIDFILE ]; then
312 echo " ...running"
313 else
314 echo " ...not running"
315 fi
316}
317
318case "$1" in
319start)
320 start
321 ;;
322stop)
323 stop
324 ;;
325restart)
326 restart
327 ;;
328status)
329 status
330 ;;
331setup)
332 ;;
333cleanup)
334 ;;
335*)
336 echo "Usage: $0 {start|stop|restart|status}"
337 exit 1
338esac
339
340exit $RETVAL
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette