Update: performed some simple testing on a basic text file containing the following 5 entries:
line1 line2 line3 line4 line5 Running with CF3.0.4p2 on CentOS 5.4 x64, this is the behaviour I'm getting: before line1 = OK after line1 = Broken (appended to end of file) before line2 = Broken (appended to end of file) after line2 = OK before line3 = OK after line3 = OK before line4 = OK after line4 = OK before line5 = OK after line5 = OK Attached is the promise.cf and cron.cf file if anyone else feels like giving it a try. Cheers Steve > > Works ok for me > > Steve Barnes wrote: >> 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 > > -- > Mark Burgess > > ------------------------------------------------- > Professor of Network and System Administration > Oslo University College, Norway > > Personal Web: http://www.iu.hio.no/~mark > Office Telf : +47 22453272 > ------------------------------------------------- >
cron.cf
Description: Binary data
promises.cf
Description: Binary data
_______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine