#!/bin/bash #------------------------------------------------------------------------------ # Copyright (c) Perforce Software, Inc., 2007-2014. All rights reserved # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1 Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE # SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. #------------------------------------------------------------------------------ # # trap unbound variables set -u # Mail to the administrator gets sent here: export MAILTO=REPL_MAILTO export MAILFROM=REPL_MAILFROM export P4USER=REPL_ADMINUSER export P4SERVICEUSER=REPL_SVCUSER export OSUSER=REPL_OSUSER export SDP_VERSION="REPL_SDPVERSION" AWK=awk CUT=cut DF="df -h" GREP=grep ID=id SDPMAIL=mail PS=ps OS=`uname` if [ "${OS}" = "SunOS" ] ; then AWK=/usr/xpg4/bin/awk ID=/usr/xpg4/bin/id SDPMAIL=mailx elif [ "${OS}" = "AIX" ] ; then DF="df -m" fi export AWK export ID export SDPMAIL export DF # Which perforce instance are we configuring? Defaults to 1. export P4INSTANCE=${1:-1} export P4SERVER="p4_${P4INSTANCE}" export P4SSLDIR=/p4/ssl export P4HOME="/p4/${P4INSTANCE}" export TMP=${P4HOME}/tmp export P4TMP=${P4HOME}/tmp export P4ROOT=${P4HOME}/root export P4JOURNAL=${P4HOME}/logs/journal export P4CONFIG=${P4HOME}/.p4config export P4TICKETS=${P4HOME}/.p4tickets export DEPOTS=${P4HOME}/depots export CHECKPOINTS=${P4HOME}/checkpoints export LOGS=${P4HOME}/logs export P4LOG=${LOGS}/log export P4LOGS=$P4HOME/logs export P4CBIN=/p4/common/bin export P4CLIB=/p4/common/lib export PERL5LIB=$P4CLIB:${PERL5LIB:-} export PERLHOME=/p4/common/perl export PYHOME=/p4/common/python export PATH=$P4HOME/bin:$P4CBIN:$PYHOME/bin:$PERLHOME/site/bin:$PERLHOME/bin:$PATH:. export MANPATH=$PERLHOME/site/man:$PERLHOME/man:${MANPATH:-} export SERVERID=`cat ${P4ROOT}/server.id` # P4Proxy Settings export P4PCACHE=$P4HOME/cache # Set KEEPCKPS to the number of checkpoint & journal files and their # corresponding log files to keep. Checkpoints and their log file are # numbered with the same journal counter number. Checkpoints/journals # and their logs are removed when daily_backup.bat or weekly_backup.bat # are run. The live_checkpoint.bat script does not remove. # Set KEEPCKPS=0 to avoid automated cleanup of checkpoints and logs. export KEEPCKPS=7 # Set KEEPLOGS to the number of server logs to keep, counting back from # the most recent. Server logs are numbered with their corresponding # journal counter number, since server logs are rotated when checkpoint # logs are rotated. Keep in mind that if scripts are set to run # more than once per day, this will not correspond to the number # of days, just the number of iterations of script calls. # KEEPLOGS affects all log files other than checkpoint logs, which are # governed by KEEPCKPS. # Set KEEPLOGS=0 to avoid automated cleanup of old server logs. export KEEPLOGS=31 # Don't change this; change or comment the above as needed export P4BIN=${P4HOME}/bin/p4_${P4INSTANCE} export P4DBIN=${P4HOME}/bin/p4d_${P4INSTANCE} export P4PBIN=${P4HOME}/bin/p4p_${P4INSTANCE} export P4BROKERBIN=${P4HOME}/bin/p4broker_${P4INSTANCE} export P4WEBBIN=${P4HOME}/bin/p4web_${P4INSTANCE} # Define *_VERSION values. These will look like "2014.1.899321" # or "2015.1_BETA.903064". For example, to specify behavior specific # to 2014.1 or later P4D, test with [[ "$P4D_VERSION" > "2014.1" ]]. # That expression will be true 2014.1 and any subsequent release. Since # the values contain the patch number, all releases of "2014.1.*" will # be greater than the string "2014.1", so "greater than or equal to" is # implied. [[ -x $P4BIN ]] && export P4_VERSION=$($P4BIN -V|$GREP ^Rev.|$CUT -d '/' -f 3).$($P4BIN -V|$GREP ^Rev.|$CUT -d '/' -f 4|$CUT -d ' ' -f 1) [[ -x $P4DBIN ]] && export P4D_VERSION=$($P4DBIN -V 2>/dev/null|$GREP ^Rev.|$CUT -d '/' -f 3).$($P4DBIN -V 2>/dev/null|$GREP ^Rev.|$CUT -d '/' -f 4|$CUT -d ' ' -f 1) # Set version values for optional executables. [[ -x $P4PBIN ]] && export P4P_VERSION=$($P4PBIN -V|$GREP ^Rev.|$CUT -d '/' -f 3).$($P4PBIN -V|$GREP ^Rev.|$CUT -d '/' -f 4|$CUT -d ' ' -f 1) [[ -x $P4BROKERBIN ]] && export P4BROKER_VERSION=$($P4BROKERBIN -V|$GREP ^Rev.|$CUT -d '/' -f 3).$($P4BROKERBIN -V|$GREP ^Rev.|$CUT -d '/' -f 4|$CUT -d ' ' -f 1) [[ -x $P4WEBBIN ]] && export P4WEB_VERSION=$($P4WEBBIN -V|$GREP ^Rev.|$CUT -d '/' -f 3).$($P4WEBBIN -V|$GREP ^Rev.|$CUT -d '/' -f 4|$CUT -d ' ' -f 1) # Sets instance specific vars. Last so that the caller sees the error. if [ -f "/p4/common/config/${P4SERVER}.vars" ] ; then . /p4/common/config/${P4SERVER}.vars fi
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#37 | 29746 | C. Thomas Tyler |
Moved proxy '-e 3072' flag from p4p_base to Instance Vars file so it can be changed on a per-instance basis. It is now part of the def'n of PROXY_V_FLAGS. Moved PROXY_MON_LEVEL from p4_vars to Instance Vars file so it can be changed on a per-instance basis. Updated format settings in sdp_upgrade.sh, and added PROXY_MON_LEVEL to list of user settings to be preserved during SDP upgrades. #review-29747 |
||
#36 | 29609 | C. Thomas Tyler | Updated data format tags per SDP relesae process docs. | ||
#35 | 29563 | Andy Boutte | Adding optional local config directories for both instance and SDP wide configuration. | ||
#34 | 29396 | C. Thomas Tyler |
Doc improvements to SDP Instance Vars file re: MAILTO/MAILFROM settings. Tweaked Shellcheck SC<NNNN> tags to re-achieve shellcheck compliance. #review-29397 @daniel_ferrara |
||
#33 | 28357 | C. Thomas Tyler |
Corrected local name of file checked for custom local logic extraction, and corrected order of local custom config file loading (global comes before instance-specific). Test: Set P4_MSG="Life" at the end of p4_vars, and set P4_MSG+=" Is Good" at the end of p4_1.vars, each below the '### MAKE LOCAL CHANGES HERE' block. Then echo $P4_MSG after. #review-28358 |
||
#32 | 28343 | C. Thomas Tyler |
Added documented-but-missing logic for extracting custom logic from SDP shell environment files. #review-28344 |
||
#31 | 28140 | C. Thomas Tyler |
Refined sdp_upgrade.sh; this is still a non-functional work in progress version, with expanded documentation. Added file format version settings into p4_vars template and instance-specific p4_vars files. |
||
#30 | 27722 | C. Thomas Tyler |
Refinements to @27712: * Resolved one out-of-date file (verify_sdp.sh). * Added missing adoc file for which HTML file had a change (WorkflowEnforcementTriggers.adoc). * Updated revdate/revnumber in *.adoc files. * Additional content updates in Server/Unix/p4/common/etc/cron.d/ReadMe.md. * Bumped version numbers on scripts with Version= def'n. * Generated HTML, PDF, and doc/gen files: - Most HTML and all PDF are generated using Makefiles that call an AsciiDoc utility. - HTML for Perl scripts is generated with pod2html. - doc/gen/*.man.txt files are generated with .../tools/gen_script_man_pages.sh. #review-27712 |
||
#29 | 27318 | C. Thomas Tyler |
Added comment block introducing '### MAKE LOCAL CHANGES HERE:' comment block to generated SDP files to simplify future automated upgrades of generated SDP files. This is a non-functional change. |
||
#28 | 26932 | C. Thomas Tyler |
Repurposed the /p4/common/site directory. This directory will exist on a a fresh SDP install, but will be empty save for a ReadMe.txt file explaining that it is to be used to make local extensions to the SDP, and that anything in here is not supported. The coming automated SDP upgrade procedure will know to ignore /p4/common/site directory tree. The p4_vars ensures that /p4/common/site/bin is in the PATH. |
||
#27 | 26652 | Robert Cowham |
This is Tom's change: Introduced new 'Unsupported' directory to clarify that some files in the SDP are not officially supported. These files are samples for illustration, to provide examples, or are deprecated but not yet ready for removal from the package. The Maintenance and many SDP triggers have been moved under here, along with other SDP scripts and triggers. Added comments to p4_vars indicating that it should not be edited directly. Added reference to an optional site_global_vars file that, if it exists, will be sourced to provide global user settings without needing to edit p4_vars. As an exception to the refactoring, the totalusers.py Maintenance script will be moved to indicate that it is supported. Removed settings to support long-sunset P4Web from supported structure. Structure under new .../Unsupported folder is: Samples/bin Sample scripts. Samples/triggers Sample trigger scripts. Samples/triggers/tests Sample trigger script tests. Samples/broker Sample broker filter scripts. Deprecated/triggers Deprecated triggers. To Do in a subsequent change: Make corresponding doc changes. |
||
#26 | 26398 | C. Thomas Tyler |
Added delay on start, to workaround common issues where a fast cycle of p4d process fails because the TCP port (e.g. 1666) is still in use briefly after a clean shutdown, a system resource isn't available immediately on boot, or similar timing issue. The delay on start is skipped if P4ROOT is empty (tested for by checking for existence of db.comain). Added optional new SDP_START_DELAY setting in the p4_vars file (generated from p4_vars.template) to configure the delay. Files in this changelist now pass shellcheck (v0.61) (driving various minor non-functional edits). |
||
#25 | 24357 | C. Thomas Tyler |
Added SDP_ADMIN_PASSWORD_FILE variable in p4_vars.template, and also added a default value in backup_functions.sh. Also added comments in p4_vars explaining the 'set +u' bit. Adding SDP_ADMIN_PASSWORD_FILE is an enabling change for an upcoming change to mkrep.sh. Updated p4login and p4login-super.sh to reference this variable. Normalized p4login-super.sh to accept SDP instance parameter, which (as with other scripts) is optional of SDP_INSTANCE is already defined, else required. Also chmod +x p4login-super.sh. #review @robert_cowham |
||
#24 | 23504 | C. Thomas Tyler |
Addding SDP-standard Ruby to PATH. #review-23505 |
||
#23 | 22595 | C. Thomas Tyler |
Fixed to prefer our self-contained SDP Perl in /p4/common/perl (if installed) over any local installation. This avoids issues where P4Perl fails to work due to interaction with a local and incompatible Perl version (e.g. some old 5.8 version). |
||
#22 | 22341 | C. Thomas Tyler |
Provided default value for SERVERID on hosts w/o server.id file. Change to ensure SERVERID always has a value, even when SDP is used on SDP-managed machines with no 'p4d' (e.g. broker or proxy boxes). In those cases, the hostname is the default value. This goes with change @22333. |
||
#21 | 21808 | C. Thomas Tyler |
Routine merge down to dev from main, picking up change from akwan: update p4p_base to incorporate proxy monitoring and set default value in p4_vars |
||
#20 | 21458 | UnstoppableDrew | Save SHELLOPTS and unset nounset if it wasn't set. | ||
#19 | 20590 | C. Thomas Tyler |
Added HMS_HOME setting, and added $HMS_HOME/scripts to PATH. Also improved comment describing purpose of 'set -u'. |
||
#18 | 20363 | C. Thomas Tyler |
Removed references to legacy names for checkpoint scripts. No functional changes. Bypassing pre-commit code review. #review-20364 |
||
#17 | 20170 | Russell C. Jackson (Rusty) |
Moved password and users into the config directory to allow for instance specific users and passwords. Ran into a case where two different teams were sharing the same server hardware and needed this type of differentiation. Surprised that we haven't hit this sooner. Also defaulted mkdirs to use the numeric ports since this is the most common installation. |
||
#16 | 20020 | C. Thomas Tyler |
Added safety feature to unset vars like P4AUTH that aren't always set, to avoid cross-instance contamination if p4_vars is sourced multiple times. |
||
#15 | 19888 | C. Thomas Tyler |
Defend against environment hijacking of P4ENVIRO and P4CONFIG. Reviewers: Please see detailed discussion in job000548. |
||
#14 | 19523 | Russell C. Jackson (Rusty) |
Added a KEEPJNLS variable to allow you to keep more journals than checkpoints in case you rotate the journal more frequently than you run checkpoints. |
||
#13 | 18925 | C. Thomas Tyler |
Enhanced p4_vars.template to support operating on an SDP-managed host where no p4d process runs, such as a p4p (proxy) host, where no /p4/n/root/server.id file exists. The $SERVERID value will be empty (but defined) in this case. Enhanced to better support operating with replicas that share /depotdata with their master servers, by making P4TRUST and P4TICKETS values contain $SERVERID. Moved SHAREDDATA from p4_vars to instance_vars, since it is not inherently a global setting. In sophisticated enterprise environments, it can vary on a per-replica basis. Adjusted mkdirs.sh accordingly. |
||
#12 | 18852 | C. Thomas Tyler | Enhanced P4DTG config to be more SDP-ified. | ||
#11 | 18581 | C. Thomas Tyler |
global_replica_status.sh v1.1.0: * Moved sdp_hosts.cfg config file to /p4/common/config, with optional override by speciffying P4CCFG variable. * Changed recommended command line for crontab to suggest '-E' (always send emails) rather than '-e' (email on error only). * Enhanced docs. Added new P4CCFG setting to p4_vars.template, with value /p4/common/config. |
||
#10 | 16029 | C. Thomas Tyler |
Routine merge to dev from main using: p4 merge -b perforce_software-sdp-dev |
||
#9 | 15701 | C. Thomas Tyler | Routine merge down using 'p4 merge -b perforce_software-sdp-dev'. | ||
#8 | 15375 | adrian_waters | Routine merge-down from main->dev | ||
#7 | 14136 | C. Thomas Tyler |
Routine merge down to dev from main for SDP using perforce_software-sdp-dev. |
||
#6 | 13934 | C. Thomas Tyler |
Added settings for P4TRUST and P4ENVIRO to both Linux and Windows environments. Removed '#!/bin/bash' line from to of p4_vars.tempate, as the generarted p4_vars file is intended to be sourced rather than executed directly (and to avoid starting an unnecessary subshell). Also removed execute bit (undoing 'chmod +x') from p4_vars.template, just to emphaisze its intended use. #review-13935 |
||
#5 | 13906 | C. Thomas Tyler |
Normalized P4INSTANCE to SDP_INSTANCE to get Unix/Windows implementations in sync. Reasons: 1. Things that interact with SDP in both Unix and Windows environments shoudn't have to account for this obscure SDP difference between Unix and Windows. (I came across this doing CBD work). 2. The Windows and Unix scripts have different variable names for defining the same concept, the SDP instance. Unix uses P4INSTANCE, while Windows uses SDP_INSTANCE. 3. This instance tag, a data set identifier, is an SDP concept. I prefer the SDP_INSTANCE name over P4INSTANCE, so I prpose to normalize to SDP_INSTANCE. 4. The P4INSTANCE name makes it look like a setting that might be recognized by the p4d itself, which it is not. (There are other such things such as P4SERVER that could perhaps be renamed as a separate task; but I'm not sure we want to totally disallow the P4 prefix for variable names. It looks too right to be wrong in same cases, like P4BIN and P4DBIN. That's a discussion for another day, outside the scope of this task). Meanwhile: * Fixed a bug in the Windows 2013.3 upgrade script that was referencing undefined P4INSTANCE, as the Windows environment defined only SDP_INSTANCE. * Had P4INSTANCE been removed completely, this change would likely cause trouble for users doing updates for existing SDP installations. So, though it involves slight technical debt, I opted to keep a redundant definition of P4INSTANCE in p4_vars.template, with comments indicating SDP_INSTANCE should be used in favor of P4INSTANCE, with a warning that P4INSTANCE may go away in a future release. This should avoid unnecessary upgrade pain. * In mkdirs.sh, the varialbe name was INSTANCE rather than SDP_INSTANCE. I changed that as well. That required manual change rather than sub/replace to avoid corrupting other similar varialbe names (e.g. MASTERINSTANCE). This is a trivial change technically (a substitute/replace, plus tweaks in p4_vars.template), but impacts many files. |
||
#4 | 12923 | C. Thomas Tyler |
Routine merge down from main to dev. Resolved with 'p4 resolve -as', no merges or conflicts. |
||
#3 | 12116 | Russell C. Jackson (Rusty) | Update dev from main. | ||
#2 | 12028 | C. Thomas Tyler | Refreshed SDP dev branch, merging down from main. | ||
#1 | 11477 | Russell C. Jackson (Rusty) |
Updated to use /usr/bin/env python Added workshop header. Changed cfg to config. |
||
//guest/perforce_software/sdp/dev/Server/Unix/p4/common/cfg/p4_vars.template | |||||
#1 | 11474 | Russell C. Jackson (Rusty) |
Had to move the cfg directory to the metadata volume and link it under the instance directory to provide the proper separation in a shared volume environment. The instance specific vars cannot be in a shared directory since they need to be different on each node using the shared volume. Since the files moved back to the instance directory, I changed the names back to: instance_vars p4review.cfg to keep things simple. Also moved p4_vars.template to SDP/Server/Unix/p4/common/cfg so that it doesn't get copied to the /p4/common/bin folder. Plus, it makes more sense for it to be in that directory in the SDP structure. |
||
//guest/perforce_software/sdp/dev/Server/Unix/p4/common/bin/p4_vars.template | |||||
#4 | 11466 | Russell C. Jackson (Rusty) |
Initial work to simplify p4_vars and remove cluster stuff. Testing of named instances surfaced some bugs that are in prod sdp, now fixed in dev. Added three triggers from RCJ SDP Moved p4review.cfg into the new /p4/common/cfg to go along with the instance_vars files. mkdirs.sh now generates an instance_p4review.cfg as well. Removed incremental p4verify to clean up a bit. It didn't support replicas and was really never used. All port settings now live in <instance>_vars file. You set what you want the ports to be in mkdirs.sh. There is no more fancy logic to try to guess what the port should be. You set it, and that is what it is. Remaining to do is to updated scripts to not need p4master_run. Saved that work for later since this is tested and works. |
||
#3 | 10994 | Robert Cowham | Catchup from Main | ||
#2 | 10867 | C. Thomas Tyler | Merge Down: Rereshed 'dev' from 'main'. | ||
#1 | 10638 | C. Thomas Tyler | Populate perforce_software-sdp-dev. | ||
//guest/perforce_software/sdp/main/Server/Unix/p4/common/bin/p4_vars.template | |||||
#1 | 10148 | C. Thomas Tyler | Promoted the Perforce Server Deployment Package to The Workshop. |