Add script to pull clones easily.

This commit is contained in:
2026-03-29 16:57:03 -07:00
parent 1cc57721f7
commit 7dcf55629d

47
bin-shared/pull-clone.sh Executable file
View File

@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# TBD:
# - merge into send-master script and use a variable to control push vs pull.
## Variables ##
PROG="$(basename -- "${BASH_SOURCE[0]}")"
loop=false
DIR="`pwd`"
dir="`basename $DIR`"
## Validations ##
if [[ "$DIR" != *"-clone" ]]; then
echo "'$DIR' is not labeled as a clone. Skipping download."
exit 0
fi
## Main ##
echo "`date` - Pulling" \
"'$PROD_DATA_USER@$PROD_DATA_HOST:$PROD_DATA_PORT$PROD_DATA_DIR/$dir'" \
"to '$dir'."
sleep=0
while true; do
if (( $sleep > 0 )); then
echo "Sleeping for '$sleep' seconds..."
sleep $sleep
fi
clone -e "ssh -p $PROD_DATA_PORT" \
$PROD_DATA_USER@$PROD_DATA_HOST:$PROD_DATA_DIR/$new_dir \
. &&
echo "`date` - Success!" ||
echo "`date` - Failed!"
sleep=30
if [[ "$loop" == false ]]; then
break;
fi
done
## Complete ##
echo "`date` - $PROG complete."
exit 0