snaprep

git mirror of https://ccx.te2000.cz/bzr/snaprep
git clone https://ccx.te2000.cz/git/snaprep
Log | Files | Refs

snap.push (667B)


      1 #!/bin/sh
      2 : ${SNAP_SRCS:=.}
      3 
      4 usage() {
      5 	printf >&2 "Usage: %s: [-S SNAP_SRCS] [-D SNAP_DST] [-] [RSYNC_ARGS]\n" $(basename "$0")
      6 	exit 2
      7 }
      8 
      9 die() {
     10 	printf "%s\n" "$*"
     11 	exit 1
     12 }
     13 
     14 while getopts S:D: opt; do
     15 	case $opt in
     16 		(S) SNAP_SRCS=$OPTARG;;
     17 		(D) SNAP_DST=$OPTARG;;
     18 		(?) usage;;
     19 		(h) usage;;
     20 	esac
     21 done
     22 shift $(($OPTIND - 1))
     23 
     24 case $1 in
     25 	(-) shift;;
     26 	(--) shift;;
     27 esac
     28 
     29 if test -z "$SNAP_DST"; then
     30 	echo >&2 "SNAP_DST is required either as env var or argument"
     31 	usage
     32 fi
     33 
     34 SNAP_SRCS=${SNAP_SRCS%%/}
     35 SNAP_DST=${SNAP_DST%%/}
     36 
     37 export SNAP_DST
     38 
     39 snap.missing "$SNAP_SRCS/" "${SNAP_DST%.push}/" | while read ts; do
     40 	snap.push.single -S "$SNAP_SRCS/$ts" - "$@"
     41 done