[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Maintaining RC symlinks

From: Luke A. Kanies
Subject: Re: Maintaining RC symlinks
Date: Thu, 10 Jun 2004 23:44:04 -0500 (CDT)

On Wed, 9 Jun 2004, Chip Seraphine wrote:

To provide a baseline, here is what I am currently doing:

       has_mysql_runlinks=      ( IsLink(/etc/rc3.d/S90mysql)
                                  IsLink(/etc/rc5.d/S90mysql) )

I don't know how much you've tested this, but it is highly unlikely that this is doing what you think it is.

Cfengine parses the above line as two separate values for 'has_mysql_runlinks', which means that the last value ends up being the real value. It doesn't matter what the results of any other IsLink() calls are. I just verified this.

If you want the test to work as (I think you) expect, you need to AND those IsLink() calls:

        has_mysql_runlinks = (

                /etc/rc3.d/S90mysql     -> ../init.d/mysql
                /etc/rc5.d/S90mysql     -> ../init.d/mysql

                "/bin/rm -f /etc/rc*.d/S90mysql"

This method is rather clunky (editing 3 seperate sections) and inefficient
(every host stats for two symlinks every run).

Ayup, although it's the maintenance clunkliness I'd be worried about, not the stat'ing. I don't expect there's much you can do about that.

Here is what (unless somebody has a better, more cfenginey way) I intend to

        mysqlserver=            ( dbhost1 dbhost2 )
        service_mysqlserver=    ( mysqlserver )

        "/var/cfengine/bin/cfservice '$(allclasses)'"

... and the cfservice script will detect the 'service_mysqlserver' script and
Do The Right Thing (which will probably be running chkconfig on Linux hosts,
or explicitly setting/removing links on others)  for every service (i.e.
script in init.d) that does or does not have a corresponding service_* class

The second approach is nonconvergent and requires me to write Yet Another
External Script, so I find it only marginally preferable to the first one.
Anybody out there has something better?

Hmm. I keep recommending this and everyone keeps ignoring me, so feel free to do so, but....

I _would_ write an external script, but it would be very simple. Maintain a mapping between classes (e.g., mysqlserver) and appropriate runlevel options:

$VAR1 = {
  "mysqlserver" => {
     "K" => 10,
     "S" => 90,

Your external script reads in that mapping, and then just loops across each class:

# no, i don't expect this all to work on first try
# all written off the top of my head
# mmmm, ruby....
my $linkcode = "links:

my $rmcode = "disable:

my %classes;
foreach my $class ((split /:/, $ENV{'CFALLCLASSES'}) {

# for every class we're looking at, make sure 1) we're that class, or
# 2) we don't have the startup scripts there
foreach my $class (keys %$VAR1) {
  if ($classes{$class}) {
    my $k = $VAR1->{$class}->{"K"};
    my $s = $VAR1->{$class}->{"S"};
    $linkcode .= "\t/etc/rc2.d/$s$class -> ../init.d/$class\n";
    $linkcode .= "\t/etc/rc0.d/$k$class -> ../init.d/$class\n";
    $linkcode .= "\t/etc/rc6.d/$k$class -> ../init.d/$class\n";
  } else {
    $rmcode .= "/etc/rc2.d/$s$class";
    $rmcode .= "/etc/rc2.d/$s$class";
    $rmcode .= "/etc/rc2.d/$s$class";

Then just execute the $linkcode and $rmcode, either through importing it in a later run or just executing immediately.

No, it's not exactly trivial, but once you've got the (actually quite simple) external script written it is trivial to maintain, and all you really ever modify is the mapping file (which I normally store in /var/cfengine/data). It's totally convergent (because you're actually using cfengine to do the work), and it's not that hard to support multiple platforms (change the paths or whatever).

I generally also make these modules, but that's just me.


Yesterday upon the stair
I met a man who wasn't there.
He wasn't there again today --
I think he's from the CIA.
Luke Kanies | |

reply via email to

[Prev in Thread] Current Thread [Next in Thread]