VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testboxscript/setup.sh@ 97405

Last change on this file since 97405 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 21.3 KB
Line 
1#!/usr/bin/env bash
2# $Id: setup.sh 96407 2022-08-22 17:43:14Z vboxsync $
3## @file
4# VirtualBox Validation Kit - TestBoxScript Service Setup on Unixy platforms.
5#
6
7#
8# Copyright (C) 2006-2022 Oracle and/or its affiliates.
9#
10# This file is part of VirtualBox base platform packages, as
11# available from https://www.virtualbox.org.
12#
13# This program is free software; you can redistribute it and/or
14# modify it under the terms of the GNU General Public License
15# as published by the Free Software Foundation, in version 3 of the
16# License.
17#
18# This program is distributed in the hope that it will be useful, but
19# WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21# General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program; if not, see <https://www.gnu.org/licenses>.
25#
26# The contents of this file may alternatively be used under the terms
27# of the Common Development and Distribution License Version 1.0
28# (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
29# in the VirtualBox distribution, in which case the provisions of the
30# CDDL are applicable instead of those of the GPL.
31#
32# You may elect to license modified versions of this file under the
33# terms and conditions of either the GPL or the CDDL or both.
34#
35# SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
36#
37
38
39#
40# !WARNING! Running the whole script in exit-on-failure mode.
41#
42# Note! Looking at the ash sources, it seems flags will be saved and restored
43# when calling functions. That's comforting.
44#
45set -e
46#set -x # debug only, disable!
47
48##
49# Get the host OS name, returning it in RETVAL.
50#
51get_host_os() {
52 RETVAL=`uname`
53 case "$RETVAL" in
54 Darwin|darwin)
55 RETVAL=darwin
56 ;;
57
58 DragonFly)
59 RETVAL=dragonfly
60 ;;
61
62 freebsd|FreeBSD|FREEBSD)
63 RETVAL=freebsd
64 ;;
65
66 Haiku)
67 RETVAL=haiku
68 ;;
69
70 linux|Linux|GNU/Linux|LINUX)
71 RETVAL=linux
72 ;;
73
74 netbsd|NetBSD|NETBSD)
75 RETVAL=netbsd
76 ;;
77
78 openbsd|OpenBSD|OPENBSD)
79 RETVAL=openbsd
80 ;;
81
82 os2|OS/2|OS2)
83 RETVAL=os2
84 ;;
85
86 SunOS)
87 RETVAL=solaris
88 ;;
89
90 WindowsNT|CYGWIN_NT-*)
91 RETVAL=win
92 ;;
93
94 *)
95 echo "$0: unknown os $RETVAL" 1>&2
96 exit 1
97 ;;
98 esac
99 return 0;
100}
101
102##
103# Get the host OS/CPU arch, returning it in RETVAL.
104#
105get_host_arch() {
106 if [ "${HOST_OS}" = "solaris" ]; then
107 RETVAL=`isainfo | cut -f 1 -d ' '`
108 else
109 RETVAL=`uname -m`
110 fi
111 case "${RETVAL}" in
112 amd64|AMD64|x86_64|k8|k8l|k9|k10)
113 RETVAL='amd64'
114 ;;
115 x86|i86pc|ia32|i[3456789]86|BePC)
116 RETVAL='x86'
117 ;;
118 sparc32|sparc|sparcv8|sparcv7|sparcv8e)
119 RETVAL='sparc32'
120 ;;
121 sparc64|sparcv9)
122 RETVAL='sparc64'
123 ;;
124 s390)
125 RETVAL='s390'
126 ;;
127 s390x)
128 RETVAL='s390x'
129 ;;
130 ppc32|ppc|powerpc)
131 RETVAL='ppc32'
132 ;;
133 ppc64|powerpc64)
134 RETVAL='ppc64'
135 ;;
136 mips32|mips)
137 RETVAL='mips32'
138 ;;
139 mips64)
140 RETVAL='mips64'
141 ;;
142 ia64)
143 RETVAL='ia64'
144 ;;
145 hppa32|parisc32|parisc)
146 RETVAL='hppa32'
147 ;;
148 hppa64|parisc64)
149 RETVAL='hppa64'
150 ;;
151 arm|armv4l|armv5tel|armv5tejl)
152 RETVAL='arm'
153 ;;
154 alpha)
155 RETVAL='alpha'
156 ;;
157
158 *)
159 echo "$0: unknown cpu/arch - $RETVAL" 1>&$2
160 exit 1
161 ;;
162 esac
163 return 0;
164}
165
166
167##
168# Loads config values from the current installation.
169#
170os_load_config() {
171 echo "os_load_config is not implemented" 2>&1
172 exit 1
173}
174
175##
176# Installs, configures and starts the service.
177#
178os_install_service() {
179 echo "os_install_service is not implemented" 2>&1
180 exit 1
181}
182
183##
184# Enables (starts) the service.
185os_enable_service() {
186 echo "os_enable_service is not implemented" 2>&1
187 return 0;
188}
189
190##
191# Disables (stops) the service.
192os_disable_service() {
193 echo "os_disable_service is not implemented" 2>&1
194 return 0;
195}
196
197##
198# Adds the testbox user
199#
200os_add_user() {
201 echo "os_add_user is not implemented" 2>&1
202 exit 1
203}
204
205##
206# Prints a final message after successful script execution.
207# This can contain additional instructions which needs to be carried out
208# manually or similar.
209os_final_message() {
210 return 0;
211}
212
213##
214# Checks the installation, verifying that files are there and scripts work fine.
215#
216check_testboxscript_install() {
217
218 # Presence
219 test -r "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript.py"
220 test -r "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript_real.py"
221 test -r "${TESTBOXSCRIPT_DIR}/testboxscript/linux/testboxscript-service.sh" -o "${HOST_OS}" != "linux"
222 test -r "${TESTBOXSCRIPT_DIR}/${HOST_OS}/${HOST_ARCH}/TestBoxHelper"
223
224 # Zip file may be missing the x bits, so set them.
225 chmod a+x \
226 "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript.py" \
227 "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript_real.py" \
228 "${TESTBOXSCRIPT_DIR}/${HOST_OS}/${HOST_ARCH}/TestBoxHelper" \
229 "${TESTBOXSCRIPT_DIR}/testboxscript/linux/testboxscript-service.sh"
230
231
232 # Check that the scripts work.
233 set +e
234 "${TESTBOXSCRIPT_PYTHON}" "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript.py" --version > /dev/null
235 if [ $? -ne 2 ]; then
236 echo "$0: error: testboxscript.py didn't respons correctly to the --version option."
237 exit 1;
238 fi
239
240 "${TESTBOXSCRIPT_PYTHON}" "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript_real.py" --version > /dev/null
241 if [ $? -ne 2 ]; then
242 echo "$0: error: testboxscript.py didn't respons correctly to the --version option."
243 exit 1;
244 fi
245 set -e
246
247 return 0;
248}
249
250##
251# Check that sudo is installed.
252#
253check_for_sudo() {
254 which sudo
255 test -f "${MY_ETC_SUDOERS}"
256}
257
258##
259# Check that sudo is installed.
260#
261check_for_cifs() {
262 return 0;
263}
264
265##
266# Checks if the testboxscript_user exists.
267does_testboxscript_user_exist() {
268 id "${TESTBOXSCRIPT_USER}" > /dev/null 2>&1
269 return $?;
270}
271
272##
273# hushes up the root login.
274maybe_hush_up_root_login() {
275 # This is a solaris hook.
276 return 0;
277}
278
279##
280# Adds the testbox user and make sure it has unrestricted sudo access.
281maybe_add_testboxscript_user() {
282 if ! does_testboxscript_user_exist; then
283 os_add_user "${TESTBOXSCRIPT_USER}"
284 fi
285
286 SUDOERS_LINE="${TESTBOXSCRIPT_USER} ALL=(ALL) NOPASSWD: ALL"
287 if ! ${MY_FGREP} -q "${SUDOERS_LINE}" ${MY_ETC_SUDOERS}; then
288 echo "# begin tinderboxscript setup.sh" >> ${MY_ETC_SUDOERS}
289 echo "${SUDOERS_LINE}" >> ${MY_ETC_SUDOERS}
290 echo "# end tinderboxscript setup.sh" >> ${MY_ETC_SUDOERS}
291 fi
292
293 maybe_hush_up_root_login;
294}
295
296
297##
298# Test the user.
299#
300test_user() {
301 su - "${TESTBOXSCRIPT_USER}" -c "true"
302
303 # sudo 1.7.0 adds the -n option.
304 MY_TMP="`sudo -V 2>&1 | head -1 | sed -e 's/^.*version 1\.[6543210]\..*$/old/'`"
305 if [ "${MY_TMP}" != "old" ]; then
306 echo "Warning: If sudo starts complaining about not having a tty,"
307 echo " disable the requiretty option in /etc/sudoers."
308 su - "${TESTBOXSCRIPT_USER}" -c "sudo -n -i true"
309 else
310 echo "Warning: You've got an old sudo installed. If it starts"
311 echo " complaining about not having a tty, disable the"
312 echo " requiretty option in /etc/sudoers."
313 su - "${TESTBOXSCRIPT_USER}" -c "sudo true"
314 fi
315}
316
317##
318# Test if core dumps are enabled. See https://wiki.ubuntu.com/Apport!
319#
320test_coredumps() {
321 # This is a linux hook.
322 return 0;
323}
324
325##
326# Test if unattended updates are disabled. See
327# http://ask.xmodulo.com/disable-automatic-updates-ubuntu.html
328test_unattended_updates_disabled() {
329 # This is a linux hook.
330 return 0;
331}
332
333##
334# Grants the user write access to the testboxscript files so it can perform
335# upgrades.
336#
337grant_user_testboxscript_write_access() {
338 chown -R "${TESTBOXSCRIPT_USER}" "${TESTBOXSCRIPT_DIR}"
339}
340
341##
342# Check the proxy setup.
343#
344check_proxy_config() {
345 if [ -n "${http_proxy}" -o -n "${ftp_proxy}" ]; then
346 if [ -z "${no_proxy}" ]; then
347 echo "Error: Env.vars. http_proxy/ftp_proxy without no_proxy is going to break upgrade among other things."
348 exit 1
349 fi
350 fi
351}
352
353##
354# Parses the testboxscript.py invocation, setting TESTBOXSCRIPT_xxx config
355# variables accordingly. Both darwin and solaris uses this.
356common_testboxscript_args_to_config()
357{
358 MY_ARG=0
359 while [ $# -gt 0 ];
360 do
361 case "$1" in
362 # boolean
363 "--hwvirt") TESTBOXSCRIPT_HWVIRT="yes";;
364 "--no-hwvirt") TESTBOXSCRIPT_HWVIRT="no";;
365 "--nested-paging") TESTBOXSCRIPT_NESTED_PAGING="yes";;
366 "--no-nested-paging") TESTBOXSCRIPT_NESTED_PAGING="no";;
367 "--io-mmu") TESTBOXSCRIPT_IOMMU="yes";;
368 "--no-io-mmu") TESTBOXSCRIPT_IOMMU="no";;
369 # optios taking values.
370 "--system-uuid") TESTBOXSCRIPT_SYSTEM_UUID="$2"; shift;;
371 "--scratch-root") TESTBOXSCRIPT_SCRATCH_ROOT="$2"; shift;;
372 "--test-manager") TESTBOXSCRIPT_TEST_MANAGER="$2"; shift;;
373 "--builds-path") TESTBOXSCRIPT_BUILDS_PATH="$2"; shift;;
374 "--builds-server-type") TESTBOXSCRIPT_BUILDS_TYPE="$2"; shift;;
375 "--builds-server-name") TESTBOXSCRIPT_BUILDS_NAME="$2"; shift;;
376 "--builds-server-share") TESTBOXSCRIPT_BUILDS_SHARE="$2"; shift;;
377 "--builds-server-user") TESTBOXSCRIPT_BUILDS_USER="$2"; shift;;
378 "--builds-server-passwd") TESTBOXSCRIPT_BUILDS_PASSWD="$2"; shift;;
379 "--builds-server-mountopt") TESTBOXSCRIPT_BUILDS_MOUNTOPT="$2"; shift;;
380 "--testrsrc-path") TESTBOXSCRIPT_TESTRSRC_PATH="$2"; shift;;
381 "--testrsrc-server-type") TESTBOXSCRIPT_TESTRSRC_TYPE="$2"; shift;;
382 "--testrsrc-server-name") TESTBOXSCRIPT_TESTRSRC_NAME="$2"; shift;;
383 "--testrsrc-server-share") TESTBOXSCRIPT_TESTRSRC_SHARE="$2"; shift;;
384 "--testrsrc-server-user") TESTBOXSCRIPT_TESTRSRC_USER="$2"; shift;;
385 "--testrsrc-server-passwd") TESTBOXSCRIPT_TESTRSRC_PASSWD="$2"; shift;;
386 "--testrsrc-server-mountopt") TESTBOXSCRIPT_TESTRSRC_MOUNTOPT="$2"; shift;;
387 "--spb") ;;
388 "--putenv")
389 MY_FOUND=no
390 MY_VAR=`echo $2 | sed -e 's/=.*$//' `
391 for i in ${!TESTBOXSCRIPT_ENVVARS[@]};
392 do
393 MY_CURVAR=`echo "${TESTBOXSCRIPT_ENVVARS[i]}" | sed -e 's/=.*$//' `
394 if [ -n "${MY_CURVAR}" -a "${MY_CURVAR}" = "${MY_VAR}" ]; then
395 TESTBOXSCRIPT_ENVVARS[$i]="$2"
396 MY_FOUND=yes
397 fi
398 done
399 if [ "${MY_FOUND}" = "no" ]; then
400 TESTBOXSCRIPT_ENVVARS=( "${TESTBOXSCRIPT_ENVVARS[@]}" "$2" );
401 fi
402 shift;;
403 --*)
404 echo "error: Unknown option '$1' in existing config"
405 exit 1
406 ;;
407
408 # Non-option bits.
409 *.py) ;; # ignored, should be the script.
410
411 *) if [ ${MY_ARG} -ne 0 ]; then
412 echo "error: unknown non-option '$1' in existing config"
413 exit 1
414 fi
415 TESTBOXSCRIPT_PYTHON="$1"
416 ;;
417 esac
418 shift
419 MY_ARG=$((${MY_ARG} + 1))
420 done
421}
422
423##
424# Used by common_compile_testboxscript_command_line, please override.
425#
426os_add_args() {
427 echo "os_add_args is not implemented" 2>&1
428 exit 1
429}
430
431##
432# Compiles the testboxscript.py command line given the current
433# configuration and defaults.
434#
435# This is used by solaris and darwin.
436#
437# The os_add_args function will be called several with one or two arguments
438# each time. The caller must override it.
439#
440common_compile_testboxscript_command_line() {
441 if [ -n "${TESTBOXSCRIPT_PYTHON}" ]; then
442 os_add_args "${TESTBOXSCRIPT_PYTHON}"
443 fi
444 os_add_args "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript.py"
445
446 for var in ${TESTBOXSCRIPT_CFG_NAMES};
447 do
448 varcfg=TESTBOXSCRIPT_${var}
449 vardef=TESTBOXSCRIPT_DEFAULT_${var}
450 if [ "${!varcfg}" != "${!vardef}" -a "${var}" != "PYTHON" ]; then # PYTHON handled above.
451 my_opt=TESTBOXSCRIPT_OPT_${var}
452 if [ -n "${!my_opt}" ]; then
453 if [ "${!my_opt}" == "--spb" ]; then
454 os_add_args "${!my_opt}"
455 elif [ "${!my_opt}" != "--skip" ]; then
456 os_add_args "${!my_opt}" "${!varcfg}"
457 fi
458 else
459 my_opt_yes=${my_opt}_YES
460 my_opt_no=${my_opt}_NO
461 if [ -n "${!my_opt_yes}" -a -n "${!my_opt_no}" ]; then
462 if [ "${!varcfg}" = "yes" ]; then
463 os_add_args "${!my_opt_yes}";
464 else
465 if [ "${!varcfg}" != "no" ]; then
466 echo "internal option misconfig: var=${var} not a yes/no value: ${!varcfg}";
467 exit 1;
468 fi
469 os_add_args "${!my_opt_yes}";
470 fi
471 else
472 echo "internal option misconfig: var=${var} my_opt_yes=${my_opt_yes}=${!my_opt_yes} my_opt_no=${my_opt_no}=${!my_opt_no}"
473 exit 1;
474 fi
475 fi
476 fi
477 done
478
479 i=0
480 while [ "${i}" -lt "${#TESTBOXSCRIPT_ENVVARS[@]}" ];
481 do
482 os_add_args "--putenv" "${TESTBOXSCRIPT_ENVVARS[${i}]}"
483 i=$((${i} + 1))
484 done
485}
486
487
488#
489#
490# main()
491#
492#
493
494
495#
496# Get our bearings and include the host specific code.
497#
498MY_ETC_SUDOERS="/etc/sudoers"
499MY_FGREP=fgrep
500DIR=`dirname "$0"`
501DIR=`cd "${DIR}"; /bin/pwd`
502
503get_host_os
504HOST_OS=${RETVAL}
505get_host_arch
506HOST_ARCH=${RETVAL}
507
508. "${DIR}/${HOST_OS}/setup-routines.sh"
509
510
511#
512# Config.
513#
514TESTBOXSCRIPT_CFG_NAMES="DIR PYTHON USER HWVIRT IOMMU NESTED_PAGING SYSTEM_UUID PATH_TESTRSRC TEST_MANAGER SCRATCH_ROOT"
515TESTBOXSCRIPT_CFG_NAMES="${TESTBOXSCRIPT_CFG_NAMES} BUILDS_PATH BUILDS_TYPE BUILDS_NAME BUILDS_SHARE BUILDS_USER"
516TESTBOXSCRIPT_CFG_NAMES="${TESTBOXSCRIPT_CFG_NAMES} BUILDS_PASSWD BUILDS_MOUNTOPT TESTRSRC_PATH TESTRSRC_TYPE TESTRSRC_NAME"
517TESTBOXSCRIPT_CFG_NAMES="${TESTBOXSCRIPT_CFG_NAMES} TESTRSRC_SHARE TESTRSRC_USER TESTRSRC_PASSWD TESTRSRC_MOUNTOPT SPB"
518
519# testboxscript.py option to config mappings.
520TESTBOXSCRIPT_OPT_DIR="--skip"
521TESTBOXSCRIPT_OPT_PYTHON="--skip"
522TESTBOXSCRIPT_OPT_USER="--skip"
523TESTBOXSCRIPT_OPT_HWVIRT_YES="--hwvirt"
524TESTBOXSCRIPT_OPT_HWVIRT_NO="--no-hwvirt"
525TESTBOXSCRIPT_OPT_NESTED_PAGING_YES="--nested-paging"
526TESTBOXSCRIPT_OPT_NESTED_PAGING_NO="--no-nested-paging"
527TESTBOXSCRIPT_OPT_IOMMU_YES="--io-mmu"
528TESTBOXSCRIPT_OPT_IOMMU_NO="--no-io-mmu"
529TESTBOXSCRIPT_OPT_SPB="--spb"
530TESTBOXSCRIPT_OPT_SYSTEM_UUID="--system-uuid"
531TESTBOXSCRIPT_OPT_TEST_MANAGER="--test-manager"
532TESTBOXSCRIPT_OPT_SCRATCH_ROOT="--scratch-root"
533TESTBOXSCRIPT_OPT_BUILDS_PATH="--builds-path"
534TESTBOXSCRIPT_OPT_BUILDS_TYPE="--builds-server-type"
535TESTBOXSCRIPT_OPT_BUILDS_NAME="--builds-server-name"
536TESTBOXSCRIPT_OPT_BUILDS_SHARE="--builds-server-share"
537TESTBOXSCRIPT_OPT_BUILDS_USER="--builds-server-user"
538TESTBOXSCRIPT_OPT_BUILDS_PASSWD="--builds-server-passwd"
539TESTBOXSCRIPT_OPT_BUILDS_MOUNTOPT="--builds-server-mountopt"
540TESTBOXSCRIPT_OPT_PATH_TESTRSRC="--testrsrc-path"
541TESTBOXSCRIPT_OPT_TESTRSRC_TYPE="--testrsrc-server-type"
542TESTBOXSCRIPT_OPT_TESTRSRC_NAME="--testrsrc-server-name"
543TESTBOXSCRIPT_OPT_TESTRSRC_SHARE="--testrsrc-server-share"
544TESTBOXSCRIPT_OPT_TESTRSRC_USER="--testrsrc-server-user"
545TESTBOXSCRIPT_OPT_TESTRSRC_PASSWD="--testrsrc-server-passwd"
546TESTBOXSCRIPT_OPT_TESTRSRC_MOUNTOPT="--testrsrc-server-mountopt"
547
548# Defaults:
549TESTBOXSCRIPT_DEFAULT_DIR="there-is-no-default-for-this-value"
550TESTBOXSCRIPT_DEFAULT_PYTHON=""
551TESTBOXSCRIPT_DEFAULT_USER="vbox"
552TESTBOXSCRIPT_DEFAULT_HWVIRT=""
553TESTBOXSCRIPT_DEFAULT_IOMMU=""
554TESTBOXSCRIPT_DEFAULT_NESTED_PAGING=""
555TESTBOXSCRIPT_DEFAULT_SPB=""
556TESTBOXSCRIPT_DEFAULT_SYSTEM_UUID=""
557TESTBOXSCRIPT_DEFAULT_PATH_TESTRSRC=""
558TESTBOXSCRIPT_DEFAULT_TEST_MANAGER=""
559TESTBOXSCRIPT_DEFAULT_SCRATCH_ROOT=""
560TESTBOXSCRIPT_DEFAULT_BUILDS_PATH=""
561TESTBOXSCRIPT_DEFAULT_BUILDS_TYPE="cifs"
562TESTBOXSCRIPT_DEFAULT_BUILDS_NAME="vboxstor.de.oracle.com"
563TESTBOXSCRIPT_DEFAULT_BUILDS_SHARE="builds"
564TESTBOXSCRIPT_DEFAULT_BUILDS_USER="guestr"
565TESTBOXSCRIPT_DEFAULT_BUILDS_PASSWD="guestr"
566TESTBOXSCRIPT_DEFAULT_BUILDS_MOUNTOPT=""
567TESTBOXSCRIPT_DEFAULT_TESTRSRC_PATH=""
568TESTBOXSCRIPT_DEFAULT_TESTRSRC_TYPE="cifs"
569TESTBOXSCRIPT_DEFAULT_TESTRSRC_NAME="teststor.de.oracle.com"
570TESTBOXSCRIPT_DEFAULT_TESTRSRC_SHARE="testrsrc"
571TESTBOXSCRIPT_DEFAULT_TESTRSRC_USER="guestr"
572TESTBOXSCRIPT_DEFAULT_TESTRSRC_PASSWD="guestr"
573TESTBOXSCRIPT_DEFAULT_TESTRSRC_MOUNTOPT=""
574
575# Set config values to defaults.
576for var in ${TESTBOXSCRIPT_CFG_NAMES}
577do
578 defvar=TESTBOXSCRIPT_DEFAULT_${var}
579 eval TESTBOXSCRIPT_${var}="${!defvar}"
580done
581declare -a TESTBOXSCRIPT_ENVVARS
582
583# Load old config values (platform specific).
584os_load_config
585
586
587#
588# Config tweaks.
589#
590
591# The USER must be a non-empty value for the successful execution of this script.
592if [ -z "${TESTBOXSCRIPT_USER}" ]; then
593 TESTBOXSCRIPT_USER=${TESTBOXSCRIPT_DEFAULT_USER};
594fi;
595
596# The DIR must be according to the setup.sh location.
597TESTBOXSCRIPT_DIR=`dirname "${DIR}"`
598
599# Storage server replacement trick.
600if [ "${TESTBOXSCRIPT_BUILDS_NAME}" = "solserv.de.oracle.com" ]; then
601 TESTBOXSCRIPT_BUILDS_NAME=${TESTBOXSCRIPT_DEFAULT_BUILDS_NAME}
602fi
603if [ "${TESTBOXSCRIPT_TESTRSRC_NAME}" = "solserv.de.oracle.com" ]; then
604 TESTBOXSCRIPT_TESTRSRC_NAME=${TESTBOXSCRIPT_DEFAULT_TESTRSRC_NAME}
605fi
606
607
608#
609# Parse arguments.
610#
611while test $# -gt 0;
612do
613 case "$1" in
614 -h|--help)
615 echo "TestBox Script setup utility."
616 echo "";
617 echo "Usage: setup.sh [options]";
618 echo "";
619 echo "Options:";
620 echo " Later...";
621 exit 0;
622 ;;
623 -V|--version)
624 echo '$Revision: 96407 $'
625 exit 0;
626 ;;
627
628 --python) TESTBOXSCRIPT_PYTHON="$2"; shift;;
629 --test-manager) TESTBOXSCRIPT_TEST_MANAGER="$2"; shift;;
630 --scratch-root) TESTBOXSCRIPT_SCRATCH_ROOT="$2"; shift;;
631 --system-uuid) TESTBOXSCRIPT_SYSTEM_UUID="$2"; shift;;
632 --hwvirt) TESTBOXSCRIPT_HWVIRT="yes";;
633 --no-hwvirt) TESTBOXSCRIPT_HWVIRT="no";;
634 --nested-paging) TESTBOXSCRIPT_NESTED_PAGING="yes";;
635 --no-nested-paging) TESTBOXSCRIPT_NESTED_PAGING="no";;
636 --io-mmu) TESTBOXSCRIPT_IOMMU="yes";;
637 --no-io-mmu) TESTBOXSCRIPT_IOMMU="no";;
638 --builds-path) TESTBOXSCRIPT_BUILDS_PATH="$2"; shift;;
639 --builds-server-type) TESTBOXSCRIPT_BUILDS_TYPE="$2"; shift;;
640 --builds-server-name) TESTBOXSCRIPT_BUILDS_NAME="$2"; shift;;
641 --builds-server-share) TESTBOXSCRIPT_BUILDS_SHARE="$2"; shift;;
642 --builds-server-user) TESTBOXSCRIPT_BUILDS_USER="$2"; shift;;
643 --builds-server-passwd) TESTBOXSCRIPT_BUILDS_PASSWD="$2"; shift;;
644 --builds-server-mountopt) TESTBOXSCRIPT_BUILDS_MOUNTOPT="$2"; shift;;
645 --testrsrc-path) TESTBOXSCRIPT_TESTRSRC_PATH="$2"; shift;;
646 --testrsrc-server-type) TESTBOXSCRIPT_TESTRSRC_TYPE="$2"; shift;;
647 --testrsrc-server-name) TESTBOXSCRIPT_TESTRSRC_NAME="$2"; shift;;
648 --testrsrc-server-share) TESTBOXSCRIPT_TESTRSRC_SHARE="$2"; shift;;
649 --testrsrc-server-user) TESTBOXSCRIPT_TESTRSRC_USER="$2"; shift;;
650 --testrsrc-server-passwd) TESTBOXSCRIPT_TESTRSRC_PASSWD="$2"; shift;;
651 --testrsrc-server-mountopt) TESTBOXSCRIPT_TESTRSRC_MOUNTOPT="$2"; shift;;
652 --spb) TESTBOXSCRIPT_SPB="yes";;
653 *)
654 echo 'Syntax error: Unknown option:' "$1" >&2;
655 exit 1;
656 ;;
657 esac
658 shift;
659done
660
661
662#
663# Find usable python if not already specified.
664#
665if [ -z "${TESTBOXSCRIPT_PYTHON}" ]; then
666 set +e
667 MY_PYTHON_VER_TEST="\
668import sys;\
669x = sys.version_info[0] == 2 and (sys.version_info[1] >= 6 or (sys.version_info[1] == 5 and sys.version_info[2] >= 1));\
670sys.exit(not x);\
671";
672 for python in python2.7 python2.6 python2.5 python;
673 do
674 python=`which ${python} 2> /dev/null`
675 if [ -n "${python}" -a -x "${python}" ]; then
676 if ${python} -c "${MY_PYTHON_VER_TEST}"; then
677 TESTBOXSCRIPT_PYTHON="${python}";
678 break;
679 fi
680 fi
681 done
682 set -e
683 test -n "${TESTBOXSCRIPT_PYTHON}";
684fi
685
686
687#
688# Do the job
689#
690set -e
691check_testboxscript_install;
692check_for_sudo;
693check_for_cifs;
694check_proxy_config;
695
696maybe_add_testboxscript_user;
697test_user;
698test_coredumps;
699test_unattended_updates_disabled;
700
701grant_user_testboxscript_write_access;
702
703os_disable_service;
704os_install_service;
705os_enable_service;
706
707#
708# That's all folks.
709#
710echo "done"
711os_final_message;
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