p4verify.sh #3

  • //
  • guest/
  • perforce_software/
  • sdp/
  • main/
  • Server/
  • Unix/
  • p4/
  • common/
  • bin/
  • p4verify.sh
  • View
  • Commits
  • Open Download .zip Download (3 KB)
#!/bin/bash
#------------------------------------------------------------------------------
# Copyright (c) Perforce Software, Inc., 2007-2014. All rights reserved
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1  Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
# 2.  Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE
# SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.
#------------------------------------------------------------------------------

LOG=$LOGS/p4verify.log
STATUS="OK: All scanned depots verified OK."
declare -i EXIT_CODE=0
 
P4="$P4BIN -p $P4PORT -u $P4USER"
 
/p4/common/bin/p4login
 
echo If there are errors in this log, contact support@perforce.com > $LOG
 
# Verify all depots of all types except 'remote' and 'archive'.
for d in `$P4 -s depots|grep "^info: Depot " |\
   grep -v --perl-regexp "^info: Depot \S+ \d{4}\/\d{2}\/\d{2} (remote|archive|unload) " |\
   cut -d ' ' -f 3`; do
   echo === Started verify of //$d/... at $(date). >> $LOG
   if [[ "${P4REPLICA}" == "FALSE" ]]; then
      echo $P4 -s verify -qz //$d/... >> $LOG
      $P4 -s verify -qz //$d/... >> $LOG 2>&1
   else
      echo $P4 -s verify -qz -t //$d/... >> $LOG
      $P4 -s verify -qz -t //$d/... >> $LOG 2>&1
      $P4 changes -s shelved //$d/... | cut -d " " -f 2 | while read cl;do
         $P4 print //$d/...@=$cl > /dev/null
      done
   fi

   if [[ $? -ne 0 ]]; then
      STATUS="Error: Verify attempt failed.  Review the log [$LOG]."
      EXIT_CODE=1
   fi

done

for d in `$P4 depots | grep unload | cut -d " " -f 2`; do
   echo === Started verify of //$d/... at $(date). >> $LOG
   if [[ "${P4REPLICA}" == "FALSE" ]]; then
      echo $P4 -s verify -U -q //$d/... >> $LOG
      $P4 -s verify -U -q //$d/... >> $LOG 2>&1
   else
      echo $P4 -s verify -U -q -t //$d/... >> $LOG
      $P4 -s verify -U -q -t //$d/... >> $LOG 2>&1
   fi

   if [[ $? -ne 0 ]]; then
      STATUS="Error: Verify attempt failed.  Review the log [$LOG]."
      EXIT_CODE=1
   fi

done



if [[ $EXIT_CODE -eq 0 ]]; then
   if [[ -n "$(grep BAD! $LOG)" || -n "$(grep MISSING! $LOG)" || -n "$(grep p4\ help\ max $LOG)" ]]; then
       STATUS="Warning: Verify errors detected.  Review the log [$LOG]."
       EXIT_CODE=1
   fi
fi
 
echo Completed verifications at $(date). >> $LOG
 
$MAIL -s "$HOSTNAME $P4SERVER P4Verify Log ($STATUS)" -S from=$MAILFROM $MAILTO < $LOG
 
exit $EXIT_CODE
# Change User Description Committed
#30 29701 C. Thomas Tyler Released SDP 2023.1.29699 (2023/07/11).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#29 29612 C. Thomas Tyler Released SDP 2023.1.29610 (2023/05/25).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#28 29143 C. Thomas Tyler Released SDP 2022.1.29141 (2022/10/29).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#27 28989 C. Thomas Tyler Released SDP 2022.1.28987 (2022/08/25).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#26 28858 C. Thomas Tyler Released SDP 2022.1.28855 (2022/05/27).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#25 28240 C. Thomas Tyler Released SDP 2021.1.28238 (2021/11/12).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#24 27761 C. Thomas Tyler Released SDP 2020.1.27759 (2021/05/07).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#23 27331 C. Thomas Tyler Released SDP 2020.1.27325 (2021/01/29).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#22 25596 C. Thomas Tyler Released SDP 2019.2.25594 (2019/05/02).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#21 25483 C. Thomas Tyler Released SDP 2019.1.25480 (2019/04/11).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#20 25245 C. Thomas Tyler Released SDP 2019.1.25238 (2019/03/02).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#19 24966 C. Thomas Tyler Adjusted version.
#18 24961 Karl Wirth Fix for SDP-362.
Move testing of variable till after the
environment has been sourced.
#17 22185 C. Thomas Tyler Released SDP 2017.2.22177 (2017/05/17).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#16 21244 C. Thomas Tyler Released SDP 2016.2.21239 (2016/12/06).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#15 21035 C. Thomas Tyler Released SDP 2016.2.21033 (2016/11/10).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#14 20997 C. Thomas Tyler Released SDP 2016.2.20995 (2016/11/07).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#13 20974 C. Thomas Tyler Released SDP 2016.2.20972 (2016/11/01).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#12 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.
#11 19414 C. Thomas Tyler Released SDP/MultiArch/2016.1/19410 (2016/05/17).
#10 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.
#9 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.
#8 13908 C. Thomas Tyler Pushing SDP 2015.1.13906.
#7 12938 Russell C. Jackson (Rusty) Adding a missing stderr redirect.
#6 12171 Russell C. Jackson (Rusty) Merge in changes to remove the need for p4master_run.
#5 11757 Russell C. Jackson (Rusty) Made the check for the unload depot more specific so it will only pick up an unload depot, and not depots with unload as part of the name or description.
#4 11707 Robert Cowham Refactored sending of mail to a common function.
Make the setting of "MAILFROM" work for Ubuntu (GNU Mailutils) as well as CentOS
#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.