diff --git a/fencing/Makefile.am b/fencing/Makefile.am index dc184ac8d0..6bb6426fa9 100644 --- a/fencing/Makefile.am +++ b/fencing/Makefile.am @@ -1,48 +1,56 @@ # Author: Sun Jiang Dong # Copyright (c) 2004 International Business Machines # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # MAINTAINERCLEANFILES = Makefile.in SUBDIRS = ## binary progs halibdir = $(CRM_DAEMON_DIR) halib_PROGRAMS = stonithd stonith-test sbin_PROGRAMS = stonith_admin sbin_SCRIPTS = fence_legacy +if BUILD_HELP +man8_MANS = $(sbin_PROGRAMS:%=%.8) fence_legacy.8 +%.8: % + echo Creating $@ + chmod a+x $< + help2man --output $@ --no-info --section 8 --name "Part of the Pacemaker cluster resource manager" $(top_builddir)/fencing/$< +endif + stonith_test_SOURCES = test.c stonith_test_LDADD = $(CRYPTOLIB) $(CLUSTERLIBS) \ $(top_builddir)/lib/common/libcrmcommon.la \ $(top_builddir)/lib/common/libcrmcluster.la \ $(top_builddir)/lib/fencing/libstonithd.la stonith_admin_SOURCES = admin.c stonith_admin_LDADD = $(CRYPTOLIB) $(CLUSTERLIBS) \ $(top_builddir)/lib/common/libcrmcommon.la \ $(top_builddir)/lib/common/libcrmcluster.la \ $(top_builddir)/lib/fencing/libstonithd.la stonithd_SOURCES = main.c commands.c remote.c stonithd_LDADD = $(CRYPTOLIB) $(CLUSTERLIBS) \ $(top_builddir)/lib/common/libcrmcommon.la \ $(top_builddir)/lib/common/libcrmcluster.la \ $(top_builddir)/lib/fencing/libstonithd.la diff --git a/fencing/fence_legacy b/fencing/fence_legacy old mode 100644 new mode 100755 index a4b2f594c3..8a51f20299 --- a/fencing/fence_legacy +++ b/fencing/fence_legacy @@ -1,168 +1,181 @@ #!/usr/bin/perl -use Getopt::Std; +use Getopt::Long; my $ME = $0; END { defined fileno STDOUT or return; close STDOUT and return; warn "$ME: failed to close standard output: $!\n"; $? ||= 1; } # Get the program name from $0 and strip directory names $_=$0; s/.*\///; my $pname = $_; $opt_o = 'reset'; # Default fence action $opt_s = 'stonith'; # Default fence binary $opt_t = 'none'; # Default fence type $extra_args = ''; sub usage { - print "Usage:\n"; + print "Helper that presents a RHCS-style interface for Linux-HA stonith plugins\n\n"; + print "Should never need to use invoked by the user directly\n\n"; print "\n"; - print "$pname [options]\n"; + print "Usage: $pname [options]\n"; print "\n"; print "Options:\n"; print " -h usage\n"; print " -t sub agent\n"; print " -n nodename\n"; print " -o Action: on | off | reset (default) | stat | hostlist\n"; print " -s stonith command\n"; print " -q quiet mode\n"; print " -V version\n"; exit 0; } sub fail { ($msg) = @_; print $msg."\n" unless defined $opt_q; $t->close if defined $t; exit 1; } sub fail_usage { ($msg)=@_; print STDERR $msg."\n" if $msg; print STDERR "Please use '-h' for usage.\n"; exit 1; } sub version { print "1.0.0\n"; exit 0; } sub get_options_stdin { my $opt; my $line = 0; while( defined($in = <>) ) { $_ = $in; chomp; # strip leading and trailing whitespace s/^\s*//; s/\s*$//; # skip comments next if /^#/; $line+=1; $opt=$_; next unless $opt; ($name,$val)=split /\s*=\s*/, $opt; if ( $name eq "" ) { print STDERR "parse error: illegal name in option $line\n"; exit 2; } # DO NOTHING -- this field is used by fenced elsif ($name eq "agent" ) {} elsif ($name eq "plugin" ) { $opt_t = $val; } elsif ($name eq "option" || $name eq "action" ) { $opt_o = $val; } elsif ($name eq "port" ) { $opt_n = $val; } elsif ($name eq "stonith" ) { $opt_s = $val; } else { $extra_args="$extra_args $name=\"$val\""; } } } ######################################################################33 # MAIN if (@ARGV > 0) { - getopts("ht:n:o:s:qV") || fail_usage ; - + GetOptions("t=s"=>\$opt_t, + "n=s"=>\$opt_n, + "o=s"=>\$opt_o, + "s=s"=>\$opt_s, + "q" =>\$opt_q, + "V" =>\$opt_V, + "version" =>\$opt_V, + "help" =>\$opt_h, + "h" =>\$opt_h) || fail_usage; + foreach (@ARGV) { + print "$_\n"; + } +# getopts("ht:n:o:s:qV") || fail_usage ; + usage if defined $opt_h; version if defined $opt_V; fail_usage "Unknown parameter." if (@ARGV > 0); } get_options_stdin(); $opt_o=lc($opt_o); fail "failed: unrecognised action: $opt_o" unless $opt_o =~ /^(on|off|reset|reboot|stat|status|monitor|list|hostlist)$/; if ( $pid=fork() == 0 ) { if ( $opt_o eq "reboot" ) { $opt_o="reset"; } if ( $opt_o eq "hostlist"|| $opt_o eq "list" ) { exec "$opt_s -t $opt_t $extra_args -l" or die "failed to exec \"$opt_s\"\n"; } elsif ( $opt_o eq "monitor" || $opt_o eq "stat" || $opt_o eq "status" ) { print "Performing: $opt_s -t $opt_t -S $opt_n\n" unless defined $opt_q; exec "$opt_s -t $opt_t $extra_args -S $opt_n" or die "failed to exec \"$opt_s\"\n"; } else { print "Performing: $opt_s -t $opt_t -T $opt_o $opt_n\n" unless defined $opt_q; fail "failed: no plug number" unless defined $opt_n; exec "$opt_s -t $opt_t $extra_args -T $opt_o $opt_n" or die "failed to exec \"$opt_s\"\n"; } } wait; $status=$?/256; print (($status == 0 ? "success":"failed") . ": $opt_n $status\n") unless defined $opt_q; exit ($status == 0 ? 0 : 1 );