setup.sh revision cf22150eaeeb72431bf1cf65c309a431454fb22b
# $Id$
## @file
# VirtualBox Validation Kit - TestBoxScript Service Setup on Unixy platforms.
#
#
# Copyright (C) 2006-2014 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
# The contents of this file may alternatively be used under the terms
# of the Common Development and Distribution License Version 1.0
# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
# VirtualBox OSE distribution, in which case the provisions of the
# CDDL are applicable instead of those of the GPL.
#
# You may elect to license modified versions of this file under the
# terms and conditions of either the GPL or the CDDL or both.
#
#
# !WARNING! Running the whole script in exit-on-failure mode.
#
# Note! Looking at the ash sources, it seems flags will be saved and restored
# when calling functions. That's comforting.
#
set -e
#set -x # debug only, disable!
##
# Get the host OS name, returning it in RETVAL.
#
;;
;;
;;
;;
;;
;;
;;
;;
;;
;;
*)
exit 1
;;
esac
return 0;
}
##
#
if [ "${HOST_OS}" = "solaris" ]; then
else
fi
RETVAL='amd64'
;;
RETVAL='x86'
;;
RETVAL='sparc32'
;;
RETVAL='sparc64'
;;
s390)
RETVAL='s390'
;;
RETVAL='s390x'
;;
RETVAL='ppc32'
;;
RETVAL='ppc64'
;;
RETVAL='mips32'
;;
RETVAL='mips64'
;;
ia64)
RETVAL='ia64'
;;
RETVAL='hppa32'
;;
RETVAL='hppa64'
;;
RETVAL='arm'
;;
RETVAL='alpha'
;;
*)
exit 1
;;
esac
return 0;
}
##
# Loads config values from the current installation.
#
echo "os_load_config is not implemented" 2>&1
exit 1
}
##
# Installs, configures and starts the service.
#
echo "os_install_service is not implemented" 2>&1
exit 1
}
##
# Enables (starts) the service.
echo "os_enable_service is not implemented" 2>&1
return 0;
}
##
# Disables (stops) the service.
echo "os_disable_service is not implemented" 2>&1
return 0;
}
##
# Adds the testbox user
#
echo "os_add_user is not implemented" 2>&1
exit 1
}
##
# Prints a final message after successful script execution.
# This can contain additional instructions which needs to be carried out
# manually or similar.
return 0;
}
##
# Checks the installation, verifying that files are there and scripts work fine.
#
# Presence
test -r "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript.py"
test -r "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript_real.py"
test -r "${TESTBOXSCRIPT_DIR}/testboxscript/linux/testboxscript-service.sh" -o "${HOST_OS}" != "linux"
test -r "${TESTBOXSCRIPT_DIR}/${HOST_OS}/${HOST_ARCH}/TestBoxHelper"
# Zip file may be missing the x bits, so set them.
chmod a+x \
"${TESTBOXSCRIPT_DIR}/${HOST_OS}/${HOST_ARCH}/TestBoxHelper"
# Check that the scripts work.
set +e
"${TESTBOXSCRIPT_PYTHON}" "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript.py" --version > /dev/null
if [ $? -ne 2 ]; then
echo "$0: error: testboxscript.py didn't respons correctly to the --version option."
exit 1;
fi
"${TESTBOXSCRIPT_PYTHON}" "${TESTBOXSCRIPT_DIR}/testboxscript/testboxscript_real.py" --version > /dev/null
if [ $? -ne 2 ]; then
echo "$0: error: testboxscript.py didn't respons correctly to the --version option."
exit 1;
fi
set -e
return 0;
}
##
# Check that sudo is installed.
#
test -f "${MY_ETC_SUDOERS}"
}
##
# Check that sudo is installed.
#
return 0;
}
##
# Checks if the testboxscript_user exists.
return $?;
}
##
# hushes up the root login.
# This is a solaris hook.
return 0;
}
##
# Adds the testbox user and make sure it has unrestricted sudo access.
if ! does_testboxscript_user_exist; then
os_add_user "${TESTBOXSCRIPT_USER}"
fi
SUDOERS_LINE="${TESTBOXSCRIPT_USER} ALL=(ALL) NOPASSWD: ALL"
fi
}
##
# Test the user.
#
# sudo 1.7.0 adds the -n option.
if [ "${MY_TMP}" != "old" ]; then
echo "Warning: If sudo starts complaining about not having a tty,"
else
echo "Warning: You've got an old sudo installed. If it starts"
echo " complaining about not having a tty, disable the"
fi
}
##
# Grants the user write access to the testboxscript files so it can perform
# upgrades.
#
chown -R "${TESTBOXSCRIPT_USER}" "${TESTBOXSCRIPT_DIR}"
}
##
# Check the proxy setup.
#
if [ -n "${http_proxy}" -o -n "${ftp_proxy}" ]; then
if [ -z "${no_proxy}" ]; then
echo "Error: Env.vars. http_proxy/ftp_proxy without no_proxy is going to break upgrade among other things."
exit 1
fi
fi
}
#
#
# main()
#
#
#
# Get our bearings and include the host specific code.
#
. "${DIR}/${HOST_OS}/setup-routines.sh"
#
# Config.
#
TESTBOXSCRIPT_BUILDS_TYPE="cifs"
TESTBOXSCRIPT_BUILDS_SHARE="builds"
TESTBOXSCRIPT_BUILDS_USER="guestr"
TESTBOXSCRIPT_BUILDS_PASSWD="guestr"
TESTBOXSCRIPT_TESTRSRC_TYPE="cifs"
TESTBOXSCRIPT_TESTRSRC_SHARE="testrsrc"
TESTBOXSCRIPT_TESTRSRC_USER="guestr"
TESTBOXSCRIPT_TESTRSRC_PASSWD="guestr"
# Load old config values (platform specific).
# Set defaults.
if [ -z "${TESTBOXSCRIPT_USER}" ]; then
fi;
#
# Parse arguments.
#
while test $# -gt 0;
do
case "$1" in
-h|--help)
echo "TestBox Script setup utility."
echo "";
echo "Usage: setup.sh [options]";
echo "";
echo "Options:";
echo " Later...";
exit 0;
;;
-V|--version)
echo '$Revision$'
exit 0;
;;
*)
echo 'Syntax error: Unknown option:' "$1" >&2;
exit 1;
;;
esac
shift;
done
#
# Find usable python if not already specified.
#
if [ -z "${TESTBOXSCRIPT_PYTHON}" ]; then
set +e
import sys;\
x = sys.version_info[0] == 2 and (sys.version_info[1] >= 6 or (sys.version_info[1] == 5 and sys.version_info[2] >= 1));\
sys.exit(not x);\
";
do
if [ -n "${python}" -a -x "${python}" ]; then
if ${python} -c "${MY_PYTHON_VER_TEST}"; then
TESTBOXSCRIPT_PYTHON="${python}";
break;
fi
fi
done
set -e
test -n "${TESTBOXSCRIPT_PYTHON}";
fi
#
# Do the job
#
set -e
#
# That's all folks.
#
echo "done"