I think that you shouldn't anchor the regexp... 
select_line_matching => "#!.*sh";

Have not tried it... :-P

Best regards,
Emil Assarsson emil.assars...@sonyericsson.com
Phone: +46 (0)10 8017422



-----Original Message-----
From: help-cfengine-boun...@cfengine.org 
[mailto:help-cfengine-boun...@cfengine.org] On Behalf Of Steve Barnes
Sent: torsdag den 18 mars 2010 13:25
To: help-cfengine@cfengine.org
Subject: Is 'select_line_matching' broken?

I'm trying to disable a few cron tasks by inserting an `exit 0` statement
just after the shebang:

###################################################

bundle agent cron {

        files:

                "/etc/cron.daily/mlocate.cron"

                        edit_line => disable_task;

                "/etc/cron.daily/makewhatis.cron"

                        edit_line => disable_task;

                "/etc/cron.weekly/makewhatis.cron"

                        edit_line => disable_task;

        }

bundle edit_line disable_task {

        insert_lines:

          "exit 0"

                location => after_shebang;

        }

body location after_shebang     {

        select_line_matching => "^#!.*sh$";
        before_after => "after";

        }

###################################################

What I end up with in all of the files is this:

[r...@box]# cat /etc/cron.daily/mlocate.cron
#!/bin/sh
nodevs=$(< /proc/filesystems awk '$1 == "nodev" { print $2 }')
renice +19 -p $$ >/dev/null 2>&1
/usr/bin/updatedb -f "$nodevs"
exit 0
exit 0
exit 0

If I modify the promise to use `before_after => "before";` it does what I
would expect:

[r...@box]# cat /etc/cron.daily/mlocate.cron
exit 0
#!/bin/sh
nodevs=$(< /proc/filesystems awk '$1 == "nodev" { print $2 }')
renice +19 -p $$ >/dev/null 2>&1
/usr/bin/updatedb -f "$nodevs"
exit 0

But that's not what I'm after. Is this a bug?

Cheers

Steve

_______________________________________________
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

Reply via email to