VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/utils/TestExecServ/linux/vboxtxs-nat.sh@ 98477

Last change on this file since 98477 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1#!/bin/sh
2## @file
3# VirtualBox Test Execution Service Init Script for NATted setups.
4#
5
6#
7# Copyright (C) 2006-2023 Oracle and/or its affiliates.
8#
9# This file is part of VirtualBox base platform packages, as
10# available from https://www.virtualbox.org.
11#
12# This program is free software; you can redistribute it and/or
13# modify it under the terms of the GNU General Public License
14# as published by the Free Software Foundation, in version 3 of the
15# License.
16#
17# This program is distributed in the hope that it will be useful, but
18# WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20# General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, see <https://www.gnu.org/licenses>.
24#
25# The contents of this file may alternatively be used under the terms
26# of the Common Development and Distribution License Version 1.0
27# (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28# in the VirtualBox distribution, in which case the provisions of the
29# CDDL are applicable instead of those of the GPL.
30#
31# You may elect to license modified versions of this file under the
32# terms and conditions of either the GPL or the CDDL or both.
33#
34# SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35#
36
37# chkconfig: 35 35 65
38# description: VirtualBox Test Execution Service
39#
40### BEGIN INIT INFO
41# Provides: vboxtxs
42# Required-Start: $network
43# Required-Stop:
44# Default-Start: 2 3 4 5
45# Default-Stop: 0 1 6
46# Description: VirtualBox Test Execution Service
47### END INIT INFO
48
49PATH=$PATH:/bin:/sbin:/usr/sbin
50SCRIPTNAME=vboxtxs-nat.sh
51
52CDROM_PATH=/media/cdrom
53SCRATCH_PATH=/tmp/vboxtxs-scratch
54
55PIDFILE="/var/run/vboxtxs"
56
57# Preamble for Gentoo
58if [ "`which $0`" = "/sbin/rc" ]; then
59 shift
60fi
61
62begin_msg()
63{
64 test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
65 logger -t "${SCRIPTNAME}" "${1}."
66}
67
68succ_msg()
69{
70 logger -t "${SCRIPTNAME}" "${1}."
71}
72
73fail_msg()
74{
75 echo "${SCRIPTNAME}: failed: ${1}." >&2
76 logger -t "${SCRIPTNAME}" "failed: ${1}."
77}
78
79killproc() {
80 kp_binary="${1##*/}"
81 pkill "${kp_binary}" || return 0
82 sleep 1
83 pkill "${kp_binary}" || return 0
84 sleep 1
85 pkill -9 "${kp_binary}"
86 return 0
87}
88
89case "`uname -m`" in
90 AMD64|amd64|X86_64|x86_64)
91 binary=/opt/validationkit/linux/amd64/TestExecService
92 ;;
93
94 i386|x86|i486|i586|i686|i787)
95 binary=/opt/validationkit/linux/x86/TestExecService
96 ;;
97
98 *)
99 binary=/opt/validationkit/linux/x86/TestExecService
100 ;;
101esac
102
103fixAndTestBinary() {
104 chmod a+x "$binary" 2> /dev/null > /dev/null
105 test -x "$binary" || {
106 echo "Cannot run $binary"
107 exit 1
108 }
109}
110
111start() {
112 if ! test -f $PIDFILE; then
113 begin_msg "Starting VirtualBox Test Execution Service" console
114 fixAndTestBinary
115 mount /dev/cdrom "${CDROM_PATH}" 2> /dev/null > /dev/null
116 $binary --auto-upgrade --scratch="${SCRATCH_PATH}" --cdrom="${CDROM_PATH}" \
117 --no-display-output --tcp-connect 10.0.2.2 > /dev/null
118 RETVAL=$?
119 test $RETVAL -eq 0 && sleep 2 && echo `pidof TestExecService` > $PIDFILE
120 if ! test -s "${PIDFILE}"; then
121 RETVAL=5
122 fi
123 if test $RETVAL -eq 0; then
124 succ_msg "VirtualBox Test Execution service started"
125 else
126 fail_msg "VirtualBox Test Execution service failed to start"
127 fi
128 fi
129 return $RETVAL
130}
131
132stop() {
133 if test -f $PIDFILE; then
134 begin_msg "Stopping VirtualBox Test Execution Service" console
135 killproc $binary
136 fi
137}
138
139restart() {
140 stop && start
141}
142
143status() {
144 echo -n "Checking for vboxtxs"
145 if [ -f $PIDFILE ]; then
146 echo " ...running"
147 else
148 echo " ...not running"
149 fi
150}
151
152case "$1" in
153start)
154 start
155 ;;
156stop)
157 stop
158 ;;
159restart)
160 restart
161 ;;
162status)
163 status
164 ;;
165setup)
166 ;;
167cleanup)
168 ;;
169*)
170 echo "Usage: $0 {start|stop|restart|status}"
171 exit 1
172esac
173
174exit $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