jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [part/] [setup.pl] - Blame information for rev 3

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2 
3# $Id: setup.pl,v 1.8 2004/07/12 07:50:15 bernisys Exp $
4 
5# include PERL libraries
6use strict;
7use warnings;
8use diagnostics;
9 
10# include HotSaNIC libraries
11use lib "../../lib";
12use lib "./platform";
13use HotSaNICparser;
14use HotSaNICshellio;
15use HotSaNIClog;
16use common;
17 
18$|=1;
19 
20(my $VERSION = '$Revision: 1.8 $') =~ s/.*(\d+\.\d+).*/$1/;
21(my $IDENTIFIER = '$Id: setup.pl,v 1.8 2004/07/12 07:50:15 bernisys Exp $') =~ s/.*,v (.*) \$/$1/;
22 
23my $MODNAME=HotSaNICparser::get_module_name();
24my %MODCONF=HotSaNICmod::common::configure();
25my $OUTFILE="settings.new";
26if ( ! -e "settings" ) { $OUTFILE="settings"; }
27open OUTFILE,">$OUTFILE" || die "could not open ".HotSaNICparser::get_module_name()." settings file for writing.\n";
28 
29if (! @{$MODCONF{DRIVE}}) { @{$MODCONF{DRIVE}}=get_drives(); }
30if (@{$MODCONF{DRIVE}}) { $MODCONF{DRIVE}="DRIVE=\"".join("\"\nDRIVE=\"",@{$MODCONF{DRIVE}})."\""; }
31else { $MODCONF{DRIVE}=""; }
32 
33print OUTFILE "# SHORT DESCRIPTION
34#
35# You may configure partitions you would like to monitor.
36# multiple lines are of course allowed.
37#
38# for a local drive enter:
39# DRIVE=<device>,<description>
40#
41# for a remote (e.g. NFS or SNMP) drive enter:
42# DRIVE=<server>:<path>,<description>
43# DRIVE=SNMP:<host>:<community>:<device>,<description>
44#
45# Note: Make sure you have no '_' in host or community
46# when using SNMP.
47#
48$MODCONF{DRIVE}
49";
50 
51close OUTFILE;
52 
53if ($OUTFILE eq "settings.new") {
54 HotSaNICparser::backup_file("settings");
55 rename "settings.new","settings";
56 }
57 
58print "Please check the settings file and adapt it to satisfy your needs.\n";
59 
60sub get_drives {
61 my @drives=();
62 open RESULT,"df -a|";
63 $_=<RESULT>; #strip header line
64 my $lastfs="";
65 while (<RESULT>) {
66 chomp;
67 my($fs,$size,undef,undef,$mp1,$mountpoint)=split;
68 if (!defined $mountpoint) {
69 if (!defined $mp1) { $lastfs=$fs; next; }
70 else { $size=$fs; $fs=$lastfs; $mountpoint=$mp1; }
71 }
72 if ( ($fs ne "none") and ($size > 0) ) {
73 $mountpoint ="root filesystem" if $mountpoint eq "/";
74 my $result=HotSaNICshellio::askyesno("Use \"$fs\", mounted on \"$mountpoint\"","n");
75 push @drives,"$fs,$mountpoint" if $result eq "y";
76 }
77 }
78 close RESULT;
79 return @drives;
80 }
81 

Powered by WebSVN 2.2.1