#!/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 #------------------------------------------------------------------------------ set -u # Change the first three variables below to match the volume names on the machine # you are configuring the SDP on. # Set the remaining variables appropriately. The meaning of each should be obvious. # Before running this script, create a configuration file. You can use a # single configuration file named mkdirs.cfg in the same directory as this # mkdirs.sh script. Alternately, you can create a file named mkdirs.N.cfg, # where 'N' is the name of the instance you intend to configure. # # Run this script as root, and pass in the instance number you are configuring. # # If you do not have root access, then some commands will be skipped, and you # will need to have the defined $P4DIR directory already existing (created by # the root user and the ownership changed to the OS user that you are planning # to run Perforce under). The /hxmetadata*, /hxdepots and /hxlogs volumes will # also need to be owned by the OS user as well in order for the script to work. # You can then run this script as the OS user for Perforce and everything # should work fine. # # This script creates an init script in the $P4DIR/$SDP_INSTANCE/bin directory. # You can use it from there if you are configuring a cluster, or you can link # it in /etc/init.d if you are setting up a stand alone machine. Sample # systemd service files are included in the systemd folder. # # After running this script, set up the crontab based on templates # generated in $P4DIR/common/etc/cron.d. For convenience, a sample generated # is to $P4DIR/p4.crontab. # # Next, put the license file in place in the P4ROOT dir, and launch the server with the init # script. # # Then run $P4DIR/common/bin/p4master_run <instance> $P4DIR/common/bin/live_checkpoint.sh # and then run both the daily_checkpoint.sh and recreate_db_checkpoint.sh to # make sure everything is working before setting up the crontab. # # Also run $P4DIR/common/bin/p4master_run <instance> $P4DIR/common/bin/p4review.py <instance> # to make sure the review script is working properly. If you intend to use # Swarm, you can skip configuration of the review daemon, and instead configure # Swarm to handle review-style email notifications. # # UPGRADING SDP # Specify the -test parameter to the script. # In this case the script will NOT make the various directories under $P4DIR, # but will instead create /tmp/p4 directory structure with the various files # processed via templates etc. You can then manually compare this directory # structure with your existing $P4DIR structure and manually copy the various # files into it. function msg () { echo -e "$*"; } function errmsg () { msg "\\nError: (line: ${BASH_LINENO[0]}) $*" >&2; } function warnmsg () { msg "\\nWarning: (line: ${BASH_LINENO[0]}) $*"; } function bail() { errmsg "(line: ${BASH_LINENO[0]}) ${1:-Unknown Error}\n" >&2; exit "${2:-1}"; } function usage () { msg "Usage:\\n\\t${0##*/} <instance> [-test]\\n" exit 1 } declare -i DoChownCommands=1 if [ $# -lt 1 ] || [ $# -gt 2 ]; then usage fi # Verify instance value. SDP_INSTANCE=$1 if [[ "$SDP_INSTANCE" == "-test" ]]; then bail "An instance argument is required." fi # Note that if the following is set to 1 then a trial run is done, into /tmp/p4 TEST=0 if [[ $# -gt 1 && "$2" == "-test" ]]; then TEST=1 fi # Check for config file - same dir as this script if [[ -r "${0%/*}/mkdirs.${SDP_INSTANCE}.cfg" ]]; then mkdirs_config="${0%/*}/mkdirs.${SDP_INSTANCE}.cfg" elif [[ -r "${0%/*}/mkdirs.cfg" ]]; then mkdirs_config="${0%/*}/mkdirs.cfg" else bail "Missing mkdirs config file $mkdirs_config." fi # shellcheck disable=SC1090 source "$mkdirs_config" || bail "Failed to source $mkdirs_config." if [[ -r "$SDP/Version" ]]; then # shellcheck disable=SC2086 SDP_VERSION="$(cat "$SDP/Version")" else SDP_VERSION="Rev. SDP/Unix/UNKNOWN" fi P4DIR=/p4 P4SERVER="p4_$SDP_INSTANCE" export AWK=awk export ID=id export MAIL=mail OS=$(uname) if [[ "${OS}" = "SunOS" ]] ; then export AWK=/usr/xpg4/bin/awk export ID=/usr/xpg4/bin/id export MAIL=mailx elif [[ "${OS}" = "AIX" ]] ; then export AWK=awk export ID=id export MAIL=mail fi if [[ $($ID -u) -eq 0 ]]; then msg "Verified: Running as root." elif [[ $(whoami) == "$OSUSER" ]]; then warnmsg "Not running as root; chown commands will be skipped and basic directories must exist.\n" DoChownCommands=0 else bail "$0 must be run as as root or $OSUSER.\n" fi if [[ $TEST -eq 1 ]]; then # CN has prefix CN=/tmp DB1=tmp/hxmetadata1 DB2=tmp/hxmetadata2 DD=tmp/hxdepots LG=tmp/hxlogs mkdir -p /$DB1 /$DB2 /$DD /$LG P4DIR=/tmp/p4 msg "\n********* -test specified - will install to $P4DIR *********\n" fi SDP_COMMON="$SDP/Server/Unix/p4/common" declare -i PreflightOK=1 [[ -f "$SDP_COMMON/bin/p4" ]] || { errmsg "No p4 in $SDP_COMMON/bin"; PreflightOK=0; } [[ -f "$SDP_COMMON/bin/p4d" ]] || { errmsg "No p4d in $SDP_COMMON/bin"; PreflightOK=0; } [[ -f "$SDP_COMMON/bin/p4p" ]] || warnmsg "No p4p in $SDP_COMMON/bin" [[ -f "$SDP_COMMON/bin/p4broker" ]] || warnmsg "No p4broker in $SDP_COMMON/bin" if [[ $TEST -eq 1 && ! -d "$P4DIR" ]]; then mkdir "$P4DIR" || bail "Failed to create $P4DIR." fi # If we aren't running as root, extend the preflight checks to verify basic dirs # exist. if [[ $($ID -u) -ne 0 && $TEST -eq 0 ]]; then for d in "$P4DIR" "/$DD" "/$DB1" "/$DB2" "/$LG"; do if [[ -d "$d" ]]; then # shellcheck disable=SC2012 disable=SC2016 dirOwner=$(ls -ld "$d" | $AWK '{print $3}') # shellcheck disable=SC2012 disable=SC2016 dirGroup=$(ls -ld "$d" | $AWK '{print $4}') if [[ "$dirOwner" != "$OSUSER" ]]; then errmsg "Dir [$d] exists but with wrong owner, $dirOwner instead of $OSUSER." PreflightOK=0 fi if [[ "$dirGroup" != "$OSGROUP" ]]; then warnmsg "Dir [$d] exists but with wrong group, $dirGroup instead of $OSGROUP." fi else errmsg "Dir must exist if not running as root: $d" PreflightOK=0 fi done fi if [[ $PreflightOK -eq 1 ]]; then msg "Verified: Preflight checks passed." else bail "Aborting due to failed preflight checks." fi chmod 755 "$SDP_COMMON/bin/p4" chmod 700 "$SDP_COMMON/bin/p4d" [[ -f "$SDP_COMMON/bin/p4broker" ]] && chmod 700 "$SDP_COMMON/bin/p4broker" [[ -f "$SDP_COMMON/bin/p4web" ]] && chmod 700 "$SDP_COMMON/bin/p4web" [[ -f "$SDP_COMMON/bin/p4p" ]] && chmod 700 "$SDP_COMMON/bin/p4p" # Make sure you update the p4 and p4d to the latest versions in the # sdp/Server/Unix/p4/common/bin directory when making new instances at a later date. # shellcheck disable=SC2016 P4RELNUM=$("$SDP_COMMON/bin/p4" -V | grep -i Rev. | $AWK -F / '{print $3}') # shellcheck disable=SC2016 P4BLDNUM=$("$SDP_COMMON/bin/p4" -V | grep -i Rev. | $AWK -F / '{print $4}' | $AWK '{print $1}') # shellcheck disable=SC2016 P4DRELNUM=$("$SDP_COMMON/bin/p4d" -V | grep -i Rev. | $AWK -F / '{print $3}') # shellcheck disable=SC2016 P4DBLDNUM=$("$SDP_COMMON/bin/p4d" -V | grep -i Rev. | $AWK -F / '{print $4}' | $AWK '{print $1}') [[ -d "$P4DIR" ]] || mkdir "$P4DIR" [[ -d "/$DD/p4" ]] || mkdir "/$DD/p4" [[ -d "/$DB1/p4" ]] || mkdir "/$DB1/p4" [[ -d "/$DB2/p4" ]] || mkdir "/$DB2/p4" [[ -d "/$LG/p4" ]] || mkdir "/$LG/p4" mkdir -p "/$LG/p4/$SDP_INSTANCE/tmp" mkdir -p "/$DD/p4/$SDP_INSTANCE/depots" mkdir -p "/$DD/p4/$SDP_INSTANCE/checkpoints" # Group the server_type values from mkrep.sh and mkdirs.cfg to simplify code paths in this script # Any not mentioned (e.g. p4d_edge) remain the same case "$SERVER_TYPE" in (p4d_ha|p4d_ham|p4d_ro|p4d_rom|p4d_fr|p4d_frm|p4d_fs|p4d_fsm|p4d_ffr) SERVER_TYPE=p4d_replica ;; (p4d_master|p4d_edge|p4d_replica|p4d_standby|p4broker|p4proxy) /bin/true ;; (*) bail "\\nError: Unrecognized replica type [$SERVER_TYPE].";; esac case "$SERVER_TYPE" in (p4d_standby) mkdir -p "/$LG/p4/$SDP_INSTANCE/journals.rep" if [[ $DoChownCommands -eq 1 ]]; then chown "$OSUSER:$OSGROUP" "/$LG/p4/$SDP_INSTANCE/journals.rep" fi ;; (p4d_replica|p4d_edge|p4d_ha|p4d_ham) mkdir -p "/$DD/p4/$SDP_INSTANCE/checkpoints.${REPLICA_ID#p4d_}" if [[ $DoChownCommands -eq 1 ]]; then chown "$OSUSER:$OSGROUP" "/$DD/p4/$SDP_INSTANCE/checkpoints.${REPLICA_ID#p4d_}" fi ;; esac [[ -d "$P4DIR/ssl" ]] || mkdir -p "$P4DIR/ssl" [[ -f "$SDP/Server/Unix/p4/ssl/config.txt" && ! -f "$P4DIR/ssl/config.txt" ]] &&\ cp "$SDP/Server/Unix/p4/ssl/config.txt" "$P4DIR/ssl/" if [[ "$CN" == "" ]]; then # When blank we put on "local" drive [[ -d "$P4DIR/common/bin" ]] || mkdir -p "$P4DIR/common/bin" [[ -d "$P4DIR/common/config" ]] || mkdir -p "$P4DIR/common/config" else # (default) put it on hxdepots or where specified [[ -d "$CN/p4/common" ]] || mkdir -p "$CN/p4/common" [[ -L "$P4DIR/common" ]] || ln -s "$CN/p4/common" "$P4DIR/common" [[ -d "$CN/p4/common/bin" ]] || mkdir -p "$CN/p4/common/bin" [[ -d "$CN/p4/common/config" ]] || mkdir -p "$CN/p4/common/config" fi mkdir -p "/$DB1/p4/$SDP_INSTANCE/db1/save" mkdir -p "/$DB2/p4/$SDP_INSTANCE/db2/save" mkdir -p "/$LG/p4/$SDP_INSTANCE/logs" cd "/$DD/p4/$SDP_INSTANCE" || bail "Could not cd to /$DD/p4/$SDP_INSTANCE" # Create /p4/1 on local disk as a directory # Then the links within it cd "$P4DIR" || bail "Could not cd to $P4DIR" [[ -d "$SDP_INSTANCE" ]] || mkdir "$SDP_INSTANCE" cd "$SDP_INSTANCE" || bail "Could not cd to $SDP_INSTANCE" [[ -d bin ]] || mkdir bin [[ -L root ]] || ln -s "/$DB1/p4/$SDP_INSTANCE/db1" root [[ -L offline_db ]] || ln -s "/$DB2/p4/$SDP_INSTANCE/db2" offline_db if [[ ! -d logs ]]; then # shellcheck disable=SC2226 [[ -L logs ]] || ln -s "/$LG/p4/$SDP_INSTANCE/logs" fi # shellcheck disable=SC2226 [[ -L depots ]] || ln -s "/$DD/p4/$SDP_INSTANCE/depots" # shellcheck disable=SC2226 [[ -L checkpoints ]] || ln -s "/$DD/p4/$SDP_INSTANCE/checkpoints" # shellcheck disable=SC2226 [[ -L tmp ]] || ln -s "/$LG/p4/$SDP_INSTANCE/tmp" case "$SERVER_TYPE" in (p4d_standby) # shellcheck disable=SC2226 [[ -L journals.rep ]] || ln -s "/$LG/p4/$SDP_INSTANCE/journals.rep" ;; (p4d_replica|p4d_edge) # shellcheck disable=SC2226 [[ -L "checkpoints.${REPLICA_ID#p4d_}" ]] || ln -s "/$DD/p4/$SDP_INSTANCE/checkpoints.${REPLICA_ID#p4d_}" esac [[ -L "$P4DIR/sdp" ]] || ln -s "$SDP" "$P4DIR/sdp" case "$SERVER_TYPE" in (p4d_master|p4d_edge) SERVERID="$MASTER_ID" echo "$SERVERID" > "$P4DIR/$SDP_INSTANCE/root/server.id" ;; (p4d_replica|p4d_standby) SERVERID="$REPLICA_ID" echo "$SERVERID" > "$P4DIR/$SDP_INSTANCE/root/server.id" ;; (*) SERVERID="$SERVER_TYPE" ;; esac [[ -f "$P4DIR/common/bin/p4_$P4RELNUM.$P4BLDNUM" ]] || cp "$SDP_COMMON/bin/p4" "$P4DIR/common/bin/p4_$P4RELNUM.$P4BLDNUM" [[ -f "$P4DIR/common/bin/p4d_$P4DRELNUM.$P4DBLDNUM" ]] || cp "$SDP_COMMON/bin/p4d" "$P4DIR/common/bin/p4d_$P4DRELNUM.$P4DBLDNUM" if [[ ! -f "$P4DIR/common/bin/p4_vars" ]]; then cp -R "$SDP_COMMON"/bin/* "$P4DIR/common/bin" # Copy certain subdirs of /p4/common if don't already exist. for dir in etc lib; do if [[ ! -d "$P4DIR/common/$dir" ]]; then cp -pr "$SDP_COMMON/$dir" "$P4DIR/common/." fi done cd "$P4DIR/common/bin" || bail "Could not cd to $P4DIR/common/bin" ln -s "p4_$P4RELNUM.$P4BLDNUM" "p4_${P4RELNUM}_bin" ln -s "p4d_$P4DRELNUM.$P4DBLDNUM" "p4d_${P4DRELNUM}_bin" ln -s "p4_${P4RELNUM}_bin" "p4_bin" sed -e "s:REPL_SDPVERSION:${SDP_VERSION}:g" \ -e "s/REPL_OSUSER/${OSUSER}/g" \ "$SDP_COMMON/config/p4_vars.template" > p4_vars fi cd "$P4DIR/common/bin" || bail "Could not cd to $P4DIR/common/bin" ln -s "p4d_${P4DRELNUM}_bin" "p4d_${SDP_INSTANCE}_bin" if [[ ! -e "$P4DIR/common/config/.p4passwd.${P4SERVER}.admin" ]]; then echo "$P4ADMINPASS" > "$P4DIR/common/config/.p4passwd.${P4SERVER}.admin" else warnmsg "Skipping update of existing admin password file $P4DIR/common/config/.p4passwd.${P4SERVER}.admin" fi if [[ ! -e "$P4DIR/common/config/.p4passwd.${P4SERVER}.service" ]]; then echo "$P4SERVICEPASS" > "$P4DIR/common/config/.p4passwd.${P4SERVER}.service" else warnmsg "Skipping update of existing service password file $P4DIR/common/config/.p4passwd.${P4SERVER}.service" fi # Create broker links if broker exists if [[ -f "$SDP_COMMON/bin/p4broker" ]]; then # shellcheck disable=SC2016 P4BRELNUM=$("$SDP_COMMON/bin/p4broker" -V | grep -i Rev. | $AWK -F / '{print $3}') # shellcheck disable=SC2016 P4BBLDNUM=$("$SDP_COMMON/bin/p4broker" -V | grep -i Rev. | $AWK -F / '{print $4}' | $AWK '{print $1}') [[ -f "$P4DIR/common/bin/p4broker_$P4BRELNUM.$P4BBLDNUM" ]] || cp "$SDP_COMMON/bin/p4broker" "$P4DIR/common/bin/p4broker_$P4BRELNUM.$P4BBLDNUM" [[ -L "p4broker_${P4BRELNUM}_bin" ]] && unlink "p4broker_${P4BRELNUM}_bin" ln -s "p4broker_$P4BRELNUM.$P4BBLDNUM" "p4broker_${P4BRELNUM}_bin" [[ -L "p4broker_${SDP_INSTANCE}_bin" ]] && unlink "p4broker_${SDP_INSTANCE}_bin" ln -s "p4broker_${P4BRELNUM}_bin" "p4broker_${SDP_INSTANCE}_bin" cd "$P4DIR/$SDP_INSTANCE/bin" || \ bail "Could not cd to $P4DIR/$SDP_INSTANCE/bin" [[ -L "p4broker_${SDP_INSTANCE}" ]] || ln -s "$P4DIR/common/bin/p4broker_${SDP_INSTANCE}_bin" "p4broker_${SDP_INSTANCE}" sed "s/REPL_SDP_INSTANCE/${SDP_INSTANCE}/g" "$SDP_COMMON/etc/init.d/p4broker_instance_init.template" > "p4broker_${SDP_INSTANCE}_init" chmod +x "p4broker_${SDP_INSTANCE}_init" fi # Create p4p links if p4p exists cd "$P4DIR/common/bin" || bail "Could not cd to $P4DIR/common/bin" if [[ -x "$SDP_COMMON/bin/p4p" ]]; then # shellcheck disable=SC2016 P4PRELNUM=$("$SDP_COMMON/bin/p4p" -V | grep -i Rev. | $AWK -F / '{print $3}') # shellcheck disable=SC2016 P4PBLDNUM=$("$SDP_COMMON/bin/p4p" -V | grep -i Rev. | $AWK -F / '{print $4}' | $AWK '{print $1}') [[ -f "$P4DIR/common/bin/p4p_$P4PRELNUM.$P4PBLDNUM" ]] || cp "$SDP_COMMON/bin/p4p" "$P4DIR/common/bin/p4p_$P4PRELNUM.$P4PBLDNUM" [[ -L "p4p_${P4PRELNUM}_bin" ]] && unlink "p4p_${P4PRELNUM}_bin" ln -s "p4p_$P4PRELNUM.$P4PBLDNUM" "p4p_${P4PRELNUM}_bin" [[ -L "p4p_${SDP_INSTANCE}_bin" ]] && unlink "p4p_${SDP_INSTANCE}_bin" ln -s "p4p_${P4PRELNUM}_bin" "p4p_${SDP_INSTANCE}_bin" cd "$P4DIR/$SDP_INSTANCE/bin" || \ bail "Could not cd to $P4DIR/$SDP_INSTANCE/bin" [[ -L "p4p_${SDP_INSTANCE}" ]] || ln -s "$P4DIR/common/bin/p4p_${SDP_INSTANCE}_bin" "p4p_${SDP_INSTANCE}" sed -e "s/REPL_SDP_INSTANCE/${SDP_INSTANCE}/g" \ -e "s/REPL_DNSNAME/${P4DNSNAME}/g" \ "$SDP_COMMON/etc/init.d/p4p_instance_init.template" > "p4p_${SDP_INSTANCE}_init" chmod +x "p4p_${SDP_INSTANCE}_init" mkdir -p "/$DD/p4/$SDP_INSTANCE/cache" fi cd "$P4DIR/$SDP_INSTANCE/bin" || bail "Could not cd to $P4DIR/$SDP_INSTANCE/bin" ln -s "$P4DIR/common/bin/p4_bin" "p4_$SDP_INSTANCE" sed "s/REPL_SDP_INSTANCE/${SDP_INSTANCE}/g" \ "$SDP_COMMON/etc/init.d/p4d_instance_init.template" > "p4d_${SDP_INSTANCE}_init" chmod +x "p4d_${SDP_INSTANCE}_init" # Moved the less commonly used, but always created init scripts to an init directory. mkdir init cd init || bail "Could not cd to $PWD/init" sed "s/REPL_SDP_INSTANCE/${SDP_INSTANCE}/g" \ "$SDP_COMMON/etc/init.d/p4dtg_instance_init.template" > "p4dtg_${SDP_INSTANCE}_init" chmod +x "p4dtg_${SDP_INSTANCE}_init" cd .. || bail "Could not cd to .. from $PWD" if [[ $CASE_SENSITIVE -eq 1 ]]; then ln -s "$P4DIR/common/bin/p4d_${SDP_INSTANCE}_bin" "p4d_$SDP_INSTANCE" else echo '#!/bin/bash' > "p4d_$SDP_INSTANCE" echo "P4D=/p4/common/bin/p4d_${SDP_INSTANCE}_bin" >> "p4d_$SDP_INSTANCE" # shellcheck disable=SC2016 echo 'exec $P4D -C1 "$@"' >> "p4d_$SDP_INSTANCE" chmod +x "p4d_$SDP_INSTANCE" fi cd "$P4DIR/common/config" || bail "Could not cd to $P4DIR/common/config" sed -e "s/REPL_MAILTO/${MAILTO}/g" \ -e "s/REPL_MAILFROM/${MAILFROM}/g" \ -e "s/REPL_ADMINUSER/${ADMINUSER}/g" \ -e "s/REPL_MASTER_ID/${MASTER_ID}/g" \ -e "s/REPL_SSLPREFIX/${SSL_PREFIX}/g" \ -e "s/REPL_P4PORT/${P4_PORT}/g" \ -e "s/REPL_P4BROKERPORT/${P4BROKER_PORT}/g" \ -e "s/REPL_P4WEBPORT/${P4WEB_PORT}/g" \ -e "s/REPL_P4FTPPORT/${P4FTP_PORT}/g" \ -e "s/REPL_DNSNAME/${P4DNSNAME}/g" \ -e "s/REPL_P4P_TARGET_PORT/${P4P_TARGET_PORT}/g" \ "$SDP_COMMON/config/instance_vars.template" > "p4_${SDP_INSTANCE}.vars" sed -e "s/REPL_ADMINISTRATOR/${MAILTO}/g" \ -e "s/REPL_COMPLAINFROM/${COMPLAINFROM}/g" \ -e "s/REPL_MAILHOST/${MAILHOST}/g" \ -e "s/REPL_DNSNAME/${P4DNSNAME}/g" \ "$SDP_COMMON/config/p4review.cfg.template" > "p4_${SDP_INSTANCE}.p4review.cfg" cd "$P4DIR" || bail "Could not cd to $P4DIR" if [[ ! -f "${P4DIR}/p4.crontab" ]]; then CRONTAB_NAME=p4.crontab else CRONTAB_NAME=p4.crontab.new rm -f "${P4DIR}/$CRONTAB_NAME" > /dev/null 2>&1 msg "Existing crontab found, writing new crontab to ${P4DIR}/${CRONTAB_NAME}" fi sed -e "s/REPL_MAILTO/${MAILTO}/g" \ -e "s/REPL_MAILFROM/${MAILFROM}/g" \ -e "s/REPL_INSTANCE/${SDP_INSTANCE}/g" \ "$SDP_COMMON/etc/cron.d/template.crontab.combined" > "$CRONTAB_NAME" if [[ $DoChownCommands -eq 1 ]]; then chown "$OSUSER:$OSGROUP" "$CRONTAB_NAME" fi if [[ -r "$SDP/Maintenance/template.maintenance.cfg" ]]; then msg "Appending configuration section [$SDP_INSTANCE] to $SDP/Maintenance/maintenance.cfg" [[ -r "$SDP/Maintenance/maintenance.cfg" ]] && chmod +w "$SDP/Maintenance/maintenance.cfg" echo -e "[$SDP_INSTANCE]" >> "$SDP/Maintenance/maintenance.cfg" sed -e "s/REPL_INSTANCE/$SDP_INSTANCE/g" \ -e "s/REPL_ADMINISTRATOR/${MAILTO}/g" \ -e "s/REPL_COMPLAINFROM/${COMPLAINFROM}/g" \ -e "s/REPL_MAILHOST/${MAILHOST}/g" \ -e "s/REPL_DOMAIN/${COMPLAINFROM_DOMAIN}/g" \ "$SDP/Maintenance/template.maintenance.cfg" >> "$SDP/Maintenance/maintenance.cfg" fi cd "$P4DIR/${SDP_INSTANCE}/bin" || \ bail "Could not cd to $P4DIR/${SDP_INSTANCE}/bin" if [[ "$SHAREDDATA" == "TRUE" ]]; then if [[ "$SERVER_TYPE" == p4d_replica || "$SERVER_TYPE" == p4d_standby ]]; then msg "Configuring Replica sharing depot data with master, skipping chown/chmod of depot files" DoChownCommands=0 fi fi if [[ $DoChownCommands -eq 1 ]]; then if [[ $TEST -eq 0 ]]; then chown "$OSUSER:$OSGROUP" "/$DD" chown "$OSUSER:$OSGROUP" "/$LG" chown "$OSUSER:$OSGROUP" "/$DB1" chown "$OSUSER:$OSGROUP" "/$DB2" fi chown "$OSUSER:$OSGROUP" "/$DD/p4" chown "$OSUSER:$OSGROUP" "/$LG/p4" chown "$OSUSER:$OSGROUP" "/$DB1/p4" chown "$OSUSER:$OSGROUP" "/$DB2/p4" chown -h "$OSUSER:$OSGROUP" "$P4DIR" chown -h "$OSUSER:$OSGROUP" "$P4DIR/$SDP_INSTANCE" chown -h "$OSUSER:$OSGROUP" "$P4DIR/common" [[ $TEST -eq 0 ]] && chown -h "$OSUSER:$OSGROUP" "$P4DIR/sdp" chown "$OSUSER:$OSGROUP" $P4DIR/* chown -Rh "$OSUSER:$OSGROUP" "$P4DIR/common/" [[ $TEST -eq 0 ]] && chown -Rh "$OSUSER:$OSGROUP" "$P4DIR/sdp" chown -Rh "$OSUSER:$OSGROUP" "$P4DIR/common" chown -Rh "$OSUSER:$OSGROUP" "/$DB1/p4/$SDP_INSTANCE" chown -Rh "$OSUSER:$OSGROUP" "/$DB2/p4/$SDP_INSTANCE" chown -Rh "$OSUSER:$OSGROUP" "/$LG/p4/$SDP_INSTANCE" if [[ "$SHAREDDATA" == "FALSE" ]]; then msg "Setting ownership on depot files - this may take some time ..." chown -Rh "$OSUSER:$OSGROUP" "/$DD/p4/$SDP_INSTANCE" fi chown -Rh "$OSUSER:$OSGROUP" "$P4DIR/$SDP_INSTANCE/bin" else msg "Skipped chown/chmod commands for large directory trees." fi chmod 700 "/$DB1/p4" chmod 700 "/$DB2/p4" chmod 700 "/$DD/p4" chmod 700 "/$LG/p4" chmod -R 700 "/$DB1/p4/$SDP_INSTANCE" chmod -R 700 "/$DB2/p4/$SDP_INSTANCE" chmod -R 700 "$P4DIR/common" chmod -R 700 "/$LG/p4/$SDP_INSTANCE" if [[ "$SHAREDDATA" == "FALSE" ]]; then msg "Setting permissions on depot files - this may take some time ..." chmod -R 700 "/$DD/p4/$SDP_INSTANCE" fi if [[ "$SDP_INSTANCE" != "$MASTERINSTANCE" ]]; then if [[ -f "$P4DIR/$MASTERINSTANCE/root/license" ]]; then ln -s "$P4DIR/$MASTERINSTANCE/root/license" "$P4DIR/$SDP_INSTANCE/root/license" chown -h "$OSUSER:$OSGROUP" "$P4DIR/$SDP_INSTANCE/root/license" fi fi chmod 755 "$P4DIR/${SDP_INSTANCE}"/bin/*_init chmod 755 "$P4DIR/${SDP_INSTANCE}"/bin/init/*_init chmod 600 "$P4DIR/common/config/.p4passwd.${P4SERVER}.admin" chmod 600 "$P4DIR/common/config/.p4passwd.${P4SERVER}.service" find "$P4DIR/common/bin/" -name "*.cfg" -exec chmod 600 {} \; find "$P4DIR/common/bin/" -name "*.html" -exec chmod 600 {} \; chmod 700 "$P4DIR/ssl" find "$P4DIR/ssl/" -type f -exec chmod 600 {} \; if [[ $DoChownCommands -eq 1 ]]; then chown -R "$OSUSER:$OSGROUP" "$P4DIR/ssl" find "$P4DIR/$SDP_INSTANCE/" -type l -user root -exec chown -h "$OSUSER:$OSGROUP" {} \; fi if [[ $TEST -eq 1 ]]; then msg " This was done in TEST mode - please run the following command to see any changes should be applied to your live environment (manually): diff -r /p4/$SDP_INSTANCE/bin $P4DIR/$SDP_INSTANCE/bin diff -r /p4/common $P4DIR/common If upgrading an older SDP version then be careful to ensure files in /p4/common/config are correct and update that /p4/common/bin/p4_vars is appropriate.\n" fi exit 0
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#92 | 30388 | C. Thomas Tyler |
Released SDP 2024.1.30385 (2024/06/11). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#91 | 30043 | C. Thomas Tyler |
Released SDP 2023.2.30041 (2023/12/22). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#90 | 29891 | C. Thomas Tyler |
Released SDP 2023.1.29699 (2023/07/11). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#89 | 29701 | C. Thomas Tyler |
Released SDP 2023.1.29699 (2023/07/11). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#88 | 29623 | C. Thomas Tyler |
Released SDP 2023.1.29621 (2023/05/25). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#87 | 29401 | C. Thomas Tyler |
Released SDP 2022.2.29399 (2023/02/06). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#86 | 29205 | C. Thomas Tyler |
Released SDP 2022.1.29203 (2022/11/22). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#85 | 28412 | C. Thomas Tyler |
Released SDP 2021.2.28410 (2021/11/24). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#84 | 28240 | C. Thomas Tyler |
Released SDP 2021.1.28238 (2021/11/12). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#83 | 27901 | C. Thomas Tyler |
Released SDP 2020.1.27899 (2021/07/13). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#82 | 27822 | C. Thomas Tyler |
Released SDP 2020.1.27820 (2021/06/19). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#81 | 27761 | C. Thomas Tyler |
Released SDP 2020.1.27759 (2021/05/07). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#80 | 27400 | C. Thomas Tyler |
Released SDP 2020.1.27398 (2021/02/06). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#79 | 27331 | C. Thomas Tyler |
Released SDP 2020.1.27325 (2021/01/29). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#78 | 26246 | C. Thomas Tyler |
Released SDP 2019.3.26239 (2020/01/08). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#77 | 26161 | C. Thomas Tyler |
Released SDP 2019.3.26159 (2019/11/06). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#76 | 25933 | C. Thomas Tyler |
Released SDP 2019.2.25923 (2019/08/05). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#75 | 25596 | C. Thomas Tyler |
Released SDP 2019.2.25594 (2019/05/02). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#74 | 25483 | C. Thomas Tyler |
Released SDP 2019.1.25480 (2019/04/11). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#73 | 25389 | C. Thomas Tyler |
Released SDP 2019.1.25386 (2019/03/21). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#72 | 25380 | C. Thomas Tyler |
Released SDP 2019.1.25374 (2019/03/21). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#71 | 25317 | Robert Cowham | Copy up logic fix to mkdirs.sh to fix breaking test | ||
#70 | 25311 | C. Thomas Tyler |
Released SDP 2019.1.25309 (2019/03/07). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#69 | 25245 | C. Thomas Tyler |
Released SDP 2019.1.25238 (2019/03/02). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#68 | 23595 | C. Thomas Tyler |
Released SDP 2018.1.23583 (2018/02/08). Patch release to fix bug in mkdirs.sh (SDP-287). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev', with selective removal of work-in-progress files. |
||
#67 | 23510 | C. Thomas Tyler |
Released SDP 2018.1.23504 (2018/01/19). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev', with selective removal of work-in-progress files. |
||
#66 | 23357 | C. Thomas Tyler |
Released SDP 2017.4.23354 (2017/12/08). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#65 | 23331 | C. Thomas Tyler |
Released SDP 2017.4.23329 (2017/12/05). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#64 | 23006 | C. Thomas Tyler |
Released SDP 2017.3.23003 (2017/10/19). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#63 | 22950 | akwan | Provide an override for difference between proxy listening port and target port | ||
#62 | 22685 | Russell C. Jackson (Rusty) | Update main with current changes from dev. | ||
#61 | 22207 | C. Thomas Tyler |
Released SDP 2017.2.22201 (2017/05/18). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#60 | 22185 | C. Thomas Tyler |
Released SDP 2017.2.22177 (2017/05/17). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#59 | 21483 | C. Thomas Tyler |
Released SDP 2016.2.21480 (2017/01/11). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#58 | 21338 | C. Thomas Tyler |
Released SDP 2016.2.21328 (2016/12/16). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#57 | 21193 | Russell C. Jackson (Rusty) | Update main from dev. | ||
#56 | 21128 | C. Thomas Tyler |
Released SDP 2016.2.21123 (2016/11/22). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#55 | 21105 | C. Thomas Tyler |
Released SDP 2016.2.21103 (2016/11/21). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#54 | 20997 | C. Thomas Tyler |
Released SDP 2016.2.20995 (2016/11/07). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#53 | 20974 | C. Thomas Tyler |
Released SDP 2016.2.20972 (2016/11/01). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#52 | 20792 | C. Thomas Tyler |
Released SDP 2016.2.20790 (2016/09/30). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#51 | 20767 | C. Thomas Tyler |
Released SDP 2016.2.20755 (2016/09/29). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#50 | 20481 | C. Thomas Tyler |
Released SDP 2016.1.20460. Copy Up using 'p4 copy -r -b perforce_software-sdp-dev', with selective removal of changes related to work-in-progress files. |
||
#49 | 20398 | C. Thomas Tyler |
Released SDP 2016.1.20395. Copy Up using 'p4 copy -r -b perforce_software-sdp-dev', with selective removal of changes related to work-in-progress files. |
||
#48 | 20390 | C. Thomas Tyler |
Released SDP 2016.1.20387. Copy Up using 'p4 copy -r -b perforce_software-sdp-dev', with selective removal of changes related to work-in-progress files. |
||
#47 | 20353 | C. Thomas Tyler |
Released SDP 2016.1.20348. Copy Up using 'p4 copy -r -b perforce_software-sdp-dev', with selective removal of changes related to work-in-progress changes. |
||
#46 | 20050 | C. Thomas Tyler |
Released: 2016.1.20028 (2016/08/03). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#45 | 19414 | C. Thomas Tyler | Released SDP/MultiArch/2016.1/19410 (2016/05/17). | ||
#44 | 18961 | C. Thomas Tyler | Released: SDP/MultiArch/2016.1/18958 (2016/04/08). | ||
#43 | 18619 | Russell C. Jackson (Rusty) | Updating main with current changes. | ||
#42 | 18530 | Russell C. Jackson (Rusty) | Update main from dev. | ||
#41 | 16554 | C. Thomas Tyler |
Changed storage for /p4/<n>/tmp dir to the /logs volume. The /logs volume is typically local, and is not backed up. Both of these characteristics are desirable for TMP/P4TMP. We don't want to pay the typically high latency tax of shared storage solutions used for the /depotdata for TMP/P4TMP. And we don't want to needlessly backup up a folder whose name implies it's not backed up. To Do: * Make the corresponding change in the Windows SDP. * Adjust docs as needed. #review-16527 @russell_jackson |
||
#40 | 16370 | C. Thomas Tyler |
Changed 'p4admin' to 'perforce' as the default SDP P4USER, now that LDAP integration is the prevailing norm. #review-15815 |
||
#39 | 16348 | Russell C. Jackson (Rusty) |
Added check for exiting binaries in /p4/common/bin since those will be the most up to date versions in an existing installation. The check helps when going back and adding another instance at a later date and you forgot to update the binaries in the SDP folder. Guess how I found that out... |
||
#38 | 16265 | Robert Cowham | Fix tests broken by previous few changes. | ||
#37 | 16259 | Russell C. Jackson (Rusty) |
Created P4MASTERPORT in instance_vars to simplify logins to the master server in the other scripts. Changed other scripts to use P4MASTERPORT Added clean up of statejcopy and checkpoints.rep directory to weekly_sync_replica so that it properly resets a replica that is using journalcopy. Moved umask to instance_vars since it wasn't being picked up when running things via crontab Removed P4REPLICANAME from instance_vars since it wasn't being used anymore. Added HOSTIP to mkdirs and to the P4PORT setting in instance vars so the server starts on a specific IP address rather than all on the server. This avoids a bug where rpl.forward.login doesn't work when logging in via localhost. |
||
#36 | 15856 | C. Thomas Tyler |
Replaced the big license comment block with a shortened form referencing the LICENSE file included with the SDP package, and also by the URL for the license file in The Workshop. |
||
#35 | 15691 | Russell C. Jackson (Rusty) |
Changed to always create a checkpoints.rep directory on the logs volume so that moving the pre-rotated journal back to be the live journal will be a move operation when doing a failover. Added a SHAREDDATA setting to p4_vars so that I could check for that in sync_replica and weekly_sync replica. That allowed me to delete weekly_sync_shared_replica and sync_shared_replica. Added cleanup of checkpoints.rep to sync_replica and weekly_sync_replica since that is where the replica journals should always be located now. Removed cleanup of checkpoints.rep from daily and weekly backup scripts since those should not be handling replica file clean up. The SDP is now designed to be used with the journalcopy and p4 pull -L commands rather than the old style replication using just pull. Failover requires that you move the pre-rotated journal that is in the checkpoints.rep directory back to /p4/${SDP_INSTANCE}/logs/journal now along with updating the server.id file. |
||
#34 | 14073 | Russell C. Jackson (Rusty) |
Backed out changes that moved variables to p4_vars. The variables are intended to be in instance vars to keep everything about a particular instance in one location. It was confusing for people to see a setting in p4_vars and not understand that setting was being overridden in the instance vars. There shouldn't be any overlap between p4_vars and instance vars anymore. Also, server.id is not optional. It must exist. It is how you control whether the instance is a master or a replica. It is not set by the scripts anymore because that was also confusing people. They would try to change the role of a server by changing server.id and we previously would just overwrite their changes. Now, the SDP just reads the server.id so that the user has control over it. That doesn't confuse them since that is how our docs tells them to change a server's role. |
||
#33 | 14045 | Robert Cowham |
Move some stuff from instance_vars to p4_vars (or at least for defaults). Clarify user messages. |
||
#32 | 13991 | Robert Cowham |
Clarify comments re SSL Prefix. Also test mode informational messages. |
||
#31 | 13908 | C. Thomas Tyler | Pushing SDP 2015.1.13906. | ||
#30 | 12964 | Russell C. Jackson (Rusty) | Updated p4review complain from address. | ||
#29 | 12387 | Robert Cowham |
Change warning re not running as root. Also clarify test output. |
||
#28 | 12329 | Russell C. Jackson (Rusty) |
Added check so script doesn't try to link logs when the logs directory is on the depotdata volume. |
||
#27 | 12150 | Robert Cowham | Fix test breakage - check for existence of ssl files before chmod'ing them | ||
#26 | 12113 | Russell C. Jackson (Rusty) |
Moved ssl dir to /p4. There is no need for an ssl directory under each instance. There are also some signs of possible issues with the certificates residing on an NFS mounted volume in one environment so far. |
||
#25 | 12067 | Russell C. Jackson (Rusty) |
Changed mkdirs.sh to default to 1666 and added comment to replace the broker with command triggers. Added simple command trigger to block commands in the server. |
||
#24 | 12008 | Russell C. Jackson (Rusty) | Added comment about the init directory. | ||
#23 | 11975 | Russell C. Jackson (Rusty) | Skip chown on /tmp | ||
#22 | 11919 | Russell C. Jackson (Rusty) |
Added a SERVERID variable to p4_vars and updated backup_functions to use it. Changed the location and the names of the config files so that they could live in /p4/common/config (You're welcome Tom). The files names are: p4_$INSTANCE.vars p4_$INSTANCE.p4review.cfg p4_$INSTANCE.vars will now set P4REPLICA to FALSE if SERVERID matches MASTERNAME, otherwise it is TRUE. This change means that a user must change server.id now in order to change the role of the server rather than changing the instance vars file. This makes more sense to a user that is reading the admin guide about server.id rather than overwriting the file based on a setting that isn't in the admin guide. Change mkdirs to reflect all of the above changes. |
||
#21 | 11913 | Russell C. Jackson (Rusty) | Added _ between instance and port in complain from. | ||
#20 | 11912 | Russell C. Jackson (Rusty) | Corrected the location of a $ in the commented variables. | ||
#19 | 11909 | adrian_waters | Change commented out entry P4PORT->P4_PORT so if uncomment the block of env settings if want auto-generated port numbers it doesn't fail unbound test (later code now used P4_PORT) | ||
#18 | 11906 | adrian_waters | fix @11903 - to ensure comparing /p4 against /tmp/p4 when in test mode | ||
#17 | 11903 | adrian_waters | Fix issue introduced in @11877 - the echo'd diff statements at end should compare /p4 against $P4DIR when in test mode | ||
#16 | 11885 | adrian_waters | Add setting to trap unbounded variables; caught/fixed one instance of error around test mode, so enhanced 'usage' check & test mode processing; excluded setting ownership/perms on /tmp/p4/sdp in test mode | ||
#15 | 11884 | adrian_waters | fix comparison to support non-numeric instance | ||
#14 | 11883 | adrian_waters | fix unbounded use of P4BROKER_PORT_END (variable removed in #2) | ||
#13 | 11878 | Russell C. Jackson (Rusty) |
Corrected crontab name to p4.crontab in output when crontab's exist. Corrected test to remove p4.crontab and p4.crontab.replica - All Reb's fault. |
||
#12 | 11877 | Russell C. Jackson (Rusty) |
Changed all occurences of /p4 to $P4DIR Fixed a couple of places that were missed to use SDP_COMMON. |
||
#11 | 11876 | Russell C. Jackson (Rusty) |
Changed to stop copying test and etc to the /p4/common folder since they are not needed there. All etc files are generated during the mkdirs.sh run from the sdp area. Cleaned up path names using a SDP_COMMON and got rid of ETC_DIR. Changed crontab and crontab.replica to p4.crontab and p4.crontab.replica |
||
#10 | 11857 | Russell C. Jackson (Rusty) |
Added a setting to control if checkpoints.rep gets created or not, and then a check to see if that directory exists. If it does, we reset CHECKPOINTS and run it a second time in the daily and weekly in order to keep the checkpoints.rep directory cleaned up when using a shared depotdata volume. |
||
#9 | 11796 | Russell C. Jackson (Rusty) |
Changed the chmod 750 so that it doesn't run over all the existing instances. That would make it horribly slow to create additional instances in an existing installation with a lot of files. Added variable to define the master instance, and then used that for making links to the license file and ssl dir in the master instance. This fixed a bug where we were checking for instance 1 for linking the license file. We cannot make that assumption when supporting named instances. |
||
#8 | 11729 | Russell C. Jackson (Rusty) |
Added check to only create crontab files if they don't exist. Otherwise tell the user to copy the section and update the instance. Also moved the times in the replica out to allow more time for the checkpoint to complete. |
||
#7 | 11724 | adrian_waters | SDP/mkdirs.sh - fix bug that prevents MAILTO being subsituted in the crontab / crontab.replica files | ||
#6 | 11723 | adrian_waters | SDP/mkdirs.sh - fix bug that stopped REPL_MAILTO being substituted in p4_vars | ||
#5 | 11720 | adrian_waters | Put extra trap to catch accidental missing of the instance param when running in test mode - otherwise get '-test' directories created! | ||
#4 | 11679 | Russell C. Jackson (Rusty) | Added section you can uncomment to use 666 for port if desired. | ||
#3 | 11570 | Russell C. Jackson (Rusty) |
Brought in changes from Mark Foundry to add -S $MAILFROM to mail commands. Changed sync_replica.sh and weekly_sync_replica.sh to use $LOGFILE for consistency. Added mail command to both files as well. |
||
#2 | 11524 | Russell C. Jackson (Rusty) | Released updated version of the SDP from Dev. | ||
#1 | 10148 | C. Thomas Tyler | Promoted the Perforce Server Deployment Package to The Workshop. |