#!/bin/bash function bail() { msg=$1 echo -e "\nError: $1\n" exit 1 } export P4CONFIG=.p4config declare SDP=sdp case $1 in sdp.win) SDP=sdp.win *) bail "Unrecognized arg: $1";; esac if [[ -n "$MYPASSWD" ]]; then echo "Verified: MYPASSWD value is set to [$MYPASSWD]. Using it to enctrypt." else bail "The MYPASSWD environment variable is not set. Set it to a simple value with no spaces or too-funky characters. Aborting." fi cd /consulting/sw/MAIN || bail "Could not cd to [/consulting/sw/MAIN]." echo "Logging in to Perforce Production server." p4 -s login < /consulting/.p4passwd echo "Getting latest SDP files." p4 -s sync $SDP/... o=$(p4 -s opened $SDP/... 2>&1) if [[ $o == *"not opened on this client"* ]]; then echo "Verified: no files opened. Continuing." else p4 -s opened ... bail "Files opened or could not verify no files opened. Aborting." fi echo "Checking files status." o=$(p4 -s status $SDP/...) if [[ $o == *" - no file(s) to reconcile"* ]]; then echo "Verified: File 'status' checked, all files OK. Continuing." else p4 -s status $SDP/... bail "The 'p4 status' command reported differences. Aborting." fi c=$(p4 changes -m 1 ...|cut -d ' ' -f 2) tarFile=/pub/guest/tom_tyler/sw/main/dist/$SDP.$c.encrypted.tar.gz if [[ -e $tarFile ]]; then echo "Tar file [$tarFile] already exists. Aborting." else echo "Generating encrypted tar file [$tarFile]." tar -cvzpf - $SDP | openssl des3 -salt -k $MYPASSWD | dd of=$tarFile echo "Logging in to Perforce Workshop server." cd $(dirname $tarFile) || bail "Could not cd to [$(dirname $tarFile)]." p4 -s login < /pub/.p4passwd echo "Testing encrypted tar file." /bin/rm -rf $SDP || bail "Could not remove dir [$PWD/$SDP]. Test not started. Aborting." dd if=$tarFile | openssl des3 -d -k $MYPASSWD | tar -xvzpf - if [[ -d $SDP ]]; then /bin/rm -rf $SDP echo "Verified Tar file looks OK." else bail "Error: Tar file bogus!" fi fi echo "Tar file looks OK!" exit 0
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 8841 | C. Thomas Tyler |
Enhanced docs, added '-f' force flag, and added unpacking instructions. |
||
#4 | 8752 | C. Thomas Tyler | Added package check. | ||
#3 | 8750 | C. Thomas Tyler |
Enhanced to accept password as a command line flag, rather than requiring an environment variable to be set. Added command line parsing and usage message. |
||
#2 | 8748 | C. Thomas Tyler | Added support for generating Windows flavor. | ||
#1 | 8747 | C. Thomas Tyler |
Added a personal utility for generating an encrypted tar file from files on the Perforce Production server. |