All of lore.kernel.org
 help / color / mirror / Atom feed
From: teigland@sourceware.org <teigland@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/group/scripts uninstall.pl
Date: 21 Jun 2006 20:45:19 -0000	[thread overview]
Message-ID: <20060621204519.18639.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland at sourceware.org	2006-06-21 20:45:19

Added files:
	group/scripts  : uninstall.pl 

Log message:
	add standard script

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

/cvs/cluster/cluster/group/scripts/uninstall.pl,v  -->  standard output
revision 1.1
--- cluster/group/scripts/uninstall.pl
+++ -	2006-06-21 20:45:19.761783000 +0000
@@ -0,0 +1,84 @@
+#!/usr/bin/perl
+
+###############################################################################
+###############################################################################
+##
+##  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
+##  Copyright (C) 2004 Red Hat, Inc.  All rights reserved.
+##
+##  This copyrighted material is made available to anyone wishing to use,
+##  modify, copy, or redistribute it subject to the terms and conditions
+##  of the GNU General Public License v.2.
+##
+###############################################################################
+###############################################################################
+
+##    Description: Basically the reverse of the install program, except it
+##                 only supports a list of files and a directory as arguments
+
+$| = 1;
+
+use Getopt::Std;
+
+# list all valid options here.  User will get errors if invalid options are 
+# specified on the command line
+getopts('hD');
+
+$args = 1;
+
+# We need at least two arguments to uninstall
+if(!defined($ARGV[1])) {
+    $args = 0;
+}
+    
+# if the user set the help flag or didn't provide enough args, print help 
+# and die.
+if(defined($opt_h) || ($args == 0)) {
+  $msg = "usage: $0 [OPTIONS] TARGET DIRECTORY\n";
+  $msg = $msg . "\t-D\tRemove specified directory if empty\n";
+  $msg = $msg . "\t-h\tDisplay this help message\n";
+  die $msg;
+}
+
+# find out how many command line arguments we have
+$length = $#ARGV;
+# We need a special case if there is only one file specified
+if($length > 1) {
+  @filelist = @ARGV;
+  $#filelist = $length - 1;
+}
+else {
+  @filelist = @ARGV[0];
+}
+
+# the last argument is the directory
+$dir = @ARGV[$length];
+
+# prepend the directory name to all files in the filelist
+$i = 0;
+print "Attempting to remove the following files from directory $dir/:\n";
+while($i < $length) {
+  print "@filelist[$i] ";
+  @filelist[$i] = "$dir/" . @filelist[$i];
+  $i++;
+}
+print "\n";
+  
+#print "Files:@filelist\n";
+#print "Directory: $dir\n";
+
+# delete the files in filelist
+$unlinked = unlink @filelist;
+if($unlinked < $length) {
+  print "Error! Unable to remove all files in $dir:\n\tYou may have to manually delete some of them.\n"
+}
+# if user specifed they want the directory deleted, try to delete it.  Print 
+# error message if not able to delete directory, including error.
+if(defined($opt_D)) {
+  $result = rmdir($dir);
+  if($result == FALSE) {
+    print "Error! Unable to remove directory $dir/:\n\t$!\n";
+  }
+}
+
+



                 reply	other threads:[~2006-06-21 20:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060621204519.18639.qmail@sourceware.org \
    --to=teigland@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.