# Various scripts send email to $MAILTO. This can contain comma-delimited list # of email addresses (no spaces). export MAILTO=REPL_MAILTO # Specify the email adddress from which emails are sent in $MAILFROM. # This must be exactly one email address. export MAILFROM=REPL_MAILFROM export P4USER=REPL_ADMINUSER export P4SERVICEUSER=svc_${SERVERID} # P4MASTER_ID is server.id of Master for this instance export P4MASTER_ID=REPL_MASTER_ID # The setting below should be ssl: if this instance uses ssl. export SSL_PREFIX=REPL_SSLPREFIX export P4PORTNUM=REPL_P4PORT export P4PORT=${SSL_PREFIX}${P4PORTNUM} # Set the value for P4BROKERPORT to Unset if the broker is not # used. export P4BROKERPORTNUM=REPL_P4BROKERPORT export P4BROKERPORT=${SSL_PREFIX}${P4BROKERPORTNUM} # These $P4D_FLAGS show when using 'ps' to scan the process table. # Other settings affect p4d. export P4D_FLAGS="-p $P4PORT -r $P4ROOT -J $P4JOURNAL -L $P4LOG -q -d --pid-file" # SERVERID is defined in /p4/n/root/server.id. # Override P4TICKETS and P4TRUST for replicas. if [[ -n "$SERVERID" && "$SERVERID" != "$P4MASTER_ID" ]]; then export P4REPLICA=TRUE export P4USER=REPL_ADMINUSER if [[ -f $P4ROOT/db.domain ]]; then targetServerPort=$($P4DBIN -r $P4ROOT -cshow | egrep "^$SERVERID: P4TARGET = ") targetServerPort=${targetServerPort##* = } targetServerPort=$(echo $targetServerPort) else targetServerPort=$P4PORTNUM fi if [[ -n "$targetServerPort" ]]; then export P4MASTERPORT=$targetServerPort if [[ "$targetServerPort" == *":"* ]]; then # strip of any trailing ':.....' element (e.g., ':1666') export P4MASTER=${targetServerPort%:*} # if P4TARGET includes ssl, also need to strip off ssl: from front export P4MASTER=${P4MASTER#*:} else export P4MASTER=REPL_DNSNAME fi else export P4MASTER=REPL_DNSNAME export P4MASTERPORT=${SSL_PREFIX}${P4MASTER}:${P4PORTNUM} fi # Set SHAREDDATA=TRUE on replica servers that share their /hxdepots # volume with their P4TARGET server. if [[ -f $P4ROOT/db.domain ]]; then repStyle=$($P4DBIN -r $P4ROOT -cshow|$GREP "^$SERVERID: lbr.replication = ") repStyle=${repStyle##* = } repStyle=$(echo $repStyle) else repStyle=readonly fi if [[ $repStyle == "shared" ]]; then export SHAREDDATA=TRUE else export SHAREDDATA=FALSE fi else export P4REPLICA=FALSE # This is the DNS name of the master server: export P4MASTER=REPL_DNSNAME export SHAREDDATA=FALSE export P4MASTERPORT=${SSL_PREFIX}${P4MASTER}:${P4PORTNUM} fi # Proxy settings export PROXY_TARGET=${SSL_PREFIX}${P4MASTER}:${REPL_P4P_TARGET_PORT:-$P4PORTNUM} export PROXY_PORT=$P4PORT # P4DTG Settings: export P4DTG_CFG=$P4SERVER export SDP_ALWAYS_LOGIN=0 umask 0026
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 23960 | noe_gonzalez | "Forking branch Dev of perforce-software-sdp to noe_gonzalez-sdp." | ||
//guest/perforce_software/sdp/dev/Server/Unix/p4/common/config/instance_vars.template | |||||
#27 | 23454 | cgeen |
Update to hms script to do two new functions: pull and df. Pull issues a pull -lj on all the edge/replica servers to get the status df issues a diskspace on all the servers. The reason for this is with a hardened edge environment the P4USER does not have permissions to run these commands on the edge servers. Therefore we need to run them centrally as a super. This replaces the replica_status commands on the edge. The updates also includes an update to the p4_vars to change the P4USER on an edge server. The idea is that P4USER only has super privs on the master on the replica edge servers the default user can only have admin privs. This is so the box adminstrator in restricted regions can't change the protection table. Hence the need for pull df centrally as these are the only commands that can't be run on the replicas/edges from the maintance scripts. It also goes without saying that ssh should only go out from the commit and never back. |
||
#26 | 22957 | C. Thomas Tyler |
Merged two changes initiated on main down to: Change @22826 by robert_cowham: Ignore some files on Mac. Change @22950 by awkan/ttyler: Provide an override for difference between proxy listening port and target port |
||
#25 | 22625 | Russell C. Jackson (Rusty) | Approved in Review 22364 | ||
#24 | 22610 | Russell C. Jackson (Rusty) | Added check to make sure db.domain exists before running p4d -cshow to avoid creating an empty database. | ||
#23 | 22333 | Russell C. Jackson (Rusty) |
The service user always needs to be defined since the proxy base script uses it as well. Added note about making sure to leave replica FALSE when setting up a proxy. If you don't the instance vars script will create an empty database by running the cshow commands. |
||
#22 | 22080 | C. Thomas Tyler |
Cosmetic change, doc tweaks and whitespace fix (tabs->spaces). No functional change. |
||
#21 | 20972 | C. Thomas Tyler | Merge down of change made in dev & main. | ||
#20 | 20921 | Russell C. Jackson (Rusty) | Fix that Adrian shelved on Main for ssl: issue. | ||
#19 | 20749 | C. Thomas Tyler |
Approved and committed, but I believe that the shared data setting is always set to false on the master and we should look at fixing that in another change. Enhanced p4login again. Improvements: Default behavior with no arguments gives the desired results. For example, if run on a master, we login on the super user P4USER to P4PORT. If run on a replica/edge and auth.id is set, we login P4USER to the P4TARGET port of the replica. All other login functionality, such as logging in the replication service user on a replica, logging in supplemental automation users, is now accessed via new flags. A usage message is now available via '-h' and '-man' options. The new synopsys is: p4login [<instance>] [-p <port> | -service] [-automation] [-all] The <instance> parameter is the only non-flag positional parameter, and can be ommitted if SDP_INSTANCE is already defined (as is typical when called by scripts). With this change, several other scripts calling either the 'p4login' script or 'p4 login' commands were normalized to call p4login as appropriate given the new usage. Reviewer Note: Review p4login first, then other files. Most changes are in p4login. In other scripts callling p4login, calls similar to: $P4BIN -u $P4USER -p $P4PORT login < /path/to/pwd are replaced with: $P4CBIN/p4login In other scritps calling p4login, calls similar to: $P4BIN -p $P4MASTERPORT login < /path/to/pwd are replaced with: $P4CBIN/p4login -p $P4MASTERPORT Note that, if auth.id is set, calling 'p4login' actually has the same behavior as 'p4login -p $P4MASTERPORT', since p4login called on a replica with auth.id set will just login to the master port anyway. Depending on intent, sometimes $P4BIN/p4login -service is used. == Misc Cleanup == In doing the cleanup: * Fixed a hard-coding-to-instance-1 bug in broker_rotate.sh. * Fixed an inconsistency in recreate_db_sync_replica.sh, where it did just a regular login rather than a login -a as done in other places for (for compatibility with some multi-interface NIC card configs). == p4login Call Normalization == Code cleanup was done to normalize calls to p4login, such that: 1) the call starts with $P4CBIN/p4login (not the hard-coded path), and 2) logic to redirect sdtout/stderr to /dev/null was removed, since it's not necessary with p4login. (And if p4login ever does generate any unwanted output, we only fix it in one place). == Tweak to instance_vars.template == This change includes a tweak to set P4MASTERPORT dynamically on a replica to ensure the value precisely matches P4TARGET for the given replica. This will reduce a source of problems when SSL is used, as it is particularly sensitive to the precise P4PORT values used, and will also help for environments which have not yet set auth.id. If the port cannot be determined dynamically, we fall back to the old logic using the assigned value. == Tweak to SDP_ALWAYS_LOGIN behavior == This used to default to 1, now it defaults to 0. At this point we should no longer need to force logins, and in fact doing so can get into a 'p4 login' hang situation with auth.id set. Best to avoid unnecessary logins if we already have a valid ticket. (I think the need to force a login may have gone away with p4d patches). == Obsolete Script == With this change, svclogin.sh is now obsolete. All it was doing was a few redundant 'p4 login' commands followed by a call to p4login anyway. == Testing == Our test suite doesn't fully cover this change, so additional manual testing was done in the Battle School lab environment. |
||
#18 | 20694 | Russell C. Jackson (Rusty) |
Remove instance specific p4trust and p4ticket files because it is causing you to have to login again when you change the server.id, and that isn't needed when using auth.id and rpl.forward.login. If you are using a shared depotdata volume, just be sure to use the auth.id and rpl.forward.login and you will not have a problem with the ticket files since the login ticket will be the same on all servers. We never had a problem with the trust files in a shared environment since the trust is always based on the master server's IP address. |
||
#17 | 20432 | C. Thomas Tyler |
Improved edge & daisy chained replica support in instance_vars.template. Changed so P4MASTER is set dynamically, based on how/whether the P4TARGET of the current ServerID is set. This also eliminates a possible discrepancey beteween P4MASTER as defined in the p4_N.vars/mkdirs.sh and the master hostname as defined in P4TARGET configurables. The value defined with P4TARGET must also work with SSH keys. (As a best practice P4TARGET should be a host alias so that it doesn't need to be changed in case of failvoer of your P4TARGET server). Changed so SHAREDDATA is set dynamically, based on how/whether the lbr.replication of the current ServerID is set. If it is unset, set to none, ondemand, or cache, then SHAREDDATA is set to TRUE, otherwise FALSE. Dynamic queries use 'p4d -cset' so they work regardless of whether the p4d process is up or not. Some internal refactoring was necessary to ensure all variables are set before they are used. This involved a minor tweak to mkdirs.sh to remove the now-unnecessary 'sed' for SHAREDDATA when generating p4_N.vars from the template. SHAREDDATA must still be configured in mkdirs.sh because it can be run before a replica is fully configured. Goals: * Simplfy SDP configuration for complex topologies by eliminating configuration external to p4d where possible/practical. * Reduce chances for discrepancies and errors as topologies evolve over time. * Allow the p4_1.vars file to identical on all hosts in the topology, an HMS requirement. |
||
#16 | 20376 | C. Thomas Tyler |
Incorporated HMS service user naming standard into the SDP, i.e. "svc_<serverid>." Removed SVCUSER setting from mkdirs.sh accordingly. Fixed mkdirs.sh so /p4/common/etc is created if it doesn't already exist, just as the 'lib' dir is handled. Also a minor structural enhacement in instance_vars.template. Added SDP_ALWAYS_LOGIN setting to instance_vars.template, setting the default to 0 to prevent unnecessary logins. |
||
#15 | 20348 | C. Thomas Tyler |
Use pid to shutdown the p4d process. Goals: 1. Make shutdown more standard using kill/SIGTERM. 2. Make shutdown more reliable; no need to be logged in, insluated from P4AUTH, etc. 3. Use the now-built-in pid mechanism. 4. On shutdown, make it so the script doesn't return until the p4d process is well and truly down. This was implemented with some backward-compatibilty features to simplfy SDP upgrades: 1. Though the p4_N.vars file should add the required '--pid-flag' to P4D_FLAGS, this new p4d_base checks and adds it if it is missing. 2. The old 'p4 admin stop' logic is retained as a new 'admin_stop' function, and is used if the server.pid file does not exist when stop is called. |
||
#14 | 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. |
||
#13 | 19965 | C. Thomas Tyler |
The Ultimate Perforce Login Script. Enhanced p4login v3.1.0: * If on a replica/edge server, logs in replication service users. * Uses 'p4 login -a' for non-service type accounts, and 'p4 login 'for service type accounts. * Accounts for auth.id, and behaves appropriately whether auth.id is set or not, e.g. doing an extra 'p4 login' as needed if auth.id isn't set. * Logs in external automaiton users, e.g. trigger or broker filter script users, if defined by the SDP_AUTOMATION_USERS setting in /p4/common/config/p4_<instance>.vars. * Fixed bug where it broke if p4_vars wasn't sourced. It now sources p4_vars. * Logs whether actual 'p4 login' commands were needed and the number of logins done, along with other cosmetic logging enhancements. * Added Version identifier. |
||
#12 | 19314 | Russell C. Jackson (Rusty) |
Change p4verify.sh to use -S to verify shelves on a replica instead of printing the files on the shelf. Removed the HOST_IP settings from mkdirs and instance_vars since it causes problems in a shared depotdata environment, and it was a temporary fix to work around a bug with auth.id that is being fixed. |
||
#11 | 18969 | C. Thomas Tyler |
Just moved the P4DTG setting from between some P4Web settings. This is a minor code cleanup/readability thing with no function impact. |
||
#10 | 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. |
||
#9 | 18852 | C. Thomas Tyler | Enhanced P4DTG config to be more SDP-ified. | ||
#8 | 16335 | C. Thomas Tyler |
Routine Merge Down to dev from main using: p4 merge -b perforce_software-sdp-dev |
||
#7 | 14136 | C. Thomas Tyler |
Routine merge down to dev from main for SDP using perforce_software-sdp-dev. |
||
#6 | 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. |
||
#5 | 12923 | C. Thomas Tyler |
Routine merge down from main to dev. Resolved with 'p4 resolve -as', no merges or conflicts. |
||
#4 | 12028 | C. Thomas Tyler | Refreshed SDP dev branch, merging down from main. | ||
#3 | 11523 | Russell C. Jackson (Rusty) |
Modified P4BROKERPORTNUM to just be the port number and added P4BROKERPORT to instance_vars to be consistent with P4PORT. Also makes it easier to modify p4review.py to use P4BROKERPORT rather than P4PORT for the subject line when needed. |
||
#2 | 11490 | Russell C. Jackson (Rusty) |
Added SSL_PREFIX back and P4MASTERPORTNUM in order to support the sync_replica.sh and weekly_sync_replica.sh scripts. |
||
#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/instance_vars.template | |||||
#1 | 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. |