Skip to contentSkip to conversation

cluster/gfs/scripts gfs_safe.pl

Cluster-devel [email protected] 1 participant 1 message Jul 27, 2006

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rohara at sourceware.org 2006-07-27 19:26:25

Added files:
gfs/scripts : gfs_safe.pl

Log message:
Early version of a script to help users determine if a logical volume might be in use by another node. Useful to avoid doing a mkfs or fsck on a mounted filesystem.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/scripts/gfs_safe.pl.diff?cvsroot=cluster&r1=NONE&r2=1.1

/cvs/cluster/cluster/gfs/scripts/gfs_safe.pl,v --> standard output revision 1.1

- renamed from gfs/scripts/gfs_safe.pl +84 -0
@@ -0,0 +1,84 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use vars qw($opt_e $opt_t $opt_v);
+
+use Getopt::Std;
+use IPC::Open3;
+
+if ($#ARGV < 0) {
+    print "$0: too few arguments.\n";
+    exit;
+}
+
+getopts('e:tv');
+
+my ($in, $out, $err, $cmd, $pid, $vol);
+
+$vol = $ARGV[$#ARGV];
+
+$cmd = "lvchange -a n $vol";
+$pid = open3($in, $out, $err, $cmd);
+
+waitpid($pid, 0);
+
+if ($?>>8)
+{
+    while (<$out>)
+    {
+	print "$_\n";
+    }
+    exit($?>>8);
+}
+else
+{
+    print "* Volume '$vol' is available for maintenance.\n";
+
+    if ($opt_t)
+    {
+	exit;
+    }
+
+    if ($opt_e)
+    {
+
+	$cmd = "lvchange -a ey $vol";
+	$pid = open3($in, $out, $err, $cmd);
+
+	waitpid($pid, 0);
+
+	if ($?>>8)
+	{
+	    while (<$out>)
+	    {
+		print "$_\n";
+	    }
+	    exit($?>>8);
+	}
+
+	$cmd = "$opt_e $vol";
+	print "$cmd\n";
+	$pid = open3($in, $out, $err, $cmd);
+
+	while (<$out>)
+	{
+	    print "$_";
+	}
+
+	waitpid($pid, 0);
+
+	$cmd = "lvchange -a en $vol";
+	$pid = open3($in, $out, $err, $cmd);
+
+	if ($?>>8)
+	{
+	    while (<$out>)
+	    {
+		print "$_\n";
+	    }
+	    exit($?>>8);
+	}
+    }
+    exit(0);
+}