VirtualBox

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

Last change on this file since 78241 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-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.7 KB
Line 
1#!/bin/sh
2## @file
3# VirtualBox Test Execution Service Init Script for NATted setups.
4#
5
6#
7# Copyright (C) 2006-2019 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-nat.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}" \
107 --no-display-output --tcp-connect 10.0.2.2 > /dev/null
108 RETVAL=$?
109 test $RETVAL -eq 0 && sleep 2 && echo `pidof TestExecService` > $PIDFILE
110 if ! test -s "${PIDFILE}"; then
111 RETVAL=5
112 fi
113 if test $RETVAL -eq 0; then
114 succ_msg "VirtualBox Test Execution service started"
115 else
116 fail_msg "VirtualBox Test Execution service failed to start"
117 fi
118 fi
119 return $RETVAL
120}
121
122stop() {
123 if test -f $PIDFILE; then
124 begin_msg "Stopping VirtualBox Test Execution Service" console
125 killproc $binary
126 fi
127}
128
129restart() {
130 stop && start
131}
132
133status() {
134 echo -n "Checking for vboxtxs"
135 if [ -f $PIDFILE ]; then
136 echo " ...running"
137 else
138 echo " ...not running"
139 fi
140}
141
142case "$1" in
143start)
144 start
145 ;;
146stop)
147 stop
148 ;;
149restart)
150 restart
151 ;;
152status)
153 status
154 ;;
155setup)
156 ;;
157cleanup)
158 ;;
159*)
160 echo "Usage: $0 {start|stop|restart|status}"
161 exit 1
162esac
163
164exit $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