Sha256: 0df9bf703ecc70499da8ba240fef9bfcbfdc824e7653884aa5c9eb3c14f9dbf8

Contents?: true

Size: 1.14 KB

Versions: 7

Compression:

Stored size: 1.14 KB

Contents

#!/usr/bin/env ruby
require 'optparse'
require 'ostruct'

require "rubygems"
require "mandy"

HadoopConfiguration.check_home_and_version

exec('mandy-rm -h') unless ARGV.size >= 1


options = OpenStruct.new

OptionParser.new do |opts|
  opts.banner = "USAGE: mandy-rm file_or_folder_on_hdfs [options]"

  opts.on("-c", "--conf HADOOP_CONF", "Use this cluster xml config file.") do |config|
    options.config = config
  end

  opts.on("-f", "--force", "Use this paramter to force deletion of a relative folder, root folder or 1st level folder (like /home or /tmp)") do
    options.force = true
  end

  opts.on_tail("-h", "--help", "Show this message") do
    puts opts
    exit
  end
end.parse!

file = ARGV[0]
config = options.config || 'cluster.xml'

if !options.force and file =~ /^[^\/]/
  puts "mandy-rm: Cowardly refusing to delete a relative folder. Use -f parameter to force command."
  exit
end

if !options.force and File.expand_path(file).split("/").size <= 2
  puts "mandy-rm: Cowardly refusing to delete a root or 1st level folder. Use -f parameter to force command."
  exit
end

`$HADOOP_HOME/bin/hadoop fs -conf #{config} -rmr #{file}`
exit($?.exitstatus)

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mandy-0.5.28 bin/mandy-rm
mandy-0.5.27 bin/mandy-rm
mandy-0.5.26 bin/mandy-rm
mandy-0.5.25 bin/mandy-rm
mandy-0.5.24 bin/mandy-rm
mandy-0.5.23 bin/mandy-rm
mandy-0.5.22 bin/mandy-rm