jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [part/] [setup.pl] - Rev 31 Go to most recent revision

Compare with Previous - Blame - Download


#!/usr/bin/env perl

# $Id: setup.pl,v 1.8 2004/07/12 07:50:15 bernisys Exp $

# include PERL libraries
use strict;
use warnings;
use diagnostics;

# include HotSaNIC libraries
use lib "../../lib";
use lib "./platform";
use HotSaNICparser;
use HotSaNICshellio;
use HotSaNIClog;
use common;

$|=1;

(my $VERSION = '$Revision: 1.8 $') =~ s/.*(\d+\.\d+).*/$1/;
(my $IDENTIFIER = '$Id: setup.pl,v 1.8 2004/07/12 07:50:15 bernisys Exp $') =~ s/.*,v (.*) \$/$1/;

my $MODNAME=HotSaNICparser::get_module_name();
my %MODCONF=HotSaNICmod::common::configure();
my $OUTFILE="settings.new";
if ( ! -e "settings" ) { $OUTFILE="settings"; }
open OUTFILE,">$OUTFILE" || die "could not open ".HotSaNICparser::get_module_name()." settings file for writing.\n";

if (! @{$MODCONF{DRIVE}}) { @{$MODCONF{DRIVE}}=get_drives(); }
if (@{$MODCONF{DRIVE}}) { $MODCONF{DRIVE}="DRIVE=\"".join("\"\nDRIVE=\"",@{$MODCONF{DRIVE}})."\""; }
else { $MODCONF{DRIVE}=""; }

print OUTFILE "# SHORT DESCRIPTION
#
# You may configure partitions you would like to monitor.
# multiple lines are of course allowed.
#
# for a local drive enter:
#   DRIVE=<device>,<description>
#
# for a remote (e.g. NFS or SNMP) drive enter:
#   DRIVE=<server>:<path>,<description>
#   DRIVE=SNMP:<host>:<community>:<device>,<description>
#
# Note: Make sure you have no '_' in host or community
#       when using SNMP.
#
$MODCONF{DRIVE}
";

close OUTFILE;

if ($OUTFILE eq "settings.new") {
  HotSaNICparser::backup_file("settings");
  rename "settings.new","settings";
  }

print "Please check the settings file and adapt it to satisfy your needs.\n";

sub get_drives {
  my @drives=();
  open RESULT,"df -a|";
  $_=<RESULT>;   #strip header line
  my $lastfs="";
  while (<RESULT>) {
    chomp;
    my($fs,$size,undef,undef,$mp1,$mountpoint)=split;
    if (!defined $mountpoint) {
      if (!defined $mp1) { $lastfs=$fs; next; }
      else { $size=$fs; $fs=$lastfs; $mountpoint=$mp1; }
      }
    if ( ($fs ne "none") and ($size > 0) ) {
      $mountpoint ="root filesystem" if $mountpoint eq "/";
      my $result=HotSaNICshellio::askyesno("Use \"$fs\", mounted on \"$mountpoint\"","n");
      push @drives,"$fs,$mountpoint" if $result eq "y";
      }
    }
  close RESULT;
  return @drives;
  }


Powered by WebSVN 2.2.1