VirtualBox

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

Last change on this file since 104699 was 103276, checked in by vboxsync, 9 months ago

Changing the python version detection section

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 21.4 KB
Line 
1#!/usr/bin/env bash
2# $Id: setup.sh 103276 2024-02-08 12:08:47Z vboxsync $
3## @file
4# VirtualBox Validation Kit - TestBoxScript Service Setup on Unixy platforms.
5#
6
7#
8# Copyright (C) 2006-2023 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 arm64|aarch64)
155 RETVAL='arm64'
156 ;;
157 alpha)
158 RETVAL='alpha'
159 ;;
160
161 *)
162 echo "$0: unknown cpu/arch - $RETVAL" 1>&$2
163 exit 1
164 ;;
165 esac
166 return 0;
167}
168
169
170##
171# Loads config values from the current installation.
172#
173os_load_config() {
174 echo "os_load_config is not implemented" 2>&1
175 exit 1
176}
177
178##
179# Installs, configures and starts the service.
180#
181os_install_service() {
182 echo "os_install_service is not implemented" 2>&1
183 exit 1
184}
185
186##
187# Enables (starts) the service.
188os_enable_service() {
189 echo "os_enable_service is not implemented" 2>&1
190 return 0;
191}
192
193##
194# Disables (stops) the service.
195os_disable_service() {
196 echo "os_disable_service is not implemented" 2>&1
197 return 0;
198}
199
200##
201# Adds the testbox user
202#
203os_add_user() {
204 echo "os_add_user is not implemented" 2>&1
205 exit 1
206}
207
208##
209# Prints a final message after successful script execution.
210# This can contain additional instructions which needs to be carried out
211# manually or similar.
212os_final_message() {
213 return 0;
214}
215
216##
217# Checks the installation, verifying that files are there and scripts work fine.
218#
219check_testboxscript_install() {
220
221 # Presence
222 test -r "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript.py"
223 test -r "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript_real.py"
224 test -r "${TESTBOXSCRIPT_DIR}/testboxscript/linux/testboxscript-service.sh" -o "${HOST_OS}" != "linux"
225 test -r "${TESTBOXSCRIPT_DIR}/${HOST_OS}/${HOST_ARCH}/TestBoxHelper"
226
227 # Zip file may be missing the x bits, so set them.
228 chmod a+x \
229 "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript.py" \
230 "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript_real.py" \
231 "${TESTBOXSCRIPT_DIR}/${HOST_OS}/${HOST_ARCH}/TestBoxHelper" \
232 "${TESTBOXSCRIPT_DIR}/testboxscript/linux/testboxscript-service.sh"
233
234
235 # Check that the scripts work.
236 set +e
237 "${TESTBOXSCRIPT_PYTHON}" "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript.py" --version > /dev/null
238 if [ $? -ne 2 ]; then
239 echo "$0: error: testboxscript.py didn't respond correctly to the --version option."
240 exit 1;
241 fi
242
243 "${TESTBOXSCRIPT_PYTHON}" "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript_real.py" --version > /dev/null
244 if [ $? -ne 2 ]; then
245 echo "$0: error: testboxscript.py didn't respond correctly to the --version option."
246 exit 1;
247 fi
248 set -e
249
250 return 0;
251}
252
253##
254# Check that sudo is installed.
255#
256check_for_sudo() {
257 which sudo
258 test -f "${MY_ETC_SUDOERS}"
259}
260
261##
262# Check that sudo is installed.
263#
264check_for_cifs() {
265 return 0;
266}
267
268##
269# Checks if the testboxscript_user exists.
270does_testboxscript_user_exist() {
271 id "${TESTBOXSCRIPT_USER}" > /dev/null 2>&1
272 return $?;
273}
274
275##
276# hushes up the root login.
277maybe_hush_up_root_login() {
278 # This is a solaris hook.
279 return 0;
280}
281
282##
283# Adds the testbox user and make sure it has unrestricted sudo access.
284maybe_add_testboxscript_user() {
285 if ! does_testboxscript_user_exist; then
286 os_add_user "${TESTBOXSCRIPT_USER}"
287 fi
288
289 SUDOERS_LINE="${TESTBOXSCRIPT_USER} ALL=(ALL) NOPASSWD: ALL"
290 if ! ${MY_FGREP} -q "${SUDOERS_LINE}" ${MY_ETC_SUDOERS}; then
291 echo "# begin tinderboxscript setup.sh" >> ${MY_ETC_SUDOERS}
292 echo "${SUDOERS_LINE}" >> ${MY_ETC_SUDOERS}
293 echo "# end tinderboxscript setup.sh" >> ${MY_ETC_SUDOERS}
294 fi
295
296 maybe_hush_up_root_login;
297}
298
299
300##
301# Test the user.
302#
303test_user() {
304 su - "${TESTBOXSCRIPT_USER}" -c "true"
305
306 # sudo 1.7.0 adds the -n option.
307 MY_TMP="`sudo -V 2>&1 | head -1 | sed -e 's/^.*version 1\.[6543210]\..*$/old/'`"
308 if [ "${MY_TMP}" != "old" ]; then
309 echo "Warning: If sudo starts complaining about not having a tty,"
310 echo " disable the requiretty option in /etc/sudoers."
311 su - "${TESTBOXSCRIPT_USER}" -c "sudo -n -i true"
312 else
313 echo "Warning: You've got an old sudo installed. If it starts"
314 echo " complaining about not having a tty, disable the"
315 echo " requiretty option in /etc/sudoers."
316 su - "${TESTBOXSCRIPT_USER}" -c "sudo true"
317 fi
318}
319
320##
321# Test if core dumps are enabled. See https://wiki.ubuntu.com/Apport!
322#
323test_coredumps() {
324 # This is a linux hook.
325 return 0;
326}
327
328##
329# Test if unattended updates are disabled. See
330# http://ask.xmodulo.com/disable-automatic-updates-ubuntu.html
331test_unattended_updates_disabled() {
332 # This is a linux hook.
333 return 0;
334}
335
336##
337# Grants the user write access to the testboxscript files so it can perform
338# upgrades.
339#
340grant_user_testboxscript_write_access() {
341 chown -R "${TESTBOXSCRIPT_USER}" "${TESTBOXSCRIPT_DIR}"
342}
343
344##
345# Check the proxy setup.
346#
347check_proxy_config() {
348 if [ -n "${http_proxy}" -o -n "${ftp_proxy}" ]; then
349 if [ -z "${no_proxy}" ]; then
350 echo "Error: Env.vars. http_proxy/ftp_proxy without no_proxy is going to break upgrade among other things."
351 exit 1
352 fi
353 fi
354}
355
356##
357# Parses the testboxscript.py invocation, setting TESTBOXSCRIPT_xxx config
358# variables accordingly. Both darwin and solaris uses this.
359common_testboxscript_args_to_config()
360{
361 MY_ARG=0
362 while [ $# -gt 0 ];
363 do
364 case "$1" in
365 # boolean
366 "--hwvirt") TESTBOXSCRIPT_HWVIRT="yes";;
367 "--no-hwvirt") TESTBOXSCRIPT_HWVIRT="no";;
368 "--nested-paging") TESTBOXSCRIPT_NESTED_PAGING="yes";;
369 "--no-nested-paging") TESTBOXSCRIPT_NESTED_PAGING="no";;
370 "--io-mmu") TESTBOXSCRIPT_IOMMU="yes";;
371 "--no-io-mmu") TESTBOXSCRIPT_IOMMU="no";;
372 # optios taking values.
373 "--system-uuid") TESTBOXSCRIPT_SYSTEM_UUID="$2"; shift;;
374 "--scratch-root") TESTBOXSCRIPT_SCRATCH_ROOT="$2"; shift;;
375 "--test-manager") TESTBOXSCRIPT_TEST_MANAGER="$2"; shift;;
376 "--builds-path") TESTBOXSCRIPT_BUILDS_PATH="$2"; shift;;
377 "--builds-server-type") TESTBOXSCRIPT_BUILDS_TYPE="$2"; shift;;
378 "--builds-server-name") TESTBOXSCRIPT_BUILDS_NAME="$2"; shift;;
379 "--builds-server-share") TESTBOXSCRIPT_BUILDS_SHARE="$2"; shift;;
380 "--builds-server-user") TESTBOXSCRIPT_BUILDS_USER="$2"; shift;;
381 "--builds-server-passwd") TESTBOXSCRIPT_BUILDS_PASSWD="$2"; shift;;
382 "--builds-server-mountopt") TESTBOXSCRIPT_BUILDS_MOUNTOPT="$2"; shift;;
383 "--testrsrc-path") TESTBOXSCRIPT_TESTRSRC_PATH="$2"; shift;;
384 "--testrsrc-server-type") TESTBOXSCRIPT_TESTRSRC_TYPE="$2"; shift;;
385 "--testrsrc-server-name") TESTBOXSCRIPT_TESTRSRC_NAME="$2"; shift;;
386 "--testrsrc-server-share") TESTBOXSCRIPT_TESTRSRC_SHARE="$2"; shift;;
387 "--testrsrc-server-user") TESTBOXSCRIPT_TESTRSRC_USER="$2"; shift;;
388 "--testrsrc-server-passwd") TESTBOXSCRIPT_TESTRSRC_PASSWD="$2"; shift;;
389 "--testrsrc-server-mountopt") TESTBOXSCRIPT_TESTRSRC_MOUNTOPT="$2"; shift;;
390 "--spb") ;;
391 "--putenv")
392 MY_FOUND=no
393 MY_VAR=`echo $2 | sed -e 's/=.*$//' `
394 for i in ${!TESTBOXSCRIPT_ENVVARS[@]};
395 do
396 MY_CURVAR=`echo "${TESTBOXSCRIPT_ENVVARS[i]}" | sed -e 's/=.*$//' `
397 if [ -n "${MY_CURVAR}" -a "${MY_CURVAR}" = "${MY_VAR}" ]; then
398 TESTBOXSCRIPT_ENVVARS[$i]="$2"
399 MY_FOUND=yes
400 fi
401 done
402 if [ "${MY_FOUND}" = "no" ]; then
403 TESTBOXSCRIPT_ENVVARS=( "${TESTBOXSCRIPT_ENVVARS[@]}" "$2" );
404 fi
405 shift;;
406 --*)
407 echo "error: Unknown option '$1' in existing config"
408 exit 1
409 ;;
410
411 # Non-option bits.
412 *.py) ;; # ignored, should be the script.
413
414 *) if [ ${MY_ARG} -ne 0 ]; then
415 echo "error: unknown non-option '$1' in existing config"
416 exit 1
417 fi
418 TESTBOXSCRIPT_PYTHON="$1"
419 ;;
420 esac
421 shift
422 MY_ARG=$((${MY_ARG} + 1))
423 done
424}
425
426##
427# Used by common_compile_testboxscript_command_line, please override.
428#
429os_add_args() {
430 echo "os_add_args is not implemented" 2>&1
431 exit 1
432}
433
434##
435# Compiles the testboxscript.py command line given the current
436# configuration and defaults.
437#
438# This is used by solaris and darwin.
439#
440# The os_add_args function will be called several with one or two arguments
441# each time. The caller must override it.
442#
443common_compile_testboxscript_command_line() {
444 if [ -n "${TESTBOXSCRIPT_PYTHON}" ]; then
445 os_add_args "${TESTBOXSCRIPT_PYTHON}"
446 fi
447 os_add_args "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript.py"
448
449 for var in ${TESTBOXSCRIPT_CFG_NAMES};
450 do
451 varcfg=TESTBOXSCRIPT_${var}
452 vardef=TESTBOXSCRIPT_DEFAULT_${var}
453 if [ "${!varcfg}" != "${!vardef}" -a "${var}" != "PYTHON" ]; then # PYTHON handled above.
454 my_opt=TESTBOXSCRIPT_OPT_${var}
455 if [ -n "${!my_opt}" ]; then
456 if [ "${!my_opt}" == "--spb" ]; then
457 os_add_args "${!my_opt}"
458 elif [ "${!my_opt}" != "--skip" ]; then
459 os_add_args "${!my_opt}" "${!varcfg}"
460 fi
461 else
462 my_opt_yes=${my_opt}_YES
463 my_opt_no=${my_opt}_NO
464 if [ -n "${!my_opt_yes}" -a -n "${!my_opt_no}" ]; then
465 if [ "${!varcfg}" = "yes" ]; then
466 os_add_args "${!my_opt_yes}";
467 else
468 if [ "${!varcfg}" != "no" ]; then
469 echo "internal option misconfig: var=${var} not a yes/no value: ${!varcfg}";
470 exit 1;
471 fi
472 os_add_args "${!my_opt_yes}";
473 fi
474 else
475 echo "internal option misconfig: var=${var} my_opt_yes=${my_opt_yes}=${!my_opt_yes} my_opt_no=${my_opt_no}=${!my_opt_no}"
476 exit 1;
477 fi
478 fi
479 fi
480 done
481
482 i=0
483 while [ "${i}" -lt "${#TESTBOXSCRIPT_ENVVARS[@]}" ];
484 do
485 os_add_args "--putenv" "${TESTBOXSCRIPT_ENVVARS[${i}]}"
486 i=$((${i} + 1))
487 done
488}
489
490
491#
492#
493# main()
494#
495#
496
497
498#
499# Get our bearings and include the host specific code.
500#
501MY_ETC_SUDOERS="/etc/sudoers"
502MY_FGREP=fgrep
503DIR=`dirname "$0"`
504DIR=`cd "${DIR}"; /bin/pwd`
505
506get_host_os
507HOST_OS=${RETVAL}
508get_host_arch
509HOST_ARCH=${RETVAL}
510
511. "${DIR}/${HOST_OS}/setup-routines.sh"
512
513
514#
515# Config.
516#
517TESTBOXSCRIPT_CFG_NAMES="DIR PYTHON USER HWVIRT IOMMU NESTED_PAGING SYSTEM_UUID PATH_TESTRSRC TEST_MANAGER SCRATCH_ROOT"
518TESTBOXSCRIPT_CFG_NAMES="${TESTBOXSCRIPT_CFG_NAMES} BUILDS_PATH BUILDS_TYPE BUILDS_NAME BUILDS_SHARE BUILDS_USER"
519TESTBOXSCRIPT_CFG_NAMES="${TESTBOXSCRIPT_CFG_NAMES} BUILDS_PASSWD BUILDS_MOUNTOPT TESTRSRC_PATH TESTRSRC_TYPE TESTRSRC_NAME"
520TESTBOXSCRIPT_CFG_NAMES="${TESTBOXSCRIPT_CFG_NAMES} TESTRSRC_SHARE TESTRSRC_USER TESTRSRC_PASSWD TESTRSRC_MOUNTOPT SPB"
521
522# testboxscript.py option to config mappings.
523TESTBOXSCRIPT_OPT_DIR="--skip"
524TESTBOXSCRIPT_OPT_PYTHON="--skip"
525TESTBOXSCRIPT_OPT_USER="--skip"
526TESTBOXSCRIPT_OPT_HWVIRT_YES="--hwvirt"
527TESTBOXSCRIPT_OPT_HWVIRT_NO="--no-hwvirt"
528TESTBOXSCRIPT_OPT_NESTED_PAGING_YES="--nested-paging"
529TESTBOXSCRIPT_OPT_NESTED_PAGING_NO="--no-nested-paging"
530TESTBOXSCRIPT_OPT_IOMMU_YES="--io-mmu"
531TESTBOXSCRIPT_OPT_IOMMU_NO="--no-io-mmu"
532TESTBOXSCRIPT_OPT_SPB="--spb"
533TESTBOXSCRIPT_OPT_SYSTEM_UUID="--system-uuid"
534TESTBOXSCRIPT_OPT_TEST_MANAGER="--test-manager"
535TESTBOXSCRIPT_OPT_SCRATCH_ROOT="--scratch-root"
536TESTBOXSCRIPT_OPT_BUILDS_PATH="--builds-path"
537TESTBOXSCRIPT_OPT_BUILDS_TYPE="--builds-server-type"
538TESTBOXSCRIPT_OPT_BUILDS_NAME="--builds-server-name"
539TESTBOXSCRIPT_OPT_BUILDS_SHARE="--builds-server-share"
540TESTBOXSCRIPT_OPT_BUILDS_USER="--builds-server-user"
541TESTBOXSCRIPT_OPT_BUILDS_PASSWD="--builds-server-passwd"
542TESTBOXSCRIPT_OPT_BUILDS_MOUNTOPT="--builds-server-mountopt"
543TESTBOXSCRIPT_OPT_PATH_TESTRSRC="--testrsrc-path"
544TESTBOXSCRIPT_OPT_TESTRSRC_TYPE="--testrsrc-server-type"
545TESTBOXSCRIPT_OPT_TESTRSRC_NAME="--testrsrc-server-name"
546TESTBOXSCRIPT_OPT_TESTRSRC_SHARE="--testrsrc-server-share"
547TESTBOXSCRIPT_OPT_TESTRSRC_USER="--testrsrc-server-user"
548TESTBOXSCRIPT_OPT_TESTRSRC_PASSWD="--testrsrc-server-passwd"
549TESTBOXSCRIPT_OPT_TESTRSRC_MOUNTOPT="--testrsrc-server-mountopt"
550
551# Defaults:
552TESTBOXSCRIPT_DEFAULT_DIR="there-is-no-default-for-this-value"
553TESTBOXSCRIPT_DEFAULT_PYTHON=""
554TESTBOXSCRIPT_DEFAULT_USER="vbox"
555TESTBOXSCRIPT_DEFAULT_HWVIRT=""
556TESTBOXSCRIPT_DEFAULT_IOMMU=""
557TESTBOXSCRIPT_DEFAULT_NESTED_PAGING=""
558TESTBOXSCRIPT_DEFAULT_SPB=""
559TESTBOXSCRIPT_DEFAULT_SYSTEM_UUID=""
560TESTBOXSCRIPT_DEFAULT_PATH_TESTRSRC=""
561TESTBOXSCRIPT_DEFAULT_TEST_MANAGER=""
562TESTBOXSCRIPT_DEFAULT_SCRATCH_ROOT=""
563TESTBOXSCRIPT_DEFAULT_BUILDS_PATH=""
564TESTBOXSCRIPT_DEFAULT_BUILDS_TYPE="cifs"
565TESTBOXSCRIPT_DEFAULT_BUILDS_NAME="vboxstor.de.oracle.com"
566TESTBOXSCRIPT_DEFAULT_BUILDS_SHARE="builds"
567TESTBOXSCRIPT_DEFAULT_BUILDS_USER="guestr"
568TESTBOXSCRIPT_DEFAULT_BUILDS_PASSWD="guestr"
569TESTBOXSCRIPT_DEFAULT_BUILDS_MOUNTOPT=""
570TESTBOXSCRIPT_DEFAULT_TESTRSRC_PATH=""
571TESTBOXSCRIPT_DEFAULT_TESTRSRC_TYPE="cifs"
572TESTBOXSCRIPT_DEFAULT_TESTRSRC_NAME="teststor.de.oracle.com"
573TESTBOXSCRIPT_DEFAULT_TESTRSRC_SHARE="testrsrc"
574TESTBOXSCRIPT_DEFAULT_TESTRSRC_USER="guestr"
575TESTBOXSCRIPT_DEFAULT_TESTRSRC_PASSWD="guestr"
576TESTBOXSCRIPT_DEFAULT_TESTRSRC_MOUNTOPT=""
577
578# Set config values to defaults.
579for var in ${TESTBOXSCRIPT_CFG_NAMES}
580do
581 defvar=TESTBOXSCRIPT_DEFAULT_${var}
582 eval TESTBOXSCRIPT_${var}="${!defvar}"
583done
584declare -a TESTBOXSCRIPT_ENVVARS
585
586# Load old config values (platform specific).
587os_load_config
588
589
590#
591# Config tweaks.
592#
593
594# The USER must be a non-empty value for the successful execution of this script.
595if [ -z "${TESTBOXSCRIPT_USER}" ]; then
596 TESTBOXSCRIPT_USER=${TESTBOXSCRIPT_DEFAULT_USER};
597fi;
598
599# The DIR must be according to the setup.sh location.
600TESTBOXSCRIPT_DIR=`dirname "${DIR}"`
601
602# Storage server replacement trick.
603if [ "${TESTBOXSCRIPT_BUILDS_NAME}" = "solserv.de.oracle.com" ]; then
604 TESTBOXSCRIPT_BUILDS_NAME=${TESTBOXSCRIPT_DEFAULT_BUILDS_NAME}
605fi
606if [ "${TESTBOXSCRIPT_TESTRSRC_NAME}" = "solserv.de.oracle.com" ]; then
607 TESTBOXSCRIPT_TESTRSRC_NAME=${TESTBOXSCRIPT_DEFAULT_TESTRSRC_NAME}
608fi
609
610
611#
612# Parse arguments.
613#
614while test $# -gt 0;
615do
616 case "$1" in
617 -h|--help)
618 echo "TestBox Script setup utility."
619 echo "";
620 echo "Usage: setup.sh [options]";
621 echo "";
622 echo "Options:";
623 echo " Later...";
624 exit 0;
625 ;;
626 -V|--version)
627 echo '$Revision: 103276 $'
628 exit 0;
629 ;;
630
631 --python) TESTBOXSCRIPT_PYTHON="$2"; shift;;
632 --test-manager) TESTBOXSCRIPT_TEST_MANAGER="$2"; shift;;
633 --scratch-root) TESTBOXSCRIPT_SCRATCH_ROOT="$2"; shift;;
634 --system-uuid) TESTBOXSCRIPT_SYSTEM_UUID="$2"; shift;;
635 --hwvirt) TESTBOXSCRIPT_HWVIRT="yes";;
636 --no-hwvirt) TESTBOXSCRIPT_HWVIRT="no";;
637 --nested-paging) TESTBOXSCRIPT_NESTED_PAGING="yes";;
638 --no-nested-paging) TESTBOXSCRIPT_NESTED_PAGING="no";;
639 --io-mmu) TESTBOXSCRIPT_IOMMU="yes";;
640 --no-io-mmu) TESTBOXSCRIPT_IOMMU="no";;
641 --builds-path) TESTBOXSCRIPT_BUILDS_PATH="$2"; shift;;
642 --builds-server-type) TESTBOXSCRIPT_BUILDS_TYPE="$2"; shift;;
643 --builds-server-name) TESTBOXSCRIPT_BUILDS_NAME="$2"; shift;;
644 --builds-server-share) TESTBOXSCRIPT_BUILDS_SHARE="$2"; shift;;
645 --builds-server-user) TESTBOXSCRIPT_BUILDS_USER="$2"; shift;;
646 --builds-server-passwd) TESTBOXSCRIPT_BUILDS_PASSWD="$2"; shift;;
647 --builds-server-mountopt) TESTBOXSCRIPT_BUILDS_MOUNTOPT="$2"; shift;;
648 --testrsrc-path) TESTBOXSCRIPT_TESTRSRC_PATH="$2"; shift;;
649 --testrsrc-server-type) TESTBOXSCRIPT_TESTRSRC_TYPE="$2"; shift;;
650 --testrsrc-server-name) TESTBOXSCRIPT_TESTRSRC_NAME="$2"; shift;;
651 --testrsrc-server-share) TESTBOXSCRIPT_TESTRSRC_SHARE="$2"; shift;;
652 --testrsrc-server-user) TESTBOXSCRIPT_TESTRSRC_USER="$2"; shift;;
653 --testrsrc-server-passwd) TESTBOXSCRIPT_TESTRSRC_PASSWD="$2"; shift;;
654 --testrsrc-server-mountopt) TESTBOXSCRIPT_TESTRSRC_MOUNTOPT="$2"; shift;;
655 --spb) TESTBOXSCRIPT_SPB="yes";;
656 *)
657 echo 'Syntax error: Unknown option:' "$1" >&2;
658 exit 1;
659 ;;
660 esac
661 shift;
662done
663
664
665#
666# Find usable python if not already specified.
667#
668if [ -z "${TESTBOXSCRIPT_PYTHON}" ]; then
669 set +e
670 MY_PYTHON_VER_TEST="\
671import sys;\
672x = (sys.version_info[0] == 3 and sys.version_info[1] >= 5) or (sys.version_info[0] == 2 and sys.version_info[1] >= 7);\
673sys.exit(not x);\
674";
675 for python in python3.{30..5} python3 python2.7 python2 python;
676 do
677 # python=`which ${python} 2> /dev/null`
678 python=`command -v ${python} 2> /dev/null`
679 if [ -n "${python}" -a -x "${python}" ]; then
680 if ${python} -c "${MY_PYTHON_VER_TEST}"; then
681 TESTBOXSCRIPT_PYTHON="${python}";
682 break;
683 fi
684 fi
685 done
686 set -e
687 test -n "${TESTBOXSCRIPT_PYTHON}";
688fi
689
690
691#
692# Do the job
693#
694set -e
695check_testboxscript_install;
696check_for_sudo;
697check_for_cifs;
698check_proxy_config;
699
700maybe_add_testboxscript_user;
701test_user;
702test_coredumps;
703test_unattended_updates_disabled;
704
705grant_user_testboxscript_write_access;
706
707os_disable_service;
708os_install_service;
709os_enable_service;
710
711#
712# That's all folks.
713#
714echo "done"
715os_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