problems with rdist
Joe Smith
jms at romana.Tymnet.COM
Wed Oct 17 11:21:07 AEST 1990
To add to the list of things that rdist does not do for me:
*) No bidirectional younger copy. If remote file is newer, I want it
copied to the master. (See enclosed script for a fix.)
*) Complains about remote directory having the wrong permissions instead
of fixing. (See enclosed script for a fix.)
*) If sending selected files from wildcarded directories, (such as
"/home/delta/*/{.login,.cshrc}"), it does not create missing directories.
(See enclosed script for a fix.)
*) When output is redirected to a file, rdist does not flush the buffers
after each file, and stdio buffers up 8K bytes of output. This means
that "tail -f logfile" cannot be used to monitor the progress in realtime.
(I don't have the sources to rdist to fix this.)
*) Changes to the owner, group, or mode of a file are not propagated to
the remote system unless the date (or checksum) of the file changes.
(I don't have the sources to rdist to fix this.)
----------%<-------- cut here for "fix-warnings" --------->%----------
#!/bin/sh
# Problems in the rdist procedure are located and fixed.
# In particular, wrong protection on directories and "remote file is newer".
cmds=/tmp/fix-warnings$$.1
warn=/tmp/fix-warnings$$.2
localhost=`hostname`
# The log from rdist is piped into this script as stdin.
# Typical use is:
# (echo; echo -n "==$$== --- starting $0 $*"; date) >>$logfile
# rdist -y -c some files to remotehost >>$logfile
# sed "1,/=$$=/D" $logfile | /etc/rdist/fix-warnings >>$logfile
# Where the use of =$$= is to select only messages from this run.
egrep "Warning|host|directory" | sed 's/:/ /g' >$warn # keep only good stuff
sendcommands() {
if [ -s $cmds ]; then # check if size of file is nonzero
echo; echo " Commands to be executed on $remotehost:"
cat $cmds # list the chmod commands here
fi
if [ "$newfiles" != "" ]; then # add "rdist" to list of commands
echo "remotehost=$remotehost" >>$cmds
echo 'echo -n "$remotehost - "' >>$cmds # rdist says "updating host"
echo "rdist -y -c $newfiles $localhost" >>$cmds
echo 'echo -n "$remotehost - ";date' >>$cmds
fi
if [ -s $cmds ]; then
echo
rsh $remotehost /bin/sh <$cmds # do chmod or mkdir as needed
echo
: >$cmds # zero out the file
fi
if [ "$dirfiles" != "" ]; then # parent directory was missing
rdist -y -c $dirfiles $remotehost # try sending file again
fi
}
: >$cmds
remotehost="$1" newfiles="" dirfiles="" fixed=""
# Get rid of extra stuff (such as a timestamp I put) in front of rdist's
# "updating host" message so that the name of the remote host can be found.
sed -e 's/^.*updating host/updating host/' $warn | \
(while read x1 x2 x3 x4 x5 x6 x7 x8 x9 x10
do
#"updating host boomer"
if [ "$x1 $x2" = "updating host" ]; then
if sendcommands; then hosts="$hosts $remotehost"; fi # previous host
remotehost=$x3 # remember name of remote host
newfiles="" # reset list of newer files
dirfiles="" # and list of files missing parent dirs
fi
#"/home/gemini/some/dir: Warning: remote mode 775 != local mode 2775"
if [ "$x3 $x4" = "remote mode" ]; then
sgid=`expr $x9 - $x5`
if [ "$sgid" = "2000" ]; then x9="g+s"; fi
if [ "$sgid" = "-2000" ]; then x9="g-s"; fi
echo "chmod $x9 $x1" >>$cmds # rdist should do this itself!
fixed=yes
fi
#"Warning: /mnt/xd4h/2/02042/c00.log: remote copy is newer"
if [ "$x5 $x6" = "is newer" ]; then
newfiles="$newfiles $x2"
fixed=yes
fi
#"rdist: boomer:/tym/7/07000/rdista08190: No such file or directory"
if [ "$x4 $x5 $x8" = "No such directory" ]; then
missingdir=`dirname $x3`
dup=no
for dir in $dirfiles
do
if [ $missingdir = $dir ]; then dup=yes; fi
done
if [ $dup = no ]; then
# Assume that just one directory is missing. This will create it.
rdist -c $missingdir $remotehost # create dir, right owner.group, mode
# But if more than one directory is missing, "mkdir -p" creates them all.
echo "mkdir -p $missingdir" >>$cmds
dirfiles="$dirfiles $missingdir" # double check for dir being updated
fi
fi
done
sendcommands # do last (or only) host
#if [ "$fixed" = "" ]; then echo "$0: no warnings"; fi
)
rm $cmds $warn
#[End of /etc/rdist/fix-warnings]#
--
Joe Smith (408)922-6220 | SMTP: jms at tardis.tymnet.com or jms at gemini.tymnet.com
BT Tymnet Tech Services | UUCP: ...!{ames,pyramid}!oliveb!tymix!tardis!jms
PO Box 49019, MS-C41 | BIX: smithjoe | 12 PDP-10s still running! "POPJ P,"
San Jose, CA 95161-9019 | humorous dislaimer: "My Amiga 3000 speaks for me."
More information about the Comp.unix.admin
mailing list