#!/bin/sh # Build a list of files changed since the last # update and send them all to the ftp server. # Excludes emacs' backup files ("*[~#]"). # # Relies upon the .netrc feature of ftp # to handle the login. # # When using 'tails' option, only sends the last 4k # of the file over. Much faster updates to the usual # log files that way. # # Usage: doupdate [noindex | indexonly | pretend | tails [size] | help] # trap "echo ABORTED;exit 0" INT INDEX=f if [ $# -lt 1 ] ; then INDEX=t else case $1 in i*) INDEX=only;; p*) INDEX=list;; n*) INDEX=f;; t*) INDEX=tails;; h*|-*) echo usage: $0 "[noindex | indexonly | pretend | tails]"; exit 0;; esac fi if [ $INDEX = "t" -o $INDEX = "only" ] ; then echo "Making index..." ./chronolog echo "Making reverse index..." ./chronolog chronorevlog.html r [ $INDEX = "only" ] && exit 0 fi [ $INDEX != "list" ] && echo "Transferring new files..." TAILS=4096 if [ $INDEX = "tails" -a $# == 2 ] ; then TAILS=$2 fi LIST=`find . -type f -a ! -name '*[~#]' -a ! -name '.*' -a ! -name '*+' -a ! -name newerthanflash -a -cnewer newerthan` LIST2=`for file in $LIST; do SIZE=0 [ -f $file ] && SIZE=$(ls -l $file|sh -c 'read p l u g s r; echo $s') [ $file = "chronolog.html" ] && SIZE=0 [ $file = "chronorevlog.html" ] && SIZE=0 if [ $INDEX = "tails" -a $SIZE -ge $TAILS ] ; then echo restart $(expr $SIZE - $TAILS) echo put $file else echo put $file transfer echo ren transfer $file fi done` if [ -z "$LIST" ] ; then echo "No out-of-date files found" exit 0 fi if [ $INDEX = "list" ] ; then echo $LIST exit 0 else echo "Ready to transfer:" echo "$LIST" | sed 's/^/ /' fi # Don't touch the timestamp file if the ftp fails! # Hash mode seems to be a little more reliable when the network's being bad. if ftp -v userweb.windwireless.net <<-EOT cd public_html bin hash $LIST2 EOT then touch newerthan; fi # # To automatically check in (snapshot) recently modified files do: # # find . -maxdepth 1 -name \*.html ! -name chrono\* -perm +200 -exec ci -msnapshot -u {} \; #