bootstrap-linux.sh #13

  • //
  • guest/
  • perforce_software/
  • helix-installer/
  • dev/
  • test/
  • bootstrap-linux.sh
  • View
  • Commits
  • Open Download .zip Download (3 KB)
#!/bin/bash
set -u

# Usage: 
# bootstrap-linux.sh [<SDPBranch> [<HelixInstallerBranch>]]
# The <SDPBranch> parameter (must be first argument) and
# <HelixInstallerBranch> parameter (must be second argument)
# are optional.  SDPBranch determines the branch of the
# SDP to test with, 'main' by default but can be 'dev'.  The
# HelixInstallerBranch is auto-detected based on the current
# directory if possible, otherwise 'dev' by default, but can
# be 'main'.

# Bootstraps a new Linux server with requirements Helix Installer testing.

function msg () { echo -e "$*"; }
function bail () { msg "\\nError: ${1:-Unknown Error}\\n"; exit "${2:-1}"; }

declare Version=1.4.0
declare SDPBranch=${1:-main}
declare HelixInstallerBranch=${2:-UNSET}
declare HelixInstallerArgs=

msg "Starting ${0##*/} v$Version at $(date)."

if [[ "$HelixInstallerBranch" == "UNSET" ]]; then
   if [[ "$PWD" == *"/dev/"* ]]; then
      HelixInstallerBranch="dev"
      msg "Helix Installer branch detected as to '$HelixInstallerBranch'."
   elif [[ "$PWD" == *"/main/"* ]]; then
      HelixInstallerBranch="main"
      msg "Helix Installer branch detected as to '$HelixInstallerBranch'."
   else
      HelixInstallerBranch="dev"
      msg "Helix Installer branch defaulted to '$HelixInstallerBranch'."
   fi
fi

# 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

if [[ -d /hxdepots/test-reset ]]; then
   [[ -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."
      sudo mkdir /hxdepots
   fi

   msg "Testing files from local dev workspace."
   sudo cp -pr /hxdepots/test-reset /hxdepots/reset
   cd /hxdepots/reset || bail "Failed to do 'cd /hxdepots/reset'. Aborting."
else
   msg "Acquiring reset_sdp.sh from Workshop."
   sudo mkdir -p /hxdepots/reset
   cd /hxdepots/reset || bail "Failed to do 'cd /hxdepots/reset'. Aborting."
   curl -k -s -O "https://swarm.workshop.perforce.com/downloads/guest/perforce_software/helix-installer/$HelixInstallerBranch/src/reset_sdp.sh"
   sudo chmod +x reset_sdp.sh
fi

HelixInstallerVersion=$(grep '^declare Version=' reset_sdp.sh)
HelixInstallerVersion=${HelixInstallerVersion#declare }
msg "Helix Installer version: $HelixInstallerVersion"

HelixInstallerCmd="./reset_sdp.sh"
HelixInstallerArgs="-fast -b $SDPBranch -i $HelixInstallerBranch"
#HelixInstallerArgs="-b $SDPBranch -i $HelixInstallerBranch"
msg "Calling Helix Installer: $HelixInstallerCmd"
#shellcheck disable=SC2086,SC2024
sudo $HelixInstallerCmd $HelixInstallerArgs > log.reset_sdp.txt 2>&1
# Change User Description Committed
#25 27288 C. Thomas Tyler Removed old Vagrant Test suite.
#24 26965 C. Thomas Tyler Fixed typo in Redhat-like OS detection.
#23 26922 C. Thomas Tyler Narrowed workworkaround for CentOS 8 SELinux enforcing mode issue.

The first iteration of this workaround disabled SELinux on all
platforms. This disables SELinux on CentOS 8 only.  This can be
undone done when fixes for SDP-562 and/or HI-54 are released.
#22 26829 C. Thomas Tyler Disabled SELinux to fix test failure on CentOS 8.
#21 26799 C. Thomas Tyler Added '-M' multi-run option to disable the 'run once' safety feature,
to simplify multiple tests.
#20 26795 C. Thomas Tyler Fixed test suite issues:
* Shell environment for test suite regression fixed.
* Vagrantfile referred to SDP rather than Helix Installer (old
Copy/Paste issue, harmless but wrong).
* Updated baseline Vagrant image for CentOS6 box.
* Fixed issue with setting hostname on CentOS6 by making hostname   
a paramter to the bootstrap script, and adjusting the bootstrap
script.

Along with this change, added missing hostmanager plugin on test
machine.
#19 26784 C. Thomas Tyler reset_sdp.sh v3.17.0:

Made /hx* mount points configurable in settings.cfg, and
updated documentation accordingly.

Added support for configuring /hxmetadata1 and /hxmetadata2
with different values.

Added test coverage for changing /hxdepots from the default.

Enhanced test suite.

TEST FAIL NOTE: As of this change, tests are succeeding on all
platforms except CentOS 6. Failures are in the test suite
infrastructure, not related to this change.
#18 26575 C. Thomas Tyler Switched back to SDP main branch.
#17 26567 C. Thomas Tyler Changed default test branch from main to dev.
#16 26023 C. Thomas Tyler Removed obsolete HelixInstallerBranch refs due to new usage
of machine.vm.synced_folder setting in Vagrantfile.
#15 26005 C. Thomas Tyler Back to -fast.
#14 25994 C. Thomas Tyler Change back to skipping '-fast'.
#13 25990 C. Thomas Tyler Refined test mechanism so local workspace dirs aren't
modified by test operations.

Changed logfile name to make it easier to find with
prefix rather than suffix.
#12 25987 C. Thomas Tyler Enhanced test suite to mount the local dir with checked out
files into the test VMs, rather than using 'curl' from a
URL which can only get submitted revisions of reset_sdp.sh.
#11 25882 C. Thomas Tyler Configured for a comprehensive test; removed '-fast'.
#10 25820 C. Thomas Tyler Enhanced bootstrap test to call Heilx Installer with '-i' to
enable testing of scenarios involving newly added files.
#9 25754 C. Thomas Tyler Helix Installer test suite changes:

Added new test outcome 'SKIP' to supplement 'PASS'/'FAIL'.

Added logic to not bother running P4Perl/P4Python tests if '-fast'
is specified in the bootstrap script, as in that case we don't
expect those to have been installed.

Changed bootstrap method back to '-fast' for now.
#8 25727 C. Thomas Tyler Removed '-fast' flag to Helix Installer reset_sdp.sh script for
comprehensive (but slower) testing.
#7 25675 C. Thomas Tyler Default changed from fast to comprehensive test.
#6 25674 C. Thomas Tyler Code optional bypass of Perl/Python compiles to make it faster.
#5 25670 C. Thomas Tyler Gave each box its own IP.
Added Ubuntu 16.10 and Ubuntu 18.10 to boxes to test.
Adjusted bootstrap script to support Ubuntu 16.10 and 18.10.
#4 25163 C. Thomas Tyler Corrected comment.
#3 24879 C. Thomas Tyler Made compliant with shellcheck.
Added version id and message to display it.
Addded 'sudo' for 'perforce' user.
#2 24870 C. Thomas Tyler Various test environment tweaks:
* Adjusted host name to bos-helix-01 to be a simplified variant
  of the Battle School Lab.
* Changed defalt SDP branch to pull to auto-detected, using
         SDP 'dev' branch if in the Helix Installer dev branch, and
  SDP 'main' branch if in the Helix Installer main branch.
* Added host aliases in /etc/hosts.
* Added niceties in ~perforce/.bashrc file.
#1 24860 C. Thomas Tyler Added basic Vagrant test suite for Helix Installer for testing
on CentOS 6.10.