#!/bin/bash #============================================================================== # Copyright and license info is available in the LICENSE file included with # this package, and also available online: # https://swarm.workshop.perforce.com/view/guest/perforce_software/helix-installer/main/LICENSE #------------------------------------------------------------------------------ #============================================================================== # Declarations set -u declare Version=2.8.6 # The tar file specified here is used if the '-t' flag is used to # specify installing from a tar file, which is good for getting a known, # fixed version of the SDP to work with. The default install method # uses Helix DVCS features to get the very latest code from a branch # ('main' by default, but '-b dev' could be specified as well) by doing # a 'p4 clone' command. # Note that test mode implies the sdp is in a mapped local directory /sdp declare SDPTar=sdp.Unix.2016.1.20559.tgz declare SDPURL=https://swarm.workshop.perforce.com/projects/perforce-software-sdp/download/downloads/$SDPTar declare SDPInstallMethod=DVCS declare SDPInstallBranch=Unset declare WorkshopPort=workshop.perforce.com:1666 declare WorkshopUser=ftp # User with no password. declare WorkshopRemote= declare HelixInstallerBaseURL=http://swarm.workshop.perforce.com/download/guest/perforce_software/helix-installer/main declare Depotdata=/depotdata declare ResetHome=$Depotdata/reset declare Metadata=/metadata declare Logs=/logs declare SDPHome=$Depotdata/sdp # If using this Helix Installer to bootsrap a production installation, # please do NOT be tempted to keep this password. Replace it with your # own. And after bootsrapping, be sure to remove the Helix Installer, # as this software has no business being on a production machine. declare Password=F@stSCM! declare ExesDir=$Depotdata/exes declare DownloadsDir=$Depotdata/downloads declare -i BlastDownloadsAndExes=0 declare -i PullFromWebAsNeeded=1 declare -i LoadSampleDepot=1 declare -i TestMode=0 declare PreserveDirList=Unset declare P4ExeRel=r16.1 declare P4DExeRel=$P4ExeRel declare P4PExeRel=$P4ExeRel declare P4BrokerExeRel=$P4ExeRel declare P4SwarmRel=r16.1 declare P4Rel=r16.1 declare RunUser=perforce declare RunGroup= declare SampleDepotTar= declare Arch=x86_64 declare ApiArch= declare ThisArch=$(uname -m) declare ThisHost=$(hostname -s) declare ThisOS=$(uname -s) declare ThisUser=$(whoami) declare RunArch=x86_64 declare CBIN=/p4/common/bin declare CCFG=/p4/common/config declare SDPSetupDir=$SDPHome/Server/Unix/setup declare SDPConfigDir=$SDPHome/Server/Unix/p4/common/config declare ThisScript=${0##*/} declare SDPInstances="1" #------------------------------------------------------------------------------ # Function: usage (required function) # # Input: # $1 - style, either -h (for short form) or -man (for man-page like format). #------------------------------------------------------------------------------ function usage { declare style=${1:--h} echo "USAGE for $ThisScript v$Version: $ThisScript [-B|-local] [-test] [-fast] [-no_ssl] [-no_sd] [-b <branch>|-t <tarfile>] [-p <dir1>[,<dir2>,...]>] [-D] or $ThisScript [-h|-man] " if [[ $style == -man ]]; then echo -e " SAFETY NOTICE: This script SHOULD NEVER EXIST on a Production Perforce server. DESCRIPTION: This script simplifies the process of testing an SDP installation, repetitively blasting all process by the 'perforce' user and resetting the SDP from the ground up, blasting typical SDP folders each time. It is helpful when bootstrapping a demo server with a sample data set, complete with broker, and optionally Perl/P4Perl and Python/P4Python. PLATFORM SUPPORT: This works on Red Hat Linux, CentOS, and Mac OSX (Mavericks or Yosemitie) platforms. It works on CentOS 6.4 and 6.5 and likely on other Linux derivatives with little or no modification. It currently supports only the bin.linux26x86_64 (Linux) and bin.darwin90x86_64 (Mac OSX/Darwin) architectures. REQUIREMENTS: Development utilities such as 'make' and the 'gcc' compiler must be installed and available in the PATH (unless running with '-fast'). The 'wget' utility must be installed and available in the PATH (unless running with '-local'). Mac OSX users: 'wget' is not installed with Mac OSX by default, at least not as of OSX 10.11/El Capitan. It can be acquired and compiled. For example, see: http://osxdaily.com/2012/05/22/install-wget-mac-os-x/ OPTIONS: -B Specify '-B' to blast base SDP dirs, for a clean start. Otherwise, downloaded components from earlier runs will be used (which should be fine if they were run recently). The '-B' and '-local' arguments are mutually exclusive. The '-test' argument sets '-local'. -local By default, various files and executables are downloaded from the Perforce Workshop or the Perforce FTP server as needed. With '-local', any missing files are treated as an error condition. The '-B' and '-local' arguments are mutually exclusive. -fast Specify '-fast' to skip installation of Perl auxiliary things like Perl, Python, P4Perl, P4Python. The '-fast' argument changes the check for GCC/G++ from a fatal error to a warning message. -test For test mode - assumes SDP is mounted in /sdp with executables in /sdp/test/exes. -no_ssl By default, the Perforce server is setup SSL-enabled. Specify '-no_ssl' to avoid using SSL feature. -no_sd By default, the Perforce Sample Depot data set is loaded. Specify '-no_sd' to skip loading the Sample Depot. -p <dir1>[,<dir2>,...]>] Specify a comma-delimited list of directories under /p4/common to preserve that would otherwise be removed. Directories must be specified as paths relative to /p4/common, and cannot contain spaces. For example, the value '-p config,bin/triggers' would preserve the /p4/common/config and /p4/common/bin/triggers directories. Directories specified are moved aside to a temporary working area before the SDP folders are removed. After installation, they are moved back via an 'rsync' command with no '--delete' option. This means any files that overlap with the stock install are replaced by ones that originally existed, but non-overlapping files are not removed. This is intended to be useful for developing test suites that install server under /p4/common/bin, e.g. Component Based Development scripts which install under /p4/common/bin/cbd would use '-p bin/cbd'. -b <branch> The default SDP install method is to clone the SDP from the main branch in The Workshop ($WorkshopPort). Specify '-b' to use a different branch, e.g. 'dev'. -t <tarfile> Specify a tarfile to use, e.g. '-t sdp.Unix.2016.1.20028.tgz', or use the special value '-t default' to use the default SDP tarfile, $SDPTar The specified tar file must exist here: https://swarm.workshop.perforce.com/projects/perforce-software-sdp/files/downloads If '-t <tarfile>' is not specified, default install method is used instead, which is to clone the SDP main branch from The Workshop ($WorkshopPort). Use '-t' to get a known version of the SDP for testing. Avoid '-t' to test with the very latest SDP from a given branch (see '-b' above for more info), even if the latest has not yet been packaged into a distribution tar file. -D Set extreme debugging verbosity. HELP OPTIONS: -h Display short help message -man Display man-style help message EXAMPLES: Typical usage: sudo bash # Because you need to run as root. cd /where/this/script/is ./reset_sdp.sh -B 2>&1 | tee /tmp/log.reset_sdp " fi exit 1 } #------------------------------------------------------------------------------ # Function bail(). # Sample Usage: # bail "Missing something important. Aborting." # bail "Aborting with exit code 3." 3 function bail () { echo -e "\nError: ${1:-Unknown Error}\n"; exit ${2:-1}; } #------------------------------------------------------------------------------ # Functions. The runCmd() function is similar to functions defined in SDP core # libraries, but we need to duplicate them here since this script runs before # the SDP is available on the machine (and we want no dependencies for this # script. function runCmd { cmd=${1:-echo Testing runCmd} desc=${2:-""} [[ -n "$desc" ]] && echo $desc echo Running: $cmd $cmd return $? } #============================================================================== # Command Line Processing declare -i NoOp=0 declare -i shiftArgs=0 declare -i InstallAuxFiles=1 declare -i UseSSL=1 declare TmpFile=/tmp/tmp.reset_sdp.$$.$RANDOM declare TmpDir=/tmp/tmp.dir.reset_sdp.$$.$RANDOM set +u while [[ $# -gt 0 ]]; do case $1 in (-B) BlastDownloadsAndExes=1;; (-local) PullFromWebAsNeeded=0;; (-fast) InstallAuxFiles=0;; (-test) TestMode=1;; (-no_ssl) UseSSL=0;; (-no_sd) LoadSampleDepot=0;; (-t) SDPTar=$2; SDPInstallMethod=Tarfile; shiftArgs=1;; (-b) SDPInstallBranch=$2; shiftArgs=1;; (-p) PreserveDirList=$2; shiftArgs=1;; (-h) usage -h;; (-man) usage -man;; (-D) set -x;; # Debug; use 'set -x' mode. (*) bail "Usage Error: Unknown arg ($1).";; esac # Shift (modify $#) the appropriate number of times. shift; while [[ $shiftArgs -gt 0 ]]; do [[ $# -eq 0 ]] && bail "Usage Error: Wrong number of args or flags to args." shiftArgs=$shiftArgs-1 shift done done set -u #------------------------------------------------------------------------------ # Command Line Validation if [[ $ThisUser != root ]]; then bail "Run as root, not $ThisUser." else echo Verified: Running as user $RunUser. fi [[ $BlastDownloadsAndExes -eq 1 && $PullFromWebAsNeeded -eq 0 ]] && \ bail "The '-B' and '-local' arguments are mutually exclusive." [[ $SDPInstallBranch != Unset && $SDPInstallMethod == Tarfile ]] && \ bail "The '-b <branch>' and '-t <tarfile>' arguments are mutually exclusive." [[ $SDPInstallBranch == Unset ]] && SDPInstallBranch=main #------------------------------------------------------------------------------ echo "Started $ThisScript v$Version at $(date)." # Digital asset acquisition and availability checks. [[ ! -d $Depotdata ]] && runCmd "/bin/mkdir -p $Depotdata" cd $Depotdata || bail "Could not cd to [$Depotdata]." echo Verifying dependencies. if [[ -z "$(which gcc 2>/dev/null)" || -z "$(which g++ 2>/dev/null)" ]]; then if [[ $InstallAuxFiles -eq 1 ]]; then bail "No gcc found in the path. You may need to install it. Please\n check that the gcc and gcc-c++ packages are\n installed, e.g. with:\n\tyum install -y gcc gcc-c++\n\n" else echo -e "Warning: No gcc found in the path. You may need to install it. Please\n check that the gcc and gcc-c++ packages are\n installed, e.g. with:\n\tyum install -y gcc gcc-c++\nIgnoring missing gcc/g++ due to '-fast'.\n" fi else echo "Verified: gcc and g++ are available and in the PATH." fi if [[ $PullFromWebAsNeeded -eq 1 ]]; then [[ -z "$(which wget 2>/dev/null)" ]] && \ bail "No 'wget' found in the path. You may need to install it. Please check that the wget packages is installed, e.g. with:\n\tyum install -y wget\n\n" fi [[ -z "$(which su 2>/dev/null)" ]] && \ bail "No 'su' found in the path. You may need to install it or add it to the path for the root user.\n\n" if [[ $ThisArch == $RunArch ]]; then echo Verified: Running on a supported architecture [$ThisArch]. ApiArch=UNDEFINED_API_ARCH case $ThisOS in (Darwin) ApiArch="darwin90x86_64" RunGroup=staff SampleDepotTar=sampledepot.mac.tar.gz ;; (Linux) ApiArch="linux26x86_64" RunGroup=perforce SampleDepotTar=sampledepot.tar.gz ;; (*) bail "Unsupported value returned by 'uname -m': $ThisOS. Aborting.";; esac else bail "Running on architecture $ThisArch. Run this only on hosts with '$RunArch' architecture. Aborting." fi # In this block, we just check that directories specified to be preserved # with the '-p' flag actually exist, in which case we abort before further # processing. if [[ $PreserveDirList != Unset ]]; then for d in $(echo $PreserveDirList|tr ',' ' '); do preserveDir=$Depotdata/p4/common/$d if [[ -d "$preserveDir" ]]; then parentDir=$(dirname $TmpDir/$d) if [[ ! -d "$parentDir" ]]; then runCmd "/bin/mkdir -p $parentDir" "Creating parent temp dir [$parentDir]." ||\ bail "Failed to create parent temp dir [$parentDir]." fi fi done fi if [[ -d $ExesDir && $BlastDownloadsAndExes -eq 1 ]]; then runCmd "/bin/rm -r -f $ExesDir" \ "Blasting exes dir [$ExesDir] due to '-B'." fi if [[ ! -d $ExesDir ]]; then [[ $PullFromWebAsNeeded -eq 0 && $TestMode -eq 0 ]] && bail "ExesDir [$ExesDir] is missing and '-local' specified. Aborting." runCmd "/bin/mkdir -p $ExesDir" ||\ bail "Could not create dir [$ExesDir]." cd $ExesDir || exit 1 echo Working in [$PWD]. if [[ $TestMode -eq 1 ]]; then runCmd "cp /sdp/test/exes/p4 ." ||\ bail "Could not get 'p4' executable." runCmd "cp /sdp/test/exes/p4d ." ||\ bail "Could not get 'p4d' executable." runCmd "cp /sdp/test/exes/p4p ." ||\ bail "Could not get 'p4p' executable." runCmd "cp /sdp/test/exes/p4broker ." ||\ bail "Could not get 'p4broker' executable." else runCmd "wget -q ftp://ftp.perforce.com/perforce/$P4ExeRel/bin.$ApiArch/p4" ||\ bail "Could not get 'p4' executable." runCmd "wget -q ftp://ftp.perforce.com/perforce/$P4DExeRel/bin.$ApiArch/p4d" ||\ bail "Could not get 'p4d' executable." runCmd "wget -q ftp://ftp.perforce.com/perforce/$P4PExeRel/bin.$ApiArch/p4p" ||\ bail "Could not get 'p4p' executable." runCmd "wget -q ftp://ftp.perforce.com/perforce/$P4BrokerExeRel/bin.$ApiArch/p4broker" ||\ bail "Could not get 'p4broker' executable." fi runCmd "chmod +x p4 p4d p4p p4broker" \ "Doing chmod +x for downloaded executables." else echo Using existing exes dir [$ExesDir]. fi #------------------------------------------------------------------------------ # Services Shutdown and Cleanup. for i in $SDPInstances; do if [[ $ThisOS == Linux || $ThisOS == Darwin ]]; then echo -e "Stopping Perforce-related servcies for Instance $i." for svc in p4d p4broker p4p p4web p4dtg; do processCmd="${svc}_${i}" # This 'ps' command should work on Linux and Mac (Yosemite+ at least). Pids=$(ps -u $RunUser -f | grep -v grep | grep "/$processCmd "| awk '{print $2}') if [[ -z "$Pids" && $svc == p4d ]]; then echo "$processCmd not found for p4d service; looking for _bin variant instead." # For the p4d service, the process command may look like 'p4d_1_bin' or just 'p4d_1', so # we check for both. processCmd="${svc}_${i}_bin" Pids=$(ps -u $RunUser -f | grep -v grep | grep "/$processCmd "| awk '{print $2}') fi if [[ -n "$Pids" ]]; then runCmd "kill -9 $Pids" \ "Killing user $RunUser processes for command $processCmd." sleep 1 else echo "Verified: No processes by user $RunUser for command [$processCmd] are running." fi done fi if [[ $ThisOS == Linux ]]; then cd /etc/init.d echo -e "Removing Perforce-related servcies.\nWorking in [$PWD]." for svc in $(/bin/ls p4*_init); do runCmd "chkconfig --del $svc" runCmd "rm -f $svc" done fi done #------------------------------------------------------------------------------ if [[ -d $DownloadsDir && $BlastDownloadsAndExes -eq 1 ]]; then runCmd "/bin/rm -r -f $DownloadsDir" \ "Blasting downloads dir [$DownloadsDir] due to '-B'." fi if [[ ! -d $DownloadsDir && $TestMode -eq 0 ]]; then [[ $PullFromWebAsNeeded -eq 0 && $TestMode -eq 0 ]] && bail "DownloadsDir [$DownloadsDir] is missing and '-local' specified. Aborting." runCmd "/bin/mkdir -p $DownloadsDir" cd $DownloadsDir || bail "Could not cd to [$DownloadsDir]." echo Working in [$PWD]. runCmd "wget -q ftp://ftp.perforce.com/perforce/$P4Rel/bin.$ApiArch/p4api.tgz" ||\ bail "Could not get file 'p4api.tgz'" runCmd "wget -q ftp://ftp.perforce.com/perforce/$P4SwarmRel/bin.multiarch/swarm.tgz" ||\ bail "Could not get file 'swarm.tgz'" if [[ $SDPInstallMethod == Tarfile ]]; then runCmd "wget -q $SDPURL" ||\ bail "Could not get SDP tar file from [$SDPURL]." fi runCmd "wget -q ftp://ftp.perforce.com/perforce/tools/$SampleDepotTar" ||\ bail "Could not get file [$SampleDepotTar]. Aborting." if [[ ! -d PerforceSample ]]; then runCmd "tar -xzvpf $SampleDepotTar" "Unpacking $SampleDepotTar in $PWD." fi runCmd "chown -R $RunUser:$RunGroup $DownloadsDir" \ "Setting ownership on downloads dir." ||\ bail "Failed to set ownership on downloads dir [$DownloadsDir]. Aborting." else echo "Using existing downloads dir [$DownloadsDir]." fi #------------------------------------------------------------------------------ # Cleanup cd "$Depotdata" || bail "Could not cd to [$Depotdata]. Aborting." echo -e "Working in [$PWD]." for d in $Metadata $Logs; do if [[ ! -d "$d" ]]; then runCmd "/bin/mkdir -p $d" "Initialized empty dir [$d]." ||\ bail "Failed to create dir [$d]." else echo "Verified: Dir [$d] exists." fi done if [[ $PreserveDirList != Unset ]]; then runCmd "/bin/mkdir -p $TmpDir" "Creating temp dir [$TmpDir]." ||\ bail "Failed to create temp dir [$TmpDir]." for d in $(echo $PreserveDirList|tr ',' ' '); do preserveDir=$Depotdata/p4/common/$d if [[ -d "$preserveDir" ]]; then parentDir=$(dirname $TmpDir/$d) if [[ ! -d "$parentDir" ]]; then runCmd "/bin/mkdir -p $parentDir" "Creating parent temp dir [$parentDir]." ||\ bail "Failed to create parent temp dir [$parentDir]." fi runCmd "/bin/mv $preserveDir $TmpDir/$d" \ "Moving preserved dir $preserveDir aside for safe keeping." else bail "Missing expected preserve dir [$preserveDir]. Check that paths specified with '-p' are relative to $Depotdata/p4/common." fi done fi for i in $SDPInstances; do runCmd "/bin/rm -rf $Depotdata/p4/$i $Metadata/p4/$i $Logs/p4/$i" \ "Blasting any existing SDP structures." ||\ bail "Failed to blast existing SDP structures." runCmd "/bin/rm -f /p4/$i" "Blasting symlink." ||\ bail "Failed to remove SDP symlink." done runCmd "/bin/rm -rf $Depotdata/p4/common" \ "Blasting SDP common folder." ||\ bail "Failed to remove SDP common folder." runCmd "/bin/rm -f /p4/common" "Removing /p4/common symink." ||\ bail "Failed to remove /p4/common symlink." runCmd "/bin/rm -rf $SDPHome /p4/ssl" \ "Removing old SDP Home and /p4/ssl." ||\ bail "Failed to remove old $SDPHome and /p4/ssl." #------------------------------------------------------------------------------ # SDP Setup if [[ $TestMode -eq 1 ]]; then runCmd "/bin/mkdir -p $SDPHome" "Creating dir $SDPHome" ||\ bail "Failed to create dir $SDPHome. Aborting." runCmd "cp -R /sdp/* $SDPHome" "Copying SDP files to $SDPHome" ||\ bail "Failed to copy SDP files to $SDPHome in test mode. Aborting." else if [[ $SDPInstallMethod == Tarfile ]]; then runCmd "tar -xzpf $DownloadsDir/$SDPTar" "Unpacking $DownloadsDir/$SDPTar in $PWD." ||\ bail "Failed to untar SDP tarfile." else export PATH="$ExesDir:$PATH" export P4CONFIG=.p4config runCmd "/bin/mkdir -p $SDPHome" "Creating dir $SDPHome" ||\ bail "Failed to create dir $SDPHome. Aborting." cd "$SDPHome" || bail "Failed to cd to [$SDPHome]." WorkshopRemote=perforce_software-sdp_${SDPInstallBranch} runCmd "$ExesDir/p4 -s -u $WorkshopUser clone -p $WorkshopPort -r $WorkshopRemote" "Cloning SDP $SDPInstallBranch branch from Workshop." ||\ bail "Failed to clone SDP from The Workshop." fi fi cd $SDPConfigDir ||\ bail "Could not cd to [$SDPConfigDir]." echo "Generating custom p4_vars.template in [$PWD]." runCmd "/bin/mv -f p4_vars.template p4_vars.template.orig" runCmd "chmod 444 p4_vars.template.orig" sed -e "s:SDPMAIL=mailx:SDPMAIL='/bin/echo Simulated mail':g" \ -e "s:SDPMAIL=mail:SDPMAIL='/bin/echo Simulated mail':g" \ p4_vars.template.orig > p4_vars.template echo "Changes in p4_vars.template:" diff p4_vars.template.orig p4_vars.template cd $SDPSetupDir ||\ bail "Could not cd to [$SDPSetupDir]." echo "Generating custom mkdirs.sh in $PWD." runCmd "/bin/mv -f mkdirs.sh mkdirs.sh.orig" runCmd "chmod 444 mkdirs.sh.orig" sed -e "s:=DNS_name_of_master_server:=helix:g" \ -e "s:admin@company.com:P4AdminList@p4demo.com:g" \ -e "s:mail.company.com:smtp.p4demo.com:g" \ -e "s:P4_PORT=1666:P4_PORT=1999:g" \ -e "s:P4BROKER_PORT=1667:P4BROKER_PORT=1666:g" \ -e "s:=adminpass:=$Password:g" \ -e "s:=servicepass:=$Password:g" \ -e "s:OSGROUP=perforce:OSGROUP=$RunGroup:g" \ -e "s:REPLICA_ID=replica:REPLICA_ID=p4d_fr_bos:g" \ -e "s:SVCUSER=service:SVCUSER=svc_p4d_fr_bos:g" \ -e "s:export MAIL=mailx:export MAIL='/bin/echo Simulated mail':g" \ -e "s:export MAIL=mail:export MAIL='/bin/echo Simulated mail':g" \ mkdirs.sh.orig > mkdirs.sh if [[ $UseSSL -eq 0 ]]; then echo "Not using SSL feature due to '-no_ssl'." sed "s/SSL_PREFIX=ssl:/SSL_PREFIX=/g" mkdirs.sh > $TmpFile runCmd "mv -f $TmpFile mkdirs.sh" fi if [[ $ThisOS == Linux ]]; then echo "Making SDP case-sensitive on Linux." sed "s:CASEINSENSITIVE=1:CASEINSENSITIVE=0:g" mkdirs.sh > $TmpFile runCmd "mv -f $TmpFile mkdirs.sh" fi chmod +x mkdirs.sh echo "SDP Localizations." diff mkdirs.sh.orig mkdirs.sh runCmd "cp -p $ExesDir/p4* $SDPHome/Server/Unix/p4/common/bin/." \ "Copying perforce executables." echo "Initializing SDP instances and configuring /etc/init.d services." for i in $SDPInstances; do cd $SDPSetupDir || bail "Could not cd to [$SDPSetupDir]." log=$PWD/mkdirs.${i}.log echo "Initializing SDP instance [$i], writing log [$log]." $PWD/mkdirs.sh $i > $log 2>&1 cat $log if [[ $ThisOS == Linux ]]; then echo -e "\nConfiguring Linux init scripts.\n" cd /etc/init.d || bail "Could not cd to [/etc/init.d]." for svc in p4broker p4d p4p; do initScript=${svc}_${i}_init if [[ -x /p4/${i}/bin/$initScript ]]; then runCmd "ln -s /p4/${i}/bin/$initScript" runCmd "chkconfig --add $initScript" runCmd "chkconfig $initScript on" fi done fi runCmd "chown -R $RunUser:$RunGroup $Depotdata" \ "Adjusting ownership of $Depotdata." || bail "Failed to adjust ownership of $Depotdata." echo -e "\nGenerating broker config for instance $i.\n" su -l $RunUser -c "$CBIN/gen_default_broker_cfg.sh ${i} > $CCFG/p4_${i}.broker.cfg" done if [[ $PreserveDirList != Unset ]]; then for d in $(echo $PreserveDirList|tr ',' ' '); do preserveDir=$Depotdata/p4/common/$d tempCopyDir=$TmpDir/$d runCmd "rsync -av $tempCopyDir/ $preserveDir" \ "Restoring $preserveDir" ||\ bail "Failed to restore $preserveDir." done runCmd "/bin/rm -rf $TmpDir" "Cleanup: Removing temp dir [$TmpDir]." ||\ bail "Failed to remove temp dir [$TmpDir]." fi #------------------------------------------------------------------------------ # Install Aux Files if [[ $InstallAuxFiles -eq 1 ]]; then echo -e "\nInstalling P4Python for SDP." su -l $RunUser -c '/depotdata/sdp/Server/Unix/setup/install_sdp_python.sh -L /p4/1/logs/install_sdp_python.log' echo -e "\nInstalling P4Perl for SDP." su -l $RunUser -c '/depotdata/sdp/Server/Unix/setup/install_sdp_perl.sh -L /p4/1/logs/install_sdp_perl.log' echo -e "\nPlaceholder for Installing Ruby and P4Ruby for SDP (Not yet implemented in the SDP).\n" fi echo "Preparing to run Sample Depot configuration script." if [[ ! -d "$ResetHome" ]]; then runCmd "/bin/mkdir -p $ResetHome" "Creating reset home dir [$ResetHome]." ||\ bail "Could not create reset home dir [$ResetHome]. Aborting." fi cd "$ResetHome" || bail "Could not cd to $Depotdata/ResetHome. Aborting." if [[ $TestMode -eq 1 ]]; then runCmd "cp /sdp/Server/test/scripts/* $ResetHome" "Copying files to reset home dir [$ResetHome]." ||\ bail "Could not copy files to reset home dir [$ResetHome]. Aborting." fi for f in NoTicketExpiration.group.p4s admin.user.p4s configure_sample_depot_for_sdp.sh protect.p4s r reset_sdp.sh; do if [[ ! -f $f ]]; then [[ $PullFromWebAsNeeded -eq 0 ]] && bail "Missing file [$f] and '-local' specified. Aborting." runCmd "wget -q $HelixInstallerBaseURL/src/$f" "Getting file $f." ||\ bail "Failed to download file [$f]. Aborting" else echo "Using existing file $PWD/$f." fi if [[ ! -x $f ]]; then if [[ $f == *".sh" || $f == r ]]; then runCmd "chmod +x $f" "chmod +x" || bail "Failed to do: chmod +x $f. Aborting." fi fi done runCmd "chown -R $RunUser:$RunGroup $ResetHome" "Fixing ownership of $ResetHome" ||: if [[ $LoadSampleDepot -eq 1 ]]; then echo "Configuring Sample Depot for SDP on Instance 1 only." su -l $RunUser -c "$ResetHome/configure_sample_depot_for_sdp.sh -i 1 -d $ResetHome" if [[ $? -eq 0 ]]; then echo -e "\nSample Depot configured successfully.\n" else bail "Failed to load the Sample Depot." fi else echo -e "\nSkipping configuration of Sample Depot due to '-no_sd'.\n" fi echo -e "\nSUCCESS: SDP Configuration complete." exit 0
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 22485 | Robert Cowham |
Update python to 3.5 Refactor tests to simplify workspace (no mapping into root), and to allow easy setup |
||
#1 | 20845 | Robert Cowham | Rename/move file(s) | ||
//guest/robert_cowham/perforce/sdp/Server/test/reset_sdp.sh | |||||
#2 | 20844 | Robert Cowham | Introduce test mode. | ||
#1 | 20821 | Robert Cowham |
Branching //guest/perforce_software/helix-installer/main/src/... to //guest/robert_cowham/perforce/sdp/Server/test/... |
||
//guest/perforce_software/helix-installer/main/src/reset_sdp.sh | |||||
#18 | 20656 | C. Thomas Tyler | Removed obsolete HostIP logic. | ||
#17 | 20654 | C. Thomas Tyler |
A few minor tweaks to make it more in-line with the Battle School Lab Engine, a primary customer of the Helix Installer. |
||
#16 | 20568 | C. Thomas Tyler | Updated SDP to 2016.1.20559. | ||
#15 | 20522 | C. Thomas Tyler | Updated SDP to 2016.1.20491. | ||
#14 | 20483 | C. Thomas Tyler | Updated SDP to 2016.1.20460. | ||
#13 | 20411 | C. Thomas Tyler | Optimzied sed. | ||
#12 | 20400 | C. Thomas Tyler | Updated SDP to 2016.1.20395. | ||
#11 | 20392 | C. Thomas Tyler | Updated to SDP 2016.1.20387. | ||
#10 | 20375 | C. Thomas Tyler |
Tweaked sample DNS name of master server to use 'helix' name, emphasizing that it should be a host alias, not hard-coded to a specific machine (e.g. helix-01 or helix-02). Also uses the host short name, which should work if networking best practices are followed. |
||
#9 | 20359 | C. Thomas Tyler |
Added comment encouring people not to be lazy and use the built-in password for production environments. |
||
#8 | 20358 | C. Thomas Tyler |
reset_sdp.sh v2.7.6: * Updated to latest SDP, including change in password file location. * Updated to acquire Swarm 2016.1. |
||
#7 | 20052 | C. Thomas Tyler | Updated latest packaged SDP default to 2016.1.20028. | ||
#6 | 19900 | C. Thomas Tyler | Updated default SDP version. | ||
#5 | 19843 | C. Thomas Tyler | Updated default to latest SDP. | ||
#4 | 19416 | C. Thomas Tyler | Updated SDP version. | ||
#3 | 19263 | C. Thomas Tyler |
Updated to test with 2016.1 executables. Enhanced code and internal docs. Tweaked URLS for pulling files from The Workshop. |
||
#2 | 19231 | C. Thomas Tyler |
Adjusted Swarm URL to reflect the Helix Installer move from //guest/tom_tyler to //guest/perforce_software. |
||
#1 | 19230 | C. Thomas Tyler |
Populate -o //guest/tom_tyler/helix-installer/... //guest/perforce_software/helix-installer/.... |
||
//guest/tom_tyler/helix-installer/main/src/reset_sdp.sh | |||||
#21 | 18963 | C. Thomas Tyler | Updated to latest SDP 2016.1.18958. | ||
#20 | 16837 | C. Thomas Tyler | Updated to latest SDP tarfile. | ||
#19 | 16697 | C. Thomas Tyler |
Tweaked to account for cases where 'hostname -i' call returns more than one IP address. |
||
#18 | 16671 | C. Thomas Tyler |
reset_sdp.sh v2.6.9: * Minor optimization to error message when gcc and/or gcc-c++ packages are missing. * The '-fast' flag now changes the error relating to gcc/g++ not being installed to a warning. * Added confirmation message if gcc/g++ are found. |
||
#17 | 16670 | C. Thomas Tyler |
reset_sdp.sh v2.6.8: * Now clones SDP main branch from The Workshop by default, rather than using a tar file. * Added '-b' to override default branch (main), e.g. '-b dev'. * Added '-t <tarfile>' (or '-t default') to use the old tarfile install method of using a hard-coded tarball, good for when stability is preferred over using the very latest. |
||
#16 | 16660 | C. Thomas Tyler |
Added '-p' flag to enable preserving existing directories under /p4/common. |
||
#15 | 16642 | C. Thomas Tyler | Updated default SDP version. | ||
#14 | 16624 | C. Thomas Tyler |
reset_sdp.sh v2.6.5. For Linux hosts, optimized to use 'hostname -i' rather than 'hostname -I'. Added inline comments on IP selection on Linux and OSX. |
||
#13 | 16623 | C. Thomas Tyler |
Changed order of commands to fix issue with permissions when generating SDP broker config file. |
||
#12 | 16607 | C. Thomas Tyler | Audit enhancement. | ||
#11 | 16606 | C. Thomas Tyler |
Improved handling of simulated mail from SDP scripts, so that live_checkpoint succeeds on all platforms; it had failed previosuly on Mac/Darwin due to failure sending email. Improved backup handling. |
||
#10 | 16602 | C. Thomas Tyler |
Added '-local' option; avoids pulling from Workshop/FTP server. Updated Swarm to 2015.3. |
||
#9 | 16567 | C. Thomas Tyler | Updated SDP Version. | ||
#8 | 16396 | C. Thomas Tyler | Rolled back Swarm version. | ||
#7 | 16395 | C. Thomas Tyler | Updated to 2015.2 GA for P4D and 2015.3 GA for Swarm. | ||
#6 | 16393 | C. Thomas Tyler |
Fixed issue with 'sed' call. Updated to work with new HOSTIP setting in SDP. |
||
#5 | 16377 | C. Thomas Tyler |
Updated to pick up latest SDP, and made corresponding adjustments to processing of subsitutions in mkdirs.sh. |
||
#4 | 16359 | C. Thomas Tyler | Minor code cleanlup. | ||
#3 | 16358 | C. Thomas Tyler |
Adjusted base path for Helix Installer. Updated coypright to reference LICENSE file. |
||
#2 | 16349 | C. Thomas Tyler | Updated to latest SDP version. | ||
#1 | 15829 | C. Thomas Tyler |
Moved Helix Installer to new Workshop Standard for personal projects. |
||
//guest/tom_tyler/sw/main/hi/src/reset_sdp.sh | |||||
#22 | 15629 | C. Thomas Tyler |
reset_sdp.sh v2.5.0: * Updated SDP to 2015.1.15607. * Added '-C' (clean) flag to blast /depotdata/p4/common. |
||
#21 | 15611 | C. Thomas Tyler |
reset_sdp.sh v2.4.9: * Updated default Swarm to 2015.2. * Fixed mostly harmless bug attempting to pull a non-existing file from the web. |
||
#20 | 15060 | C. Thomas Tyler | Rollback of Copy Up done with a new utility that apparently needs some work. | ||
#19 | 15051 | C. Thomas Tyler | Copy Up using 'p4 copy -r -b tom_tyler-hi-dev' | ||
#18 | 15007 | C. Thomas Tyler | Fixed expression. | ||
#17 | 14987 | C. Thomas Tyler |
Reduced excessive noise from from rsync and tar commands. Added '--delete' to rsync commands handling the Sample Depot to force a clean reset. Added clear completion messages. |
||
#16 | 14973 | C. Thomas Tyler | Added -no_ssl flag. | ||
#15 | 14956 | C. Thomas Tyler | Fixed 'ps' check. | ||
#14 | 14954 | C. Thomas Tyler | Fixed typo in case sensitivity mod. | ||
#13 | 14953 | C. Thomas Tyler |
Updated various settings to match changes in SDP. Removed generation of a duplicate broker config file. |
||
#12 | 14952 | C. Thomas Tyler |
Adjusted case sensitivitiy to be case-sensitive on Linux, the opposite of the SDP default. |
||
#11 | 14949 | C. Thomas Tyler |
Enhanced to ensure that 'reset_sdp.sh' is the only script required. It now downloads all other scripts and data files as needed. |
||
#10 | 14910 | C. Thomas Tyler |
Added initialtion of empty /depotdata /metadata and /logs dirs. |
||
#9 | 14903 | C. Thomas Tyler | Fixed issue running under Vagrant. | ||
#8 | 14902 | C. Thomas Tyler |
Changed default list of SDP instances to initialize from "1 12 abc" (illustrating ability to use named rather than number instances) to just "1", which is mostly all that's wanted for testing and pilot installations. |
||
#7 | 14901 | C. Thomas Tyler | Fixed a typo in 'chmod' call. | ||
#6 | 14188 | C. Thomas Tyler | Updated SDP version. | ||
#5 | 14120 | C. Thomas Tyler |
Moved sample depot checkpoint load to configurator script. Added '-fast' flag to speed up testing. Various minor tweaks. |
||
#4 | 14106 | C. Thomas Tyler |
Implemented Sample Depot SDP configurator script. Tightened logic around process kill statement, and made it work for Linux/Mac. |
||
#3 | 14063 | C. Thomas Tyler |
Added generation of initial live checkpoint for each instance. Adjusted permissions on downloads folder. Removed bad code fragements. Cosmetic enhancement to the password. |
||
#2 | 14033 | C. Thomas Tyler |
Added script to transform stock Sample Depot data set to be SDP compliant (mostly a stub at this point). Various improvements to reset_sdp.sh and the wrapper r.sh. |
||
#1 | 13940 | C. Thomas Tyler |
Added my personal reset_sdp test script. DO NOT DEPLOY on a live server. |