VirtualBox

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

Last change on this file since 72401 was 69111, checked in by vboxsync, 7 years ago

(C) year

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1#!/bin/sh
2## @file
3# VirtualBox Test Execution Service Init Script.
4#
5
6#
7# Copyright (C) 2006-2017 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
40SCRIPTNAME=vboxtxs.sh
41
42CDROM_PATH=/media/cdrom
43SCRATCH_PATH=/tmp/vboxtxs-scratch
44
45PIDFILE="/var/run/vboxtxs"
46
47# Preamble for Gentoo
48if [ "`which $0`" = "/sbin/rc" ]; then
49 shift
50fi
51
52begin_msg()
53{
54 test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
55 logger -t "${SCRIPTNAME}" "${1}."
56}
57
58succ_msg()
59{
60 logger -t "${SCRIPTNAME}" "${1}."
61}
62
63fail_msg()
64{
65 echo "${SCRIPTNAME}: failed: ${1}." >&2
66 logger -t "${SCRIPTNAME}" "failed: ${1}."
67}
68
69killproc() {
70 kp_binary="${1##*/}"
71 pkill "${kp_binary}" || return 0
72 sleep 1
73 pkill "${kp_binary}" || return 0
74 sleep 1
75 pkill -9 "${kp_binary}"
76 return 0
77}
78
79case "`uname -m`" in
80 AMD64|amd64|X86_64|x86_64)
81 binary=/opt/validationkit/linux/amd64/TestExecService
82 ;;
83
84 i386|x86|i486|i586|i686|i787)
85 binary=/opt/validationkit/linux/x86/TestExecService
86 ;;
87
88 *)
89 binary=/opt/validationkit/linux/x86/TestExecService
90 ;;
91esac
92
93fixAndTestBinary() {
94 chmod a+x "$binary" 2> /dev/null > /dev/null
95 test -x "$binary" || {
96 echo "Cannot run $binary"
97 exit 1
98 }
99}
100
101start() {
102 if ! test -f $PIDFILE; then
103 begin_msg "Starting VirtualBox Test Execution Service" console
104 fixAndTestBinary
105 mount /dev/cdrom "${CDROM_PATH}" 2> /dev/null > /dev/null
106 $binary --auto-upgrade --scratch="${SCRATCH_PATH}" --cdrom="${CDROM_PATH}" --no-display-output > /dev/null
107 RETVAL=$?
108 test $RETVAL -eq 0 && sleep 2 && echo `pidof TestExecService` > $PIDFILE
109 if ! test -s "${PIDFILE}"; then
110 RETVAL=5
111 fi
112 if test $RETVAL -eq 0; then
113 succ_msg "VirtualBox Test Execution service started"
114 else
115 fail_msg "VirtualBox Test Execution service failed to start"
116 fi
117 fi
118 return $RETVAL
119}
120
121stop() {
122 if test -f $PIDFILE; then
123 begin_msg "Stopping VirtualBox Test Execution Service" console
124 killproc $binary
125 fi
126}
127
128restart() {
129 stop && start
130}
131
132status() {
133 echo -n "Checking for vboxtxs"
134 if [ -f $PIDFILE ]; then
135 echo " ...running"
136 else
137 echo " ...not running"
138 fi
139}
140
141case "$1" in
142start)
143 start
144 ;;
145stop)
146 stop
147 ;;
148restart)
149 restart
150 ;;
151status)
152 status
153 ;;
154setup)
155 ;;
156cleanup)
157 ;;
158*)
159 echo "Usage: $0 {start|stop|restart|status}"
160 exit 1
161esac
162
163exit $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