Package: fai
Severity: wishlist
Tags: patch

Hi,

We don't allow ssh from the clients to the install server so we need
another way to disable the pxe config file for a newly installed client.
As there already is faimond monitoring the status of the nodes we
improved it to allow to run fai-chboot -r <host> when it sees a REBOOT.

/torkel

-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.6.8
Locale: LANG=en_GB.UTF-8, LC_CTYPE=sv_SE.UTF-8 (charmap=UTF-8)

Versions of packages fai depends on:
pn  debootstrap                              Not found.
ii  nfs-kernel-server [nfs-serve 1:1.0.6-3.1 Kernel NFS server support
ii  perl                         5.8.4-8     Larry Wall's Practical Extraction 
Index: faimond
===================================================================
--- faimond     (revision 3156)
+++ faimond     (working copy)
@@ -1,4 +1,5 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
+# vim:et:sw=2:smartindent:
 
 # $Id$
 #*********************************************************************
@@ -12,12 +13,34 @@
 #*********************************************************************
 
 use strict;
+use warnings;
 use Socket;
+use Getopt::Std;
 
 $| = 1;
 my $port = 4711;
 
+my %options;
+
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+sub parse_options() {
+  getopts('adp:hv', \%options);
+
+  if($options{'h'}) {
+    print STDERR "Usage: $0 [-a] [-p port] [-h]\n";
+    print STDERR "      -a      Allow actions\n";
+    print STDERR "      -p port Set port to listen to\n";
+    print STDERR "      -v      Verbose\n";
+    print STDERR "      -d      Debug\n";
+    print STDERR "      -h      Show this help\n";
+    exit 1;
+  }
+
+  if($options{'p'}) {
+    $port = $options{'p'};
+  }
+}
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 sub server_init() {
 
   my $proto = getprotobyname('tcp');
@@ -39,9 +62,33 @@
     $inp = <CLIENT>;
     close CLIENT;
     print "$inp";
+
+    if($options{'a'}) {
+      my ($host, $action) = split / /, $inp, 2;
+      if ($action =~ /REBOOT/) {
+        my $status=`fai-chboot -l $host`;
+        chomp $status;
+        if ($status) {
+          print "$host Action status: $status\n" if $options{'d'};
+          if ($status =~ /^[0-9a-zA-Z]+ /) {
+            my $cmd = "fai-chboot -r $host";
+            print "$host Action: $cmd\n" if $options{'v'};
+            my $status=`$cmd`;
+            print "$host Action status: $status\n" if ($options{'v'} && 
$status);
+          } elsif ($status =~ /^[0-9a-zA-Z]+\.disable /) {
+            print "$host Action: Already disabled\n" if $options{'v'};
+          } else {
+            print "$host Action: Unknown status: $status\n" if $options{'v'};
+          }
+        } else {
+          print "$host Action: No configuration file\n" if $options{'v'};
+        }
+      }
+    }
   }
 }
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
+parse_options;
 server_init;
 big_loop;

Reply via email to