From 8a7b8ea816eaefd98c27cd1f6d2f0acd5bdbe5ad Mon Sep 17 00:00:00 2001 From: hadaq Date: Thu, 29 Jan 2009 13:24:24 +0000 Subject: [PATCH] Not important. Sergey. --- plugins/restart.pl | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/plugins/restart.pl b/plugins/restart.pl index 1465dd9..1492de8 100755 --- a/plugins/restart.pl +++ b/plugins/restart.pl @@ -9,6 +9,7 @@ use strict; use warnings; use Getopt::Std; +use File::Basename; our ($opt_s, $opt_r, $opt_k, $opt_h); getopts('hs:p:kr'); @@ -21,9 +22,9 @@ if($opt_h){ &checkArgs(); #--- on these PCs the script should be restarted: -#my @PCList = ('lxg0429','lxg0433','lxg0435','lxg0437','lxg0439','lxg0440','lxg0441','lxg0442','lxg0443','lxg0444','lxg0445','lxg0446','lxg0447','lxg0448','lxg0452','lxg0453','lxg0454','lxg0455'); -my @PCList = ('lxg0447'); -my $args = "-d"; #- arguments of script to be restarted +my @PCList = ('lxg0429','lxg0433','lxg0435','lxg0437','lxg0439','lxg0440','lxg0441','lxg0442','lxg0443','lxg0444','lxg0445','lxg0446','lxg0447','lxg0448','lxg0452','lxg0453','lxg0454','lxg0455'); +#my @PCList = ('lxg0447'); +my $args = "-d"; #- arguments of script to be restarted &main(); @@ -34,13 +35,9 @@ exit(0); sub main { - #--- on these PCs the script should be restarted: - #my @PCList = ('lxg0429','lxg0433','lxg0435','lxg0437','lxg0439','lxg0440','lxg0441','lxg0442','lxg0443','lxg0444','lxg0445','lxg0446','lxg0447','lxg0448','lxg0452','lxg0453','lxg0454','lxg0455'); - my @PCList = ('lxg0447'); - foreach my $PC (@PCList) { - print "restart on $PC ...\n"; + &printMessage($PC); if( $opt_k || $opt_r ){ #--- get PIDs of running scripts @@ -79,6 +76,23 @@ sub checkArgs } } +sub printMessage +{ + my $PC = shift; + + my $prog_name = basename($opt_s); + + if($opt_k){ + print "kill $prog_name on $PC ...\n"; + } + elsif($opt_r){ + print "restart $prog_name on $PC ...\n"; + } + else{ + print "start $prog_name on $PC ...\n"; + } +} + sub showHelp { print << 'EOF'; @@ -99,5 +113,9 @@ sub showHelp -k : Kill a running script without restarting. -h : Print this help. + If there is only -s specified this script will + remotely start program without trying to kill + it first. + EOF } -- 2.43.0