Forum: Cfengine Help
Subject: Re: Managing Solaris logadm.conf
Author: berntjernberg
Link to topic: https://cfengine.com/forum/read.php?3,17248,19930#msg-19930

Hi,

To edit the pacct-line I solved it like this. Surely you can make a more 
general solution but this worked for me.
Any thoughts or recommendations?

Regards
/Bernt Jernberg


bundle edit_line replace_line(old_value,new_value)
{
    replace_patterns:
        "$(old_value)"
        replace_with => value("$(new_value)"),
        classes => if_repaired("pattern_replaced");
}

bundle agent update_pacct_logadm_conf
{
    vars:
        solaris::
            "valid_pacct_line"        string => "/var/adm/pacct -C 10 -N -a 
'/usr/lib/acct/accton pacct' -g adm -m 664 -o adm -s 75m -z 1";
            "logadm_conf_file"         slist => { 
readstringlist("/etc/logadm.conf","#.*","\n",100,4000) };
            "logadm_conf_file_sublist" slist => 
grep("^/var/adm/pacct.*","logadm_conf_file");

    classes:
        "pacct_not_ok"   not => 
regcmp("^$(valid_pacct_line)$","$(logadm_conf_file_sublist)");

    files:
        pacct_not_ok::
            "/etc/logadm.conf"
            edit_line => replace_line("^/var/adm/pacct.*(?!-s 75m -z 
1)$","$(valid_pacct_line)"),
            classes => if_repaired("pacct_line_changed");
}



_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to