[Fwd: Output of fcron job: 'update-website.sh']

Anderson Lizardo lizardo at linuxfromscratch.org
Wed Jan 7 09:26:11 PST 2004

Jeroen Coumans wrote:
> In three hours from now, fcron will update the website. I'm keeping an 
> eye out to see if the entire site is removed again. Can you scrutinize 
> my last changes to update-website.sh?

Sure, but first let me explain why the site was emptied, so we can avoid 
the same error on future.

The previous script had the following lines:

rm -rf $TARGETDIR &&

When the cronjob executed, it tried to remove TARGETDIR recursively with 
the command "rm -rf $TARGETDIR". The root directory, 
/home/httpd/www.linuxfromscratch.org, can only be removed by its owner 
or by root. I suppose that update-website is run by fcron as "gerard" 
user. When me (lizardo) or you (jeroen) run that script, it works fine, 
because TARGETDIR is not removed, only its contents. Therefore the next 
command ("mv $NEWSITE/* $TARGETDIR") works as expected. But, when the 
onwer of TARGETDIR runs the script, it removes all the contents of this 
dir, including the dir itself. The mv command then fails with

mv: when moving multiple files, last argument must be a directory

and the website is emptied.

A fix for this is to add a "mkdir -p  $TARGETDIR" before moving the 

Additionally, the mv command above will not copy hidden files (like 
.htaccess). Someone would think: "Why not use the plain 'mv $NEWSITE 
$TARGETDIR'?". That will not work either, because it will move NEWSITE 
to a subdirectory of TARGETDIR, instead of overwriting it, because 
TARGETDIR already exists.

So, the "tar | tar" trick is the best alternative at the moment, because 
it works for all members of "lfswww".

All the fixes mentioned above are already on CVS, so we will see if it 
works without problems.
Anderson Lizardo
lizardo at linuxfromscratch.org

More information about the website mailing list