#!/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 #------------------------------------------------------------------------------ export SDP_INSTANCE=${SDP_INSTANCE:-Undefined} export SDP_INSTANCE=${1:-$SDP_INSTANCE} if [[ $SDP_INSTANCE == Undefined ]]; then echo "Instance parameter not supplied." echo "You must supply the Perforce instance as a parameter to this script." exit 1 fi . /p4/common/bin/p4_vars $SDP_INSTANCE AWK=awk ID=id MAIL=mail OS=`uname` if [ "${OS}" = "SunOS" ] ; then AWK=/usr/xpg4/bin/awk ID=/usr/xpg4/bin/id MAIL=mailx elif [ "${OS}" = "AIX" ] ; then AWK=awk ID=id MAIL=mail fi export AWK export ID export MAIL cd /p4/common/bin common_dir=`pwd -P` . /p4/common/bin/backup_functions.sh if [[ -d $common_dir ]]; then cd $common_dir else echo $common_dir does not exist. exit 1 fi ######### Start of Script ########## check_vars set_vars LOGFILE=$LOGS/upgrade.log.$(date +'%Y:%m:%d-%H:%M:%S') check_dirs check_uid [[ -f $common_dir/p4 ]] || { echo "No p4 in $common_dir" ; exit 1 ;} [[ -f $common_dir/p4d ]] || { echo "No p4d in $common_dir" ; exit 1 ;} chmod 777 $common_dir/p4 chmod 700 $common_dir/p4d [[ -f $common_dir/p4broker ]] && chmod 755 $common_dir/p4broker P4RELNUM=`./p4 -V | grep -i Rev. | $AWK -F / '{print $3}'` P4DRELNUM=`./p4d -V | grep -i Rev. | $AWK -F / '{print $3}'` P4BLDNUM=`./p4 -V | grep -i Rev. | $AWK -F / '{print $4}' | awk '{print $1}'` P4DBLDNUM=`./p4d -V | grep -i Rev. | $AWK -F / '{print $4}' | awk '{print $1}'` CURRENT_RELNUM=`./p4d_${SDP_INSTANCE}_bin -V | grep -i Rev. | $AWK -F / '{print $3}'` log "Start $P4SERVER Upgrade" [[ -f p4_$P4RELNUM.$P4BLDNUM ]] || cp p4 p4_$P4RELNUM.$P4BLDNUM [[ -f p4d_$P4DRELNUM.$P4DBLDNUM ]] || cp p4d p4d_$P4DRELNUM.$P4DBLDNUM [[ -f p4_${P4RELNUM}_bin ]] && unlink p4_${P4RELNUM}_bin ln -s p4_$P4RELNUM.$P4BLDNUM p4_${P4RELNUM}_bin >> "$LOGFILE" 2>&1 [[ -f p4d_${P4DRELNUM}_bin ]] && unlink p4d_${P4DRELNUM}_bin ln -s p4d_$P4DRELNUM.$P4DBLDNUM p4d_${P4DRELNUM}_bin >> "$LOGFILE" 2>&1 [[ -f p4_bin ]] && unlink p4_bin ln -s p4_${P4RELNUM}_bin p4_bin >> "$LOGFILE" 2>&1 if [[ -L p4broker_${SDP_INSTANCE}_bin ]]; then /p4/${SDP_INSTANCE}/bin/p4broker_${SDP_INSTANCE}_init stop P4BRELNUM=`./p4broker -V | grep -i Rev. | $AWK -F / '{print $3}'` P4BBLDNUM=`./p4broker -V | grep -i Rev. | $AWK -F / '{print $4}' | $AWK '{print $1}'` [[ -f p4broker_$P4BRELNUM.$P4BBLDNUM ]] || cp p4broker 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 /p4/${SDP_INSTANCE}/bin/p4broker_${SDP_INSTANCE}_init start fi /p4/common/bin/p4login if [[ "$P4REPLICA" == "FALSE" ]] || [[ $EDGESERVER -eq 1 ]]; then get_journalnum fi stop_p4d # Don't upgrade the database for minor upgrades if [[ $CURRENT_RELNUM != $P4DRELNUM ]]; then # Only rotate the journal on the master. if [[ "$P4REPLICA" == "FALSE" ]] && [[ $EDGESERVER -eq 0 ]]; then truncate_journal get_offline_journal_num replay_journals_to_offline_db fi unlink p4d_${SDP_INSTANCE}_bin >> "$LOGFILE" 2>&1 ln -s p4d_${P4DRELNUM}_bin p4d_${SDP_INSTANCE}_bin >> "$LOGFILE" 2>&1 $P4DBIN -r $P4ROOT -J off -xu >> "$LOGFILE" 2>&1 # Upgrade the offline database on the master and on edge servers. if [[ "$P4REPLICA" == "FALSE" ]] || [[ $EDGESERVER -eq 1 ]]; then $P4DBIN -r $OFFLINE_DB -J off -xu >> "$LOGFILE" 2>&1 fi fi start_p4d log "Finish $P4SERVER Upgrade"
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19278 | trina | "Forking branch Main of perforce-software-sdp to trina-sdp." | ||
//guest/perforce_software/sdp/main/Server/Unix/p4/common/bin/upgrade.sh | |||||
#10 | 18619 | Russell C. Jackson (Rusty) | Updating main with current changes. | ||
#9 | 16534 | Russell C. Jackson (Rusty) | Corrected upgrade logic to not try to rotate the journal on an edge server. | ||
#8 | 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. |
||
#7 | 15777 | C. Thomas Tyler |
No functional changes. Style Policing only on bash scripts only. Normalized indentation and line breaks, removed offending tabs, and general whitespace usage. |
||
#6 | 15609 | C. Thomas Tyler | Pushing SDP 2015.1.15607 (2015/09/02). | ||
#5 | 13908 | C. Thomas Tyler | Pushing SDP 2015.1.13906. | ||
#4 | 12171 | Russell C. Jackson (Rusty) | Merge in changes to remove the need for p4master_run. | ||
#3 | 11524 | Russell C. Jackson (Rusty) | Released updated version of the SDP from Dev. | ||
#2 | 11459 | mark_foundry |
Fixing the location of the upgrade.log. Previously, it would try to write to /upgrade.log, which requires root permissions. So changed to use $LOGS which is what backupfunctions.sh uses, and is defined in p4vars. I've only tested upgrade.sh, as I don't have a pre-2013.3 server. |
||
#1 | 10148 | C. Thomas Tyler | Promoted the Perforce Server Deployment Package to The Workshop. |