On 2019-11-14, Klemens Nanni <[email protected]> wrote:
> Feedback? OK?
Here's a bunch more script tweaks. This is somewhat style/personal
preference territory. --exclude can be used with listing mode.
--- reposync.orig Thu Nov 14 21:24:57 2019
+++ reposync Thu Nov 14 21:32:45 2019
@@ -31,30 +31,30 @@
force=false
fwduser=anoncvs
while getopts "fl:p" c; do
- case "$c" in
+ case $c in
f) force=true ;;
- l) fwduser="$OPTARG" ;;
- p) fwduser="" ;;
+ l) fwduser=$OPTARG ;;
+ p) fwduser= ;;
*) usage ;;
esac
done
shift $((OPTIND-1))
-[ $# -gt 0 ] || usage
+(( $# > 0 )) || usage
-synchost="$1"
+synchost=$1
repodir=${2:-/cvs}
run_rsync()
{
if [[ -n $fwduser ]]; then
# reach rsync on the server via an ssh port-forward
- rsync -e "ssh -W localhost:rsync -l $fwduser" $* 2>&1
+ rsync -e "ssh -W localhost:rsync -l $fwduser" "$@" 2>&1
else
- rsync $* 2>&1
+ rsync "$@" 2>&1
fi
}
-rundir="/var/db/reposync"
+rundir=/var/db/reposync
for i in "$rundir" "$repodir"; do
[[ ! -d $i ]] || [[ ! -w $i ]] &&
@@ -65,9 +65,9 @@
err "should be run by the uid owning the repository"
fi
-oldhash="invalid"
-hashfile="$rundir/reposync.hash"
-lockfile="$rundir/reposync.lock"
+oldhash=invalid
+hashfile=$rundir/reposync.hash
+lockfile=$rundir/reposync.lock
cd $rundir
if [[ -h $lockfile ]]; then
@@ -90,7 +90,7 @@
# check CVSROOT directory listing to identify updates; primarily for
# ChangeLog but val-tags may also be updated after a checkout was done
# using a new tag. ignore "history" (lists read-only operations).
-_t="$(run_rsync ${synchost}/CVSROOT/ | grep -v history)"
+_t=$(run_rsync --exclude='history*' ${synchost}/CVSROOT/)
[[ -n $fwduser ]] && case $_t in
"stdio forwarding failed"*|"Stdio forwarding request failed"*)
err "mirror does not support ssh port-forwarding" ;;
@@ -103,7 +103,7 @@
# result in a change there so also do a full update run at least
# every 6h.
if ((age < 6*60*60)); then
- oldhash=`cat $hashfile`
+ oldhash=$(< $hashfile)
fi
fi
--
Christian "naddy" Weisgerber [email protected]