#!/bin/bash #------------------------------------------------------------------------------ set -u # Usage: # bootstrap-linux.sh [<FQDN>] [<SDPBranch>] # The <SDPBranch> parameter is optional. SDPBranch determines # the branch of the SDP to test with, 'main' by default but can # be 'dev'. # Bootstraps a new Linux server with requirements Helix Installer testing. function msg () { echo -e "$*"; } function errmsg () { msg "\\nBootstrap Error: ${1:-Unknown Error}\\n"; ErrorCount+=1; } function bail () { msg "\\nError: ${1:-Unknown Error}\\n"; exit "${2:-1}"; } declare ThisScript="${0##*/}" declare Version=1.6.3 declare SDPBranch="${2:-main}" declare HelixInstallerArgs= declare FQDN="${1:-Unset}" declare -i ErrorCount=0 msg "Starting $ThisScript v$Version as $USER@${HOSTNAME%%.*} at $(date) as:\\n$ThisScript $*" # Currently, RHEL/CentOS and Ubuntu flavors are supported. # See release notes for more specific details of which versions are # currently supported. if [[ -r "/etc/redhat-release" ]]; then msg "Verified: Running Red Hat or similar Linux OS." elif [[ -r "/etc/lsb-release" ]]; then msg "Verified: Running Ubuntu or similar Linux OS." else msg "Warning: Running on unknown OS. Hoping for the best." fi [[ -d /hxdepots/reset ]] && \ bail "Directory /hxdepots/reset unexpectedly exists at bootstrap!" if [[ -d /hxdepots ]]; then msg "Using existing /hxdepots volume provisioned at bootstrap." else msg "Initializing /hxdepots dir." if ! sudo mkdir /hxdepots; then errmsg "MKDIR of /hxepots failed." fi fi [[ -d /depotdata/reset ]] && \ bail "Directory /depotdata/reset unexpectedly exists at bootstrap!" if [[ -d /depotdata ]]; then msg "Using existing /depotdata volume provisioned at bootstrap." else msg "Initializing /depotdata dir." if ! sudo mkdir /depotdata; then errmsg "MKDIR of /depotdata failed." fi fi # Some tests use the default /hxdepots mount point directory, while # others test the ability to configure an alternative, /depotdata. # In this bootstrap script, we ensure both are available. if [[ -d /tmp/test-reset ]]; then msg "Testing files from local workspace." if sudo cp -pr /tmp/test-reset /hxdepots/reset; then msg "Copied /tmp/test-reset to /hxdepots/reset" else errmsg "Failed to copy /tmp/test-reset to /hxdepots/reset" fi if sudo cp -pr /tmp/test-reset /depotdata/reset; then msg "Copied /tmp/test-reset to /depotdata/reset" else errmsg "Failed to copy /tmp/test-reset to /depotdata/reset" fi cd /hxdepots/reset || errmsg "Failed to do 'cd /hxdepots/reset'. Aborting." cd /depotdata/reset || errmsg "Failed to do 'cd /depotdata/reset'. Aborting." else bail "Expected test support dir /tmp/test-reset does not exist. Check the Vagrantfile for the setting 'machine.vm.synced_folder'." fi if [[ "$FQDN" != "Unset" ]]; then if [[ -n "$(command -v hostnamectl)" ]]; then msg "Setting hostname using: hostnamectl set-hostname $FQDN" hostnamectl set-hostname "$FQDN" else msg "Setting hostname in /etc/sysconfig/network and calling: hostname $FQDN" echo -e "NETWORKING=yes\\nHOSTNAME=$FQDN\\n" > /etc/sysconfig/network hostname "$FQDN" fi fi ### WORKAROUND for incompatibility with SELinux in enforcing mode on ### RHEL/CentOS 8. ### See: https://swarm.workshop.perforce.com/jobs/SDP-562 ### See: https://swarm.workshop.perforce.com/jobs/HI-54 if [[ -r "/etc/redhat-release" ]]; then if grep -qi "Linux release 8" /etc/redhat-release; then msg "Disabling SELinux on host ${HOSTNAME%%.*}." if setenforce 0; then msg "SELinux disabled for this session." else errmsg "Failed to disable SELinux for this session." fi if sed 's:^SELINUX=enforcing:SELINUX=permissive:g' /etc/selinux/config > /etc/selinux/config.new; then if mv -f /etc/selinux/config.new /etc/selinux/config; then msg "SELinux permanently disabled." else errmsg "Failed to disable SELinux permanently." fi else errmsg "Failed to run 'sed' in /etc/selinux/config file." fi fi fi HelixInstallerVersion=$(grep '^declare Version=' reset_sdp.sh) HelixInstallerVersion=${HelixInstallerVersion#declare } msg "Helix Installer version: $HelixInstallerVersion" HelixInstallerCmd="./reset_sdp.sh" HelixInstallerArgs="-fast -b $SDPBranch -M" #HelixInstallerArgs="-b $SDPBranch -M" msg "Calling Helix Installer: $HelixInstallerCmd $HelixInstallerArgs" #shellcheck disable=SC2086,SC2024 if ! sudo $HelixInstallerCmd $HelixInstallerArgs > log.reset_sdp.txt 2>&1; then errmsg "Sudo command failed: $HelixInstallerCmd $HelixInstallerArgs" fi exit "$ErrorCount"
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#14 | 27427 | C. Thomas Tyler |
Released SDP 2021.2.27425 (2021/02/09). Copy Up using 'p4 copy -r -b perforce_software-helix-installer-dev'. |
||
#13 | 26975 | C. Thomas Tyler | Released HelixInstaller 2020.2.26973 (2020/12/01). | ||
#12 | 26831 | C. Thomas Tyler | Released HelixInstaller/MultiArch/2020.1/26829 (2020/10/07). | ||
#11 | 26793 | C. Thomas Tyler | Released HelixInstaller/MultiArch/2020.1/26784 (2020/09/25). | ||
#10 | 26578 | C. Thomas Tyler | Released Helix Installer 2020.1.26576 (2020/06/17). | ||
#9 | 26031 | C. Thomas Tyler | Released Helix Installer 2019.4.26026 (2019/08/22). | ||
#8 | 26008 | C. Thomas Tyler | Released HelixInstaller 2019.4.26006 (2019/08/20). | ||
#7 | 25999 | C. Thomas Tyler | Released HelixInstaller 2019.4.25995 (2019/08/20). | ||
#6 | 25900 | C. Thomas Tyler | Released HelixInstaller 2019.3.25890 (2019/07/24). | ||
#5 | 25822 | C. Thomas Tyler | Released HelixInstaller/MultiArch/2019.3/25820 (2019/07/11). | ||
#4 | 25725 | C. Thomas Tyler | Released HelixInstaller/MultiArch/2019.2/25723 (2019/06/19). | ||
#3 | 25166 | C. Thomas Tyler | Released Helix Installer 2019.1.25164 (2019/02/22). | ||
#2 | 24914 | C. Thomas Tyler | Released HelixInstaller 2018.2.24912. | ||
#1 | 24865 | C. Thomas Tyler | Released HelixInstaller v2018.2.24862. | ||
//guest/perforce_software/helix-installer/dev/test/bootstrap-linux.sh | |||||
#1 | 24860 | C. Thomas Tyler |
Added basic Vagrant test suite for Helix Installer for testing on CentOS 6.10. |