#! /bin/sh RSYNC=no SCP=no SF=no STC_ATLAS_ROOT=no STC_ATLAS_NONROOT=no while getopts acDd:h:Rrs opt; do case $opt in a ) RSYNC=yes ;; c ) SCP=yes ;; D ) delete="--del" ;; d ) remote_dir="$OPTARG" ;; h ) RSYNC=yes; force_remote_hosts="$OPTARG" ;; R ) RSYNC=yes; STC_ATLAS_ROOT=yes ;; r ) RSYNC=yes; STC_ATLAS_NONROOT=yes ;; s ) RSYNC=yes; SF=yes ;; esac done shift `expr $OPTIND - 1` if [ -z "$1" ]; then echo "Usage: $0 [-acDRrs] [-h remote_hosts] [-d remote_dir] files..." >&2 exit 1 fi if [ $RSYNC = no -a $SCP = no -a $SF = no -a \ $STC_ATLAS_ROOT = no -a $STC_ATLAS_NONROOT = no -a \ -z "$force_remote_hosts" ]; then echo "Usage: $0 [-acDRrs] [-h remote_hosts] [-d remote_dir] files..." >&2 echo "Use at least one of [-acRrs] or [-h remote_hosts]" >&2 exit 1 fi for d in "$@"; do if [ "$d" = .. \ -o \( "$PWD" = "$HOME" -a \( "$d" = Downloads -o "$d" = mnt -o "$d" = tmp \) \) \ -o \( "$PWD" = "$HOME"/mnt -a \( "$d" = misc -o "$d" = net -o "$d" = usb \) \) \ -o \( "$PWD" = "$HOME"/tmp -a \( "$d" = inpx \) \) \ ]; then echo "Cannot sync \"$d\"!" >&2 exit 1 fi done if [ -n "$force_remote_hosts" ]; then rsync_hosts="$force_remote_hosts" else [ $RSYNC = yes ] && rsync_hosts="`run-hosts -aL`" # Don't use `run-hosts -DLs` here because of full paths sf_hosts="shell.sourceforge.net:/home/users/p/ph/phd/ web.sourceforge.net:/home/users/p/ph/phd/" [ "$SF" = yes ] && rsync_hosts="$rsync_hosts $sf_hosts" [ "$STC_ATLAS_ROOT" = yes ] && rsync_hosts="$rsync_hosts `run-hosts -DLR`" [ "$STC_ATLAS_NONROOT" = yes ] && rsync_hosts="$rsync_hosts `run-hosts -DLr`" fi if [ -z "$remote_dir" ]; then remote_dir=`pwd | sed "s@^$HOME/@@"` fi if [ "$remote_dir" = "$HOME" ]; then remote_dir=. fi if [ $RSYNC = yes ]; then for remote_host in $rsync_hosts; do if echo "$remote_host" | grep -Fqv : ; then remote_host="$remote_host:" fi rsync -ahPv $delete "$@" "$remote_host$remote_dir/" done fi if [ $SCP = yes ]; then [ -n "$force_remote_hosts" ] && scp_hosts="$force_remote_hosts" for remote_host in $scp_hosts; do scp -rp4 "$@" "$remote_host$remote_dir/" done fi #if [ "$STC_ATLAS_ROOT" = yes -o "$STC_ATLAS_NONROOT" = yes ]; then # exec "$HOME"/archive/STCnet-Atlas-STM/distribute-home "$@" #fi