ROOTCMD in cfengine script

2007-08-18 Thread Per Foreby

Is it possible to use $ROOTCMD in cfengine scripts?

I update a configuration file for tex-common, and want to run 
update-texmf after that. It must work both for install and softupdate.


This is what I tried with in my script:

  shellcommands:
any::
  ${ROOTCMD} /usr/sbin/update-texmf

The error from cfengine says that the command must be an absolute path, 
and since I tried this on a softudate where $ROOTCMD should be a null 
string, $ROOTCMD might not be exported to the script. Or would an empty 
string cause this problem?


I resorted to using a separate shell-script, but it would be nice to 
have everything in the same script.


I would probably be able to create a class script which defines 
FAI_ACTION as a class, and then check for that class in the cfengine 
script:


  shellcommands:
install::
  /sbin/chroot /tmp/target /usr/sbin/update-texmf
softupdate::
  /usr/sbin/update-texmf

Does anyone have a better idea?

/Per


Add to default fai.conf

2007-08-18 Thread Per Foreby

When running a softupdate, two variables must be added to fai.conf:
monserver for faimond, and LOGSERVER to copy the logs to the server.

It would be nice if these variables were added to the default 
fai.conf so it is obvious that they have to be defined.


Even better would be if they weren't needed. Both logs and monitoring 
works when doing the initial install, so I don't see any reason why it 
shouldn't work on softupdates.


/Per



Re: ROOTCMD in cfengine script

2007-08-18 Thread Thomas Lange
> On Sat, 18 Aug 2007 18:52:20 +0200 (CEST), Per Foreby <[EMAIL PROTECTED]> 
> said:

> Is it possible to use $ROOTCMD in cfengine scripts?
> I update a configuration file for tex-common, and want to run 
> update-texmf after that. It must work both for install and softupdate.

>shellcommands:
>  any::
>${ROOTCMD} /usr/sbin/update-texmf

> The error from cfengine says that the command must be an absolute path, 
IMO this error is because chroot is not used as /sbin/chroot but
only as chroot in $ROOTCMD. You may define $ROOTCMD in a class/*.var file.

-- 
regards Thomas


Re: ROOTCMD in cfengine script

2007-08-18 Thread Per Foreby



On Sat, 18 Aug 2007, Thomas Lange wrote:


On Sat, 18 Aug 2007 18:52:20 +0200 (CEST), Per Foreby <[EMAIL PROTECTED]> said:


   > Is it possible to use $ROOTCMD in cfengine scripts?
   > I update a configuration file for tex-common, and want to run
   > update-texmf after that. It must work both for install and softupdate.

   >shellcommands:
   >  any::
   >${ROOTCMD} /usr/sbin/update-texmf

   > The error from cfengine says that the command must be an absolute path,
IMO this error is because chroot is not used as /sbin/chroot but
only as chroot in $ROOTCMD. You may define $ROOTCMD in a class/*.var file.


But i got the error message when doing a softupdate, and then $ROOTCMD 
is set to nothing, so it is not the missing path for chroot that is the 
problem.


I did some testing, and the problem seems to be ROOTCMD= (empty) in 
/usr/sbin/fai. I tried to come up with some commands that just executed 
its arguments without the need for quoting (like /bin/sh -c). Writing 
such a "shell" is of cource easy. I would know since I have written 
a number of them for restricted environments, but now I tried to find 
something out-of-the-box. This worked:


  ROOTCMD="/usr/bin/nice -n 0"

But then I found an even simpler soulution:

  ROOTCMD=" "

This works togeter with "noabspath=true"

This is what my test script looked like:

  control:
actionsequence = ( shellcommands )

  shellcommands:
any::
  "${ROOTCMD} /usr/bin/touch /root/tt" noabspath=true


Setting ROOTCMD to " " doesn't affect shell scripts, so I would suggest 
a change in /usr/sbin/fai:



ROOTCMD="/usr/sbin/chroot $FAI_ROOT"
# no chroot needed
[ "$FAI_ROOT" = '/' ] && ROOTCMD=" "

Or, to be safe if chroot would move to another directory:

ROOTCMD="`which chroot` $FAI_ROOT"
# no chroot needed
[ "$FAI_ROOT" = '/' ] && ROOTCMD=" "

For the time beeing I will put this in a *.var script.

/Per