#!/bin/bash #============================================================================== # Copyright and license info is available in the LICENSE file included with # the Server Deployment Package (SDP), and also available online: # https://swarm.workshop.perforce.com/projects/perforce-software-sdp/view/main/LICENSE #------------------------------------------------------------------------------ # # Use "chkconfig --add p4broker_REPL_SDP_INSTANCE_init" to set up the script # to start and stop automatically. # # Perforce Init Script. # chkconfig: - 90 30 # description: Start Perforce broker instance REPL_SDP_INSTANCE # Usage: p4broker_REPL_SDP_INSTANCE_init start|stop|status|restart [<ConfigTag>|all] # The ConfigTag can use the special values 'all'. For example, # 'p4d_REPL_SDP_INSTANCE_init status all' can be used to determine # which broker configuration(s) are running. When starting mulitple # broker configurations, be sure they are not configured to listen on # the same port. If ConfigTag is omitted, it is the equivalent of # specifying 'default'. # # The default broker config is /p4/common/config/p4_N.broker.cfg, (where # N is the instance name), which can be overridden on specifc machines if # there exists a file named /p4/common/config/p4_N.broker.<short-hostname>.cfg. # # Additional broker config files can be defined by creating broker config # files named /p4/common/config/p4_N.broker.YourTagName.cfg, e.g. # /p4/common/config/p4_N.broker.dfm.cfg (the "Down For Maintenance" config # file.). declare OpMode=${1:-status} declare ConfigTag=${2:-default} declare ConfigTagList= declare -i ExitStatus=0 # Load SDP shell environment for Instance REPL_SDP_INSTANCE. source /p4/common/bin/p4_vars REPL_SDP_INSTANCE || exit 1 if [[ "$ConfigTag" == "all" ]]; then ConfigTagList="default $(cd ${P4CCFG}; ls ${P4SERVER}.broker.*.cfg | cut -d '.' -f 3)" ConfigTagList=$(echo $ConfigTagList) else ConfigTagList=$ConfigTag fi for tag in $ConfigTagList; do if [[ $tag == default ]]; then if [[ -r /p4/common/config/${P4SERVER}.broker.${HOSTNAME%%.*}.cfg ]]; then export P4BROKERCFG=${P4CCFG}/${P4SERVER}.broker.${HOSTNAME%%.*}.cfg else export P4BROKERCFG=${P4CCFG}/${P4SERVER}.broker.cfg fi else export P4BROKERCFG=${P4CCFG}/${P4SERVER}.broker.${tag}.cfg fi if [[ ! -r "$P4BROKERCFG" ]]; then echo -e "\nError: Missing broker config file $P4BROKERCFG.\n" ExitStatus=1 continue fi $P4CBIN/p4broker_base "$OpMode" "$tag" || ExitStatus=1 done exit $ExitStatus
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#13 | 20491 | C. Thomas Tyler |
Fixed an environment insulation bug in init scripts. More testing (and thinking) revealed that the only way to truly provide a guarantee of insulation from user-set defaults in ~perforce/.bashrc (etc.) is to pass SDP_INSTANCE as a parameter to the *_base scripts, so that the instance name is explicitly passed into the su/exec call (when run as root). This change also includes minor cleanup in init scripts and *_base scripts. |
||
#12 | 20448 | C. Thomas Tyler |
Fixed env bug seen when running init scripts as root. Updated *_base scripts and *_init script templates to a new standard. Goals: 1. Init scripts that use corresponding *_base scripts are minimized so that do nothing more than set SDP_INSTANCE and then call the corresponding *_base script. 2. The 'su' commands always pass $* instead of $1, deferring all processing to the *_base script. 3. The shell environment is now guaranteeds to have the same results regardless of whether it is called as 'root' or as the defined OSUSER. 4. The p4_vars file is always sourced exactly once. Two calls to 'source p4_vars' appear in some cases, one immediatley before the su/exec call, and another after the after the 'su/exec'. Only one or the other is sourced. 5. All init scripts have a reasonably consistent usage message. 6. All init scripts accept a 'status' argument. This change fixes a bug where 'p4broker_N_init status' run as the 'perforce' user would report many pids unrelated to Perforce if run as root, e.g. doing 'service p4broker_N_init status'. This also eliminates a potential issue where the 'perforce' user might source a p4_vars with a default instance in ~/.profile or ~/.bashrc, thus invalidating the instance specified when the user ran the init script as root. |
||
#11 | 20341 | C. Thomas Tyler |
Tweaked all init scripts to default to 'status' (rather than an ugly syntax error) of the user forgets the start/stop/status parameter, as was done previosly for the broker init script. Removed unnecessary 'source' call when calling p4<whateve>_base scripts. Cleaned up comments. |
||
#10 | 20334 | C. Thomas Tyler |
Added support for 'all' config tag option, e.g. 'p4d_1_init status all' to find out which broker configs are running. Enhanced internal docs. |
||
#9 | 18921 | C. Thomas Tyler |
Enhanced broker init script to support multiple broker configs. This can be used to easily shutdown a production broker and replace it with a preconfigured "Down For Maintenance" broker config file. This change is backward-compatible with current typical usage. |
||
#8 | 18582 | C. Thomas Tyler | Enabled optional host-specific override p4broker init script. | ||
#7 | 16029 | C. Thomas Tyler |
Routine merge to dev from main using: p4 merge -b perforce_software-sdp-dev |
||
#6 | 13914 | C. Thomas Tyler | Applied SDP_INSTANCE to templates. | ||
#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 | 11469 | Russell C. Jackson (Rusty) |
Changed CFG to P4BROKERCFG and moved it to the p4broker init script. Changed get_pids to look for P4BROKERCFG rather than P4BROKERBIN so that it only kills the broker instances running the config specified by the init script. This change makes it easy to just copy the p4broker_instance_init script and change the config file name to be able to run more than one broker per instance of Perforce. Useful to have one ssl and one non ssl broker. |
||
#2 | 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. |
||
#1 | 10638 | C. Thomas Tyler | Populate perforce_software-sdp-dev. | ||
//guest/perforce_software/sdp/main/Server/Unix/p4/common/etc/init.d/p4broker_instance_init.template | |||||
#1 | 10148 | C. Thomas Tyler | Promoted the Perforce Server Deployment Package to The Workshop. |