#!/bin/bash set -u # This script requires outbound internet access. Depending on your environment, # it may also require HTTPS_PROXY to be defined, or may not work at all. # Usage: get_latest_exes.sh [<version>] [<exe1>,<exe2>,...] # # Typical Usage (if SDP tar extracted to /hxdepots/sdp) is # with no arguments, e.g.: # cd /hxdepots/sdp/exes # ./get_latest_exes.sh # # If no parameters are specified, the default version and list of # executables to get is coded below. Note that the list of exes # is comma-delimited. # # Sample usage specifying version: # ./get_latest_exes.sh r20.1 # # Sample getting r19.2 and skipping the proxy executable, p4p: # cd /hxdepots/sdp/exes # ./get_latest_exes.sh r19.2 p4,p4d,p4broker # # Note: Only supported release are available from the Perforce # FTP server. function msg () { echo -e "$*"; } function errmsg () { msg "\\nError: ${1:-Unknown Error}\\n"; ErrorCount+=1; } function warnmsg () { msg "\\nWarning: ${1:-Unknown Warning}\\n"; WarningCount+=1; } function bail () { errmsg "${1:-Unkonwn Error}"; exit "${2:-1}"; } declare DefaultPerforceHelixVersion=r20.1 declare DefaultExeList="p4 p4d p4broker p4p" declare ThisScript=${0##*/} declare Version=1.0.2 declare -i ErrorCount=0 declare -i WarningCount=0 declare -i RetryCount=0 declare -i RetryMax=2 declare -i RetryDelay=2 declare -i RetryOK=0 declare PerforceHelixVersion="${1:-$DefaultPerforceHelixVersion}" declare ExeList="${2:-$DefaultExeList}" declare Platform=linux26x86_64 declare PerforceFTPBaseURL="https://ftp.perforce.com/perforce" declare ExeURL= declare Cmd= msg "\\nStarted $ThisScript v$Version as $USER@${HOSTNAME%%.*} at $(date)." for exe in $(echo "$ExeList"|tr ',' ' '); do msg "\\nGetting $exe ..." ExeURL="${PerforceFTPBaseURL}/${PerforceHelixVersion}/bin.${Platform}/$exe" if [[ -x "$exe" ]]; then msg "Old version of $exe: $("./$exe" -V | grep Rev)" rm -f "$exe" fi Cmd="curl -s -k -O $ExeURL" msg "Running: $Cmd" if $Cmd; then chmod +x "$exe" msg "New version of $exe: $("./$exe" -V | grep Rev)" else warnmsg "Failed to download $exe with this URL: $ExeURL\\nRetrying ..." RetryCount+=0 while [[ "$RetryCount" -le "$RetryMax" ]]; do RetryCount+=1 sleep "$RetryDelay" msg "Retry $RetryCount of command: $Cmd" if $Cmd; then chmod +x "$exe" msg "New version of $exe: $("./$exe" -V | grep Rev)" RetryOK=1 break else warnmsg "Retry $RetryCount failed again to download $exe with this URL: $ExeURL" fi done if [[ "$RetryOK" -eq 0 ]]; then errmsg "Failed to download $exe with this URL: $ExeURL" rm -f "$exe" fi fi done if [[ "$ErrorCount" -eq 0 ]]; then msg "\\nDownloading of exes completed OK." else errmsg "\\There were $ErrorCount errors attempting to download exes." fi exit "$ErrorCount"
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#6 | 27022 | C. Thomas Tyler | Changed 'exes' to 'helix_binaries' in folder and script name, per review. | ||
#5 | 27003 | Robert Cowham | Work around timing issues for tests. | ||
#4 | 27000 | C. Thomas Tyler |
Tweak so 'curl' command uses '-s' silent mode for normal operation, and drops '-s' only on retry attempts in event of an initial failure. |
||
#3 | 26998 | C. Thomas Tyler | Fixed issue with existing files causing curl command to fail. | ||
#2 | 26993 | C. Thomas Tyler | Added retry logic to get_latest_exes.sh. | ||
#1 | 26982 | C. Thomas Tyler |
mkdirs.sh v4.1.0: * Accounted for directory structure change of Maintenance to Unsupported. * Added standard command line processing with '-h' and '-man' doc flags, and other flags (all documented). * Added in-code docs and updated AsciiDoc. * Enhanced '-test' mode to simulate /hx* mounts. * Enhanced preflight testing, and fixed '-test' mode installs. * Added support for installing to an alternate root directory. * Added '-s <ServerID>' option to override REPLICA_ID. * Added '-S <TargetServerID>' used for replicas of edge servers. * Added '-t <server_type>' option to override SERVER_TYPE. * Added '-M' option to override mount points. * Added '-f' fast option to skip big chown/chmod commands, and moved those commands near the end as well. verify_sdp.sh v5.9.0: * Added check for /p4/Version file, and checked that other legacy SDP methods of checking version * Added sanity check for crontab. * Added 'test skip' mechanism to skip certain tests: - crontab: Skip crontab check. Use this if you do not expect crontab to be configured, perhaps if a different scheduler is used. - license: Skip license related checks. - version: Skip version checks. - excess: Skip checks for excess copies of p4d/p4p/p4broker in PATH. * Added VERIFY_SDP_SKIP_TEST_LIST setting ton instance_vars.template, to define a standard way to have verify_sdp.sh always skip certain tests for a site. * Extended '-online' checks to check for bogus P4MASTERPORT, a common config error. Update test_SDP.py: * Adjusted test suite to account for various changes in mkdirs.sh. * Added 'dir' parameter to run_cmd() and sudo_cmd(), to run a command from a specified directory (as required to test new mkdirs.sh) * Added check_links() similar to existing check_dirs() function. === Upgrade Process Changes === Made /p4/common/bin/p4d/p4/p4broker/p4p shell script rather than binary. This changes the way SDP new binaries are staged for upgrade. For safety, exes are now staged to a director outside the PATH, the /p4/sdp/exes folder. A new 'get_latest_exes.sh' script simplifies the task of pulling executables from the Perforce FTP server. This can be used 'as is' for environments with outbound internet access, and is useful in any case to describe now to acquire binaries. This addresses an issue where a p4d binary staged for a future upgrade might be called before the actual upgrade is performed. upgrade.sh v4.0.0: * All preflight checks are now done first. Added '-p' to abort after preflight. * Added '-n' to show what would be done before anything is executed. * Minimalist logic to start/stop only servers that are upgrade, and apply upgrades only as needed. * Staging of exes for upgrade is now separate from /p4/common/bin * Improved in-code docs, added '-h' and '-man' options. * Retained pre/post P4D 2019.1 upgrade logic. |