pre push commit
This commit is contained in:
parent
fd2e1a8352
commit
b8baa13b9d
73
bucket-tool
73
bucket-tool
@ -1,47 +1,33 @@
|
|||||||
#!/usr/bin/ruby
|
#!/usr/bin/ruby
|
||||||
|
|
||||||
# BEGIN: Pre-Run Check
|
|
||||||
|
|
||||||
if ENV["USER"] != 'root'
|
|
||||||
puts "This script should only be run by root (permissions issues). Please rerun it as root or prepend \"sudo\""
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
|
|
||||||
# END: Pre-Run Check
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# BEGIN: Variables
|
|
||||||
|
|
||||||
$DEBUG=false
|
|
||||||
|
|
||||||
$CONFIG = Hash.new
|
|
||||||
$CONFIG[:bucket_dir]=` sudo puppet agent --configprint clientbucketdir `.strip()
|
|
||||||
$CONFIG[:action]=""
|
|
||||||
$CONFIG[:search_term]=""
|
|
||||||
$CONFIG[:log_file]=""
|
|
||||||
File.open('/etc/hostname') do |file|
|
|
||||||
$HOSTNAME=file.read().strip()
|
|
||||||
end
|
|
||||||
FLAG_REGEX=/\-+\S+/
|
|
||||||
# END: Variables
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# BEGIN: Helper Functions
|
# BEGIN: Helper Functions
|
||||||
|
|
||||||
def usage
|
def usage
|
||||||
puts "#{__FILE__} [ACTION <arg>] [<flags>]
|
puts "#{__FILE__} [ACTION <arg>] [<flags>]
|
||||||
|
|
||||||
|
Description:
|
||||||
|
This utlity is meant to be used to interact with & manage the filebucket on P4 nodes due to the
|
||||||
|
utility for that `puppet filebucket -l <action>` being nonfunctional.
|
||||||
|
|
||||||
|
This implements the same functionality (minus the puppet tie-in) and will allow the user to
|
||||||
|
search the filebucket and restore from it.
|
||||||
|
|
||||||
Actions:
|
Actions:
|
||||||
search <term> : Search for bucket entries matching a portion of the filepath
|
search <term> : Search for bucket entries matching a portion of the filepath
|
||||||
list : List all Bucket entries
|
list : List all Bucket entries
|
||||||
list-files : List all files/paths that have been backed up to the bucket
|
list-files : List all files/paths that have been backed up to the bucket
|
||||||
get <entry-md5> : Get the content of a specific entry (by md5)
|
get <entry-md5> : Get the content of a specific entry (by md5)
|
||||||
restore <entry-md5> : Restore entry to
|
|
||||||
|
|
||||||
Global Flags:
|
Global Flags:
|
||||||
-d | --debug : Set debug flag
|
-d | --debug : Set debug flag
|
||||||
|
-h | --help : This help message
|
||||||
|
|
||||||
|
Author:
|
||||||
|
Name: Tristan Ancelet
|
||||||
|
Email: tristan.ancelet@acumera.com
|
||||||
|
Phone (Work) #: +1 (337) 965-1855
|
||||||
|
|
||||||
"
|
"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -79,8 +65,38 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# BEGIN: Variables
|
||||||
|
|
||||||
|
if not (ARGV & ['-h', '--help']).empty?
|
||||||
|
usage
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
|
if ENV["USER"] != 'root'
|
||||||
|
puts "This script should only be run by root (permissions issues). Please rerun it as root or prepend \"sudo\""
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
$DEBUG=false
|
||||||
|
|
||||||
|
$CONFIG = Hash.new
|
||||||
|
$CONFIG[:bucket_dir]=` sudo puppet agent --configprint clientbucketdir `.strip()
|
||||||
|
$CONFIG[:action]=""
|
||||||
|
$CONFIG[:search_term]=""
|
||||||
|
$CONFIG[:log_file]=""
|
||||||
|
File.open('/etc/hostname') do |file|
|
||||||
|
$HOSTNAME=file.read().strip()
|
||||||
|
end
|
||||||
|
FLAG_REGEX=/\-+\S+/
|
||||||
|
|
||||||
|
# END: Variables
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# BEGIN: Handle CLI Args
|
# BEGIN: Handle CLI Args
|
||||||
|
|
||||||
|
|
||||||
if ARGV.count == 0
|
if ARGV.count == 0
|
||||||
puts "No arguments were provided"
|
puts "No arguments were provided"
|
||||||
usage
|
usage
|
||||||
@ -90,7 +106,6 @@ end
|
|||||||
if not (ARGV & ['-d', '--debug']).empty?
|
if not (ARGV & ['-d', '--debug']).empty?
|
||||||
$DEBUG=true
|
$DEBUG=true
|
||||||
end
|
end
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
case ARGV[i]
|
case ARGV[i]
|
||||||
when 'search'
|
when 'search'
|
||||||
|
Loading…
Reference in New Issue
Block a user