Extending fcopy
Janning Vygen
vygen at planwerk6.de
Fri Dec 8 13:47:17 CET 2006
Am Freitag, 8. Dezember 2006 11:29 schrieben Sie:
> On Thursday, 7. December 2006 22:45, Michael Tautschnig wrote:
> >
> > - some -k/--keep option (which I'd rather call --keep-permissions :-) )
> > to retain the permissions of the file which should be overwritten (BTW:
> > what should happen if there is no such file?)
>
> I'm not against the option, but in the an FAI context, IMHO one should now
> user:group:permission before overriding a file. If there are different
> from host to host, then either it's wrong or I better 'code' this exception
> in the installation scripts. <- IMHO of course.
Why should i know the user:group:permission of a file like /etc/sudoers. I
know it is there i want to override it and want to keep the permissions of
the orignial file. to me, it sounds very naturally, just to copy the content
of a file and keep original permissions.
> > - some way to return the number of files that were actually copied.
>
> That does not sound unix'ish IMHO. Why not the
> paths of the files copied are listed on stdout. Num is then just adding
> '| wc -l'. And stuff like: fcopy --whatever | while read file; do ...
> are still possible.
your absolutely right and i already wrote it this way, but i did use a
different format fcopy already uses:
print "fcopy: copied $sourcefile to $destfile\n" ;
i tried to use exit code, too:
exit code is 0: if one or more files were changed (content or permissions)
and no errors occured
exit code is 1: if no files were changed (content nor permissions) and no
warnings or errors occured
exit code is 2: warnings or errors occured plus description of exit code 1
exit code is 3: warnings or errors occured plus description of exit code 1
exit code is 4: on all other conditions (show Usage etc.)
this way you can say
fcopy ... /etc/postgresql && /etc/init.d/postgresql restart || exit 1;
What do you think about using exit codes? First i sort it's not unix like, but
diff does like this, too.
> Philosophical: I favour postinst scripts for all this, i.e. event based
> programming ;) When using FAI the first time the split of data below
> files and scripts using then scattered over the rest of fai/config
> was very hard to follow. Now I use fcopy recursive once and logic is
> in postinst files. And if something is missing I would first think
> about adding another event script like postinst and filemode.
but if you have more than two (or more) config files for a daemon you need two
(or more) postinst scripts which reloads the daemon. And the daemon is
reloaded twice and maybe even before the second file is copied which might
even include a security hole. Because the daemon is restarted with only one
file changed, then copying the second file before restarting again. i don't
like restarting a half-configured daemon.
kind regards
janning
More information about the linux-fai-devel
mailing list