#!/usr/pkg/bin/bash function die () { echo $@ >&2 exit 1 } host=$1 if [ -z "$host" ]; then die "must specify remote host"; fi if [ ! -f $HOME/.netrc ]; then die "cannot run without $HOME/.netrc" fi user=`grep "^machine $host login " $HOME/.netrc | awk '{print $4}'` pass=`grep "^machine $host login " $HOME/.netrc | awk '{print $6}'` secure=`grep "^$host\>" $HOME/.ssh/known_hosts` if [ -z "$user" -o -z "$pass" ]; then die "no login information for $host" fi cd $HOME/www || die "cannot chdir to $HOME/www" echo Updating host $host: errors=0 if [ -f $HOME/.ftpupdate/$host.lastupdate ]; then for file in \ `find . -follow -type f -newer $HOME/.ftpupdate/$host.lastupdate`; do if echo $file | egrep -qv '\.svn|RCS|CVS'; then putfile $host "$file" $user || errors=$((errors+1)) fi done if [ "$errors" = "0" ]; then touch $HOME/.ftpupdate/$host.lastupdate echo Update successful fi else touch -t 197406201440.00 $HOME/.ftpupdate/$host.lastupdate $0 $@ fi