#!/bin/bash set -u function msg () { echo -e "$*"; } function bail () { msg "Error: $1"; exit ${2:-1}; } function usage () { msg "Usage:\n\t${0##*/} <user>\n"; exit 1; } declare Ckp= declare CkpMod= declare TemplateOwner=perforce declare TemplateStorageBase=/p4/1/tmp/dt declare TemplateStorage= declare Proj=jam declare TemplateSet=s1 declare TemplateName=${Proj}-${TemplateSet} declare RepoStorageBase=/p4/1/tmp/u declare RepoStorage= #declare User=Unset declare User=quinn declare -i Force=0 declare -i shiftArgs=0 set +u while [[ $# -gt 0 ]]; do case $1 in (-f) Force=1;; (-u) User=$2; shiftArgs=1;; (-h) usage -h;; (-man) usage -man;; (-V) show_versions; exit 1;; (-v1) export VERBOSITY=1;; (-v2) export VERBOSITY=2;; (-v3) export VERBOSITY=3;; (-v4) export VERBOSITY=4;; (-v5) export VERBOSITY=5;; (-L) export P4U_LOG=$2; shiftArgs=1;; (-si) SilentMode=1;; (-n) export NO_OP=1;; (-D) set -x;; # Debug; use 'set -x' mode. (*) if [[ $User == Unset ]]; then User=$1 else usageError "Unknown arg ($1)." fi ;; esac # Shift (modify $#) the appropriate number of times. shift; while [[ $shiftArgs -gt 0 ]]; do [[ $# -eq 0 ]] && usageError "Bad usage." shiftArgs=$shiftArgs-1 shift done done set -u export P4ENVIRO=/dev/null/.p4enviro [[ $User == Unset ]] && usage RepoStorage=${RepoStorageBase}/$User/$ TemplateStorage=${TemplateStorageBase}/${Proj}-${TemplateSet} if [[ -d $TemplateStorage/.p4root ]]; then msg "Using template $TemplateStorage." else bail "Could not find a suitable template. Checked: $TemplateStorage" fi RepoStorage=${RepoStorageBase}/${User}/${Proj} if [[ -d $RepoStorage ]]; then if [[ $Force -eq 1 ]]; then /bin/rm -rf $RepoStorage || bail "Failed to remove existing repo dir: $RepoStorage." else bail "Repo already exists at $RepoStorage." fi fi mkdir -p $RepoStorage || bail "Failed to create repo storage dir: $RepoStorage." msg "Snap/Cloning from $TemplateStorage to $RepoStorage." rsync -a $TemplateStorage/ $RepoStorage || bail "Failed to snap/clone template repo." msg "Massaging data". cd $RepoStorage/.p4root || bail "Failed to cd to $RepoStorage/.p4root" p4 admin checkpoint Ckp=$RepoStorage/.p4root/backups/back.ckp.1 CkpMod=${Ckp}.mod sed -e 's:@perforce@:@${User}@:g' \ $Ckp > $CkpMod # For safety, disable server vars so 'p4 init' doesn't go haywire on p4d. unset P4PORT P4ROOT P4JOURNAL P4LOG P4DEBUG P4AUDIT /bin/rm -rf $RepoStorage/.p4root/db.* p4d -r $RepoStorage/.p4root -jr $CkpMod msg "Done. Enjoy your repo in: $RepoStorage" exit 0
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#6 | 19956 | Perforce maintenance | Refactored. | ||
#5 | 19955 | Perforce maintenance | Added notes. | ||
#4 | 19953 | Perforce maintenance |
flexclone.sh is taking shape. Added test script. |
||
#3 | 19952 | Perforce maintenance | Milestone PoC. | ||
#2 | 19951 | Perforce maintenance | wip. | ||
#1 | 19950 | Perforce maintenance | Added flexclone script, wip. |