1 | 1 | simandl | #!/usr/bin/env perl |
2 | | | |
3 | | | # $Id: diagrams.pl,v 1.6 2004/07/11 22:39:38 bernisys Exp $ |
4 | | | |
5 | | | # include PERL libraries |
6 | | | use strict; |
7 | | | use warnings; |
8 | | | use diagnostics; |
9 | | | |
10 | | | # include HotSaNIC libraries |
11 | | | use lib "./lib"; |
12 | | | use HotSaNICparser; |
13 | | | |
14 | | | (my $VERSION = '$Revision: 1.6 $') =~ s/.*(\d+\.\d+).*/$1/; |
15 | | | (my $IDENTIFIER = '$Id: diagrams.pl,v 1.6 2004/07/11 22:39:38 bernisys Exp $') =~ s/.*,v (.*) \$/$1/; |
16 | | | |
17 | | | # read global settings |
18 | | | # |
19 | | | my %CONFIG=HotSaNICparser::get_config("./"); |
20 | | | |
21 | | | my $PIDFILE=$CONFIG{VARDIR}."/run/diagram.pid"; |
22 | | | my $PID=HotSaNICparser::get_pid($PIDFILE,"diagram"); |
23 | | | if ($PID > 0) { |
24 | | | print "diagram process already running on PID $PID\nchecking if stalled...\n"; |
25 | | | if (-e $PIDFILE) { |
26 | | | my $runtime=time-(stat($PIDFILE))[10]; |
27 | | | print "process running $runtime sec\n"; |
28 | | | if ($runtime > 1800) { |
29 | | | print "Killing probably stalled diagram process on $PID\n"; |
30 | | | kill 9,$PID; |
31 | | | } |
32 | | | else { print "seems ok - exiting normally.\n"; exit 0; } |
33 | | | } |
34 | | | } |
35 | | | |
36 | | | open FILE,">$PIDFILE"; |
37 | | | print FILE $$; |
38 | | | close FILE; |
39 | | | |
40 | | | if (! -e $CONFIG{WEBDIR}) { mkdir $CONFIG{WEBDIR},0755; } |
41 | | | |
42 | | | chdir "./modules"; |
43 | | | opendir DIR,"."; |
44 | | | my @files=grep /[a-zA-Z]+/,readdir DIR; |
45 | | | closedir DIR; |
46 | | | |
47 | | | foreach my $entry (sort @files) { |
48 | | | if ( (-d $entry) && ($entry ne "CVS") ) { |
49 | | | print "----- modules/$entry -----\n"; |
50 | | | if ( (index($CONFIG{SHOW},$entry) >= 0) or ($CONFIG{SHOW} eq "*") ) { |
51 | | | chdir "./$entry"; |
52 | | | if (-e "diagrams.pl") { system "./diagrams.pl"; } elsif (-e "diagrams") { system "./diagrams"; } |
53 | | | chdir ".."; |
54 | | | } |
55 | | | else { print "Module not in SHOW - skipping...\n"; } |
56 | | | } |
57 | | | } |
58 | | | |
59 | | | unlink $PIDFILE; |
60 | | | |