#!/bin/bash # ========== # $File: //guest/amo/scripts/triggers/proxyload.sh $ # $Revision: #2 $ # $Change: 24630 $ # # $Author: amo $ # $DateTimeTZ: 2018/09/24 07:09:04 -0700 PDT $ # ---------- # Bash script called by a p4d bgtask, intended to update the proxy cache. # # Takes three parameters. # user: a user with protections necessary to sync files from the specified area # port: the P4PORT value where the proxy can be found # client: a client workspace that maps the files to be sync'd # path: the top-level depot path to be sync'd # # The script runs 'p4 -Zproxyload sync @n' using the above details, where 'n' is the value of a counter. # The counter is incremented, and next run the next revision should be sync'd. # # ---------- # Example trigger entry: # proxyload bgtask bgtask "%//scripts/triggers/proxyload.sh% amorriss myServer:3666 proxyload //..." # # Example bgtask command: # p4 bgtask -d -i5 -m100 -t proxyload # # ---------- # Next steps: # - better (or just 'some') error handling # - logging; what's the script actually doing, what's the current counter value, timestamps, etc. # # ========== user=$1 port=$2 cli=$3 path=$4 # messages usage="USAGE: $0 user port client path" nocli="ERROR: 'p4' client not found" nocon="ERROR: 'p4' not logged in or no connection available" # checking parameters provided if [ "$#" -eq 0 ]; then printf "%s\n" "$usage"; exit 1; fi # check we have 'p4' available p4cli=`which p4` if [ "$?" -ne 0 ]; then printf "%s\n%s\n" "$usage" "$nocli"; exit 2; fi # client exists, create the 'connection string' and test for a connection. p4con="$p4cli -u $user -p $port -c $cli" $p4con login -s > /dev/null 2>&1 if [ $? -ne 0 ]; then printf "%s\n%s\n" "$usage" "$nocon"; exit 3; fi # define the counter update command count=`$p4con counter -i proxyload` # proxyload-sync, at counter $p4con -Zproxyload sync -q $path@$count
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 24630 | Adam Morriss |
Correcting comment stating that the script takes three parameters, then proceeds to describe all four of them. (now says 'four' instead of 'three') |
||
#1 | 24541 | Adam Morriss | moving proxyload script to 'triggers' sub-folder | ||
//guest/amo/scripts/proxyload.sh | |||||
#1 | 24265 | Adam Morriss | Background trigger script for preloading proxy cache |