#============================================================================== # 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 #------------------------------------------------------------------------------ # Save SHELLOPTS _shellopts=$SHELLOPTS # Trap unbound (undefined) varialbes, treating them as an error. set -u # Defaulting to Perforce for backwards compatiability with old instances vars that do not have this setting. export OSUSER=perforce #Defaulting the RSYNCUSER to the OSUSER. You can override it in /p4/common/bin/p4_$instance.vars export RSYNCUSER="$OSUSER" export AWK=awk export CUT=cut export DF="df -h" export GREP=grep export ID=id export SDPMAIL=mail export PS=ps # Which perforce instance are we configuring? Defaults to 1. export SDP_INSTANCE=${1:-1} if [[ ! "$SDP_INSTANCE" =~ ^[a-zA-Z0-9_-]+$ ]]; then echo "Error: Invalid SDP_INSTANCE value: $SDP_INSTANCE" return 1 fi # The P4INSTANCE variable is deprecated, and is maintained here for backward # compatibility. The SDP_INSTANCE variable should be referenced instead, as # P4INSTANCE may go away in a future release. export P4INSTANCE="$SDP_INSTANCE" export P4SERVER="p4_${SDP_INSTANCE}" export P4SSLDIR=/p4/ssl export P4HOME="/p4/${SDP_INSTANCE}" export TMP=${P4HOME}/tmp export P4TMP=${P4HOME}/tmp # Explicitly unset environment variables that affect p4d server if they # are defined at startup, excluding those that are always defined in this # file, like P4ROOT, P4PORT, P4lOG, and P4JOURNAL. This prevents cross- # instance shell environment contamination if p4_vars is sourced multiple # times for different instances. unset P4AUTH P4CHANGE P4DEBUG P4AUDIT P4TARGET export P4ROOT=${P4HOME}/root export P4JOURNAL=${P4HOME}/logs/journal export P4CONFIG=${P4HOME}/.p4config export P4TICKETS=${P4HOME}/.p4tickets export P4TRUST=${P4HOME}/.p4trust export P4ENVIRO=/dev/null/.p4enviro export DEPOTS=${P4HOME}/depots export LOGS=${P4HOME}/logs export P4LOG=${LOGS}/log export P4CBIN=/p4/common/bin export P4CCFG=/p4/common/config # Site extension dirs: place site-local custom scripts/config here so they live # outside the SDP-managed bin/ and survive SDP updates. P4CSBIN is added to PATH. export P4CSITE=/p4/common/site export P4CSBIN=$P4CSITE/bin export PYHOME=/p4/common/python # Admin password file used by p4login. Matches this fork's historical path # (/p4/common/config/.p4passwd..admin); now exported so the modern # p4login can locate it. An optional encrypted variant is ".enc". export SDP_ADMIN_PASSWORD_FILE="$P4CCFG/.p4passwd.${P4SERVER}.admin" # Comma-separated list of external automation users for 'p4login -automation'. # Empty by default (no automation users); safe if unset. export SDP_AUTOMATION_USERS=${SDP_AUTOMATION_USERS:-""} # If set to 1, p4login forces a fresh login even when a long-term ticket exists. export SDP_ALWAYS_LOGIN=${SDP_ALWAYS_LOGIN:-0} # Snapshot-based live checkpoint (live_checkpoint.sh / snapshot_checkpoint). # Method selection: auto picks reflink -> aws -> azure -> gcp -> (fallback to the # in-place live checkpoint). 'off' disables snapshots; or pin a specific method. export SNAPSHOT_METHOD=${SNAPSHOT_METHOD:-auto} # auto|reflink|aws|azure|gcp|off # The reflink method needs NO further config. The cloud methods need the items # below (they cannot be reliably auto-discovered across hypervisors). Set per # instance (e.g. in $P4CCFG/${SERVERID}.vars) when using a cloud method: # SNAPSHOT_P4ROOT_RELPATH - path of P4ROOT within the backing volume's fs. # SNAPSHOT_MOUNT - temp mountpoint base (default ${P4TMP}/snap_mnt.). # SNAPSHOT_DELETE_AFTER - 1 to delete the source snapshot after the checkpoint # (default 0: keep it as a DR artifact). # AWS: SNAPSHOT_AWS_VOLUME (vol-... backing P4ROOT), SNAPSHOT_AWS_DEVICE # (default /dev/sdf), SNAPSHOT_AWS_AZ (default: this instance's AZ). # Azure: SNAPSHOT_AZURE_RG, SNAPSHOT_AZURE_DISK, SNAPSHOT_AZURE_DEVICE. # GCP: SNAPSHOT_GCP_ZONE, SNAPSHOT_GCP_DISK. # Cloud methods also require the provider CLI (aws/az/gcloud) + an instance role # with snapshot/volume create/attach/detach/delete permissions. if [[ ":$PATH:" != *":$P4HOME/bin:"* ]]; then export PATH=$P4HOME/bin:$P4CBIN:$P4CSBIN:$PYHOME/bin:$PATH fi export CHECKPOINTS=${P4HOME}/checkpoints export JOURNALS=${P4HOME}/journals.rotated if [[ -r ${P4ROOT}/server.id ]]; then export SERVERID="$(cat "${P4ROOT}/server.id")" else export SERVERID="server.id_not_found" fi if [[ -r ${P4ROOT}/sdp_server_type.txt ]]; then export SERVER_TYPE="$(cat "${P4ROOT}/sdp_server_type.txt")" else export SERVER_TYPE=default echo "${P4ROOT}/sdp_server_type.txt MISSING!" fi # P4Proxy Settings export P4PCACHE=$P4HOME/cache # Set Proxy monitoring level to 3 in order to monitor all traffic for all operations export PROXY_MON_LEVEL=3 # 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_checkpoint.sh, live_checkpoint.sh, # or recreate_db_checkpoint.sh are run. # Set KEEPCKPS=0 to avoid automated cleanup of checkpoints and logs. export KEEPCKPS=7 # KEEPJNLS allows you to keep a different number of journals than checkpoints # in case you rotate the journal more frequently than you run checkpoints. export KEEPJNLS=112 # 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=350 # Don't change this; change or comment the above as needed export P4BIN=${P4HOME}/bin/p4_${SDP_INSTANCE} export P4DBIN=${P4HOME}/bin/p4d_${SDP_INSTANCE} export P4PBIN=${P4HOME}/bin/p4p_${SDP_INSTANCE} export P4BROKERBIN=${P4HOME}/bin/p4broker_${SDP_INSTANCE} export P4DTGBIN=${P4HOME}/bin/p4dtg_${SDP_INSTANCE} # 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) # 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 # if 'nounset' was not in SHELLOPTS when we started, call set +u if [[ $_shellopts != *nounset* ]]; then set +u fi