Actually isdir() would be best here perhaps. :)

M

Nakarin Phooripoom wrote:
> Alternatively, I would use a built-in function fileexists() to check there is 
> a directory or not then execute commands.
> 
> classes:
>   "dir_exists" expression => fileexists("some/directory");
>   "no_dir"            not => fileexists("some/directory");
> 
> commands:
>  dir_exists::
>    "command_1";
>  no_dir::
>    "command_2";
> 
> Cheers,
> --Nakarin
> 
> On Jun 3, 2010, at 3:35 AM, tktuc...@gmail.com wrote:
> 
>> The concern is not the creation of the directory, which I agree can be 
>> achieved with the "create => true" syntax.
>> My question is how can I get additional commands executed after noticing a 
>> directory doesn't exist or after I create the directory.
>>
>> On Jun 2, 2010 9:13pm, Daniel V Klein <d...@lonewolf.com> wrote:
>>> Is one of the commands perhaps to create the directory you want?  Why not 
>>> use
>>>
>>> the "create => true" attribute and just let the promises converge to the
>>>
>>> desired state?
>>>
>>>
>>>
>>> -Dan
>>>
>>>
>>>
>>>> --===============1770191284==
>>>> Content-Type: multipart/alternative; boundary=0016e6470cf819ef39048813b6ae
>>>> --0016e6470cf819ef39048813b6ae
>>>> Content-Type: text/plain; charset=ISO-8859-1
>>>> I am trying to write a promise config that will first check to see if a
>>>> directory exists. If it doesn't the run these commands. I am able to 
>>>> achieve
>>>> this with files incombination with the "classes => if_repaired(xyz);".  Any
>>>> suggestions?
>>>> Thank you,
>>>> CFengine 3
>>>> files:
>>>>     # directory example
>>>>     "/some/directory/."
>>>>      execute commandX
>>>>      execute commandY
>>>>     # works with files
>>>>     "/var/spool/cron/crontabs/www"
>>>>          copy_from =>
>>>> umycopy("$(content_files)/solaris/10/all/var/spool/cron/crontabs/www"),
>>>>          perms => mog("0600","www","www"),
>>>>          classes => if_repaired(restart_cron);
>>>>     
>>>> commands:
>>>>     commandX::
>>>>     "/path/commandX";
>>>>     commandY::
>>>>     "/path/commandY";
>>>>     
>>>> }
>>>> --0016e6470cf819ef39048813b6ae
>>>> Content-Type: text/html; charset=ISO-8859-1
>>>> Content-Transfer-Encoding: quoted-printable
>>> I am trying to write a promise config that will first check to see if a=
>>>
>>>>  directory exists. If it doesn't the run these commands. I am able to a=
>>>> chieve this with files incombination with the "classes =3D> if_repa=
>>>> ired(xyz);".=A0 Any suggestions?
>>>
>>> Thank you,
>>>
>>> CFengine 3
>>>
>>> files:
>>>
>>> =A0=A0=A0 # directory=
>>>
>>>>  example 
>>> =A0=A0=A0 "/some/directory/."
>>> =A0=A0=A0 =A0execut=
>>>
>>>> e commandX
>>> =A0=A0=A0 =A0execute commandY
>>>
>>> =A0=A0=A0 # works with f=
>>>
>>>> iles
>>> =A0=A0=A0 "/var/spool/cron/crontabs/www"
>>>
>>>
>>>> =A0=A0=A0=A0=A0=A0=A0=A0 copy_from =3D>
>>> =A0=A0=A0=A0=A0=A0=A0=A0 umyc=
>>>
>>>> opy("$(content_files)/solaris/10/all/var/spool/cron/crontabs/www"=
>>>> ),
>>> =A0=A0=A0=A0=A0=A0=A0=A0 perms =3D> mog("0600","www=
>>>
>>>> ","www"),
>>> =A0=A0=A0=A0=A0=A0=A0=A0 classes =3D> if_rep=
>>>
>>>> aired(restart_cron);
>>>
>>> =A0=A0=A0 <other unrelated files below>
>>>
>>>
>>>
>>> commands: 
>>>> br>=A0=A0=A0 commandX::
>>> =A0=A0=A0 "/path/commandX";
>>>
>>> =A0=
>>>
>>>> =A0=A0 commandY::
>>> =A0=A0=A0 "/path/commandY";
>>>
>>> =A0=A0=A0=
>>>
>>>>  <other unrelated commands below>
>>>
>>>> }
>>> =A0=A0=A0 
>>> =A0=A0=A0 
>>>
>>>
>>>
>>>> --0016e6470cf819ef39048813b6ae--
>>>> --===============1770191284==
>>>> Content-Type: text/plain; charset="us-ascii"
>>>> MIME-Version: 1.0
>>>> Content-Transfer-Encoding: 7bit
>>>> Content-Disposition: inline
>>>> _______________________________________________
>>>> Help-cfengine mailing list
>>>> Help-cfengine@cfengine.org
>>>> https://cfengine.org/mailman/listinfo/help-cfengine
>>>> --===============1770191284==--
>>> _______________________________________________
>> Help-cfengine mailing list
>> Help-cfengine@cfengine.org
>> https://cfengine.org/mailman/listinfo/help-cfengine
> 
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine

-- 
Mark Burgess

-------------------------------------------------
Professor of Network and System Administration
Oslo University College, Norway

Personal Web: http://www.iu.hio.no/~mark
Office Telf : +47 22453272
-------------------------------------------------
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to