[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Determing if pipe exists
From: |
Brendan Strejcek |
Subject: |
Re: Determing if pipe exists |
Date: |
Wed, 4 May 2005 14:24:50 -0500 |
User-agent: |
Mutt/1.5.6+20040907i |
Brian Seppanen wrote:
> So what I need to do is configure cfengine to detect if this file
> exists as a pipe or as a regular file. If it exists as a regular file
> delete the file and create a pipe, and make sure the ownership and
> permissions are correct.
...
> I think I've seen an ifFileExists ( ), but I'm not sure that would
> work.
You might be interested in:
http://www.cfengine.org/docs/cfengine-Reference.html#Evaluated-classes-and-special-functions
There is no test for pipeness, but IsPlain() might be useful to detect
non-pipes, depending on the logic you prefer.
This is what I would do:
classes:
is_pipe = (
ReturnsZero(/bin/sh -c '
/bin/ls -l /path/to/pipe | /bin/grep ^p >/dev/null 2>&1
')
)
shellcommands:
!is_pipe::
"/bin/rm -f /path/to/pipe"
"/usr/bin/mkfifo /path/to/pipe"
"/bin/chown ${pipe_ownership} /path/to/pipe"
"/bin/chmod ${pipe_mode} /path/to/pipe"
You could also add a files: section so the permissions get verified on
every run, even when is_pipe evaluates to true.
Best,
Brendan