Compare commits
No commits in common. "master" and "feature-delete" have entirely different histories.
master
...
feature-de
@ -26,6 +26,3 @@ This will allow you to restore a file on disk to the specific version that is st
|
|||||||
|
|
||||||
### Get
|
### Get
|
||||||
The utility will allow you to get the contents of a backup up file and have it output to the terminal.
|
The utility will allow you to get the contents of a backup up file and have it output to the terminal.
|
||||||
|
|
||||||
### Delete
|
|
||||||
The utility allows you to delete entries/backups in the bucket if you choose to do so.
|
|
||||||
|
28
bucket-tool
28
bucket-tool
@ -15,11 +15,11 @@ def usage
|
|||||||
#{__FILE__} [ACTION <arg>] [<flags>]
|
#{__FILE__} [ACTION <arg>] [<flags>]
|
||||||
|
|
||||||
Description:
|
Description:
|
||||||
This utlity is meant to be used to interact with & manage the filebucket in the same capacity as
|
This utlity is meant to be used to interact with & manage the filebucket on P4 nodes due to the
|
||||||
the builtin filebucket utility. However, it does not handle any puppet tie ins.
|
utility for that `puppet filebucket -l <action>` being nonfunctional.
|
||||||
|
|
||||||
I created this due to the puppet filebucket utility in my companies P4 envrionments not
|
This implements the same functionality (minus the puppet tie-in) and will allow the user to
|
||||||
functioning
|
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
|
||||||
@ -568,10 +568,6 @@ def get_entry_by_file (bucket, filenames)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if $CONFIG[:alt_filepath] != ""
|
|
||||||
return entry, $CONFIG[:alt_filepath]
|
|
||||||
end
|
|
||||||
|
|
||||||
if filename[0] != '/'
|
if filename[0] != '/'
|
||||||
filename = "/#{filename}"
|
filename = "/#{filename}"
|
||||||
end
|
end
|
||||||
@ -582,12 +578,6 @@ end
|
|||||||
def get_entry_by_hash (bucket)
|
def get_entry_by_hash (bucket)
|
||||||
if bucket.entries.has_key? $CONFIG[:search_term]
|
if bucket.entries.has_key? $CONFIG[:search_term]
|
||||||
entry = bucket.entries[$CONFIG[:search_term]]
|
entry = bucket.entries[$CONFIG[:search_term]]
|
||||||
|
|
||||||
if $CONFIG[:alt_filepath] != ""
|
|
||||||
log "$CONFIG[:alt_filepath] was set. Skipping prompts asking for filepaths"
|
|
||||||
return entry, $CONFIG[:alt_filepath]
|
|
||||||
end
|
|
||||||
|
|
||||||
filepath = ""
|
filepath = ""
|
||||||
if entry.filepaths.count == 1
|
if entry.filepaths.count == 1
|
||||||
filepath = entry.filepaths[0]
|
filepath = entry.filepaths[0]
|
||||||
@ -615,6 +605,10 @@ def restore_entry (bucket)
|
|||||||
entry, filepath = get_entry_by_hash bucket
|
entry, filepath = get_entry_by_hash bucket
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if $CONFIG[:alt_filepath] != ""
|
||||||
|
filepath=$CONFIG[:alt_filepath]
|
||||||
|
end
|
||||||
|
|
||||||
if get_verification "Are you sure you want to overwrite #{filepath}?"
|
if get_verification "Are you sure you want to overwrite #{filepath}?"
|
||||||
File.open(filepath,'w') do |file|
|
File.open(filepath,'w') do |file|
|
||||||
file.write(entry.content)
|
file.write(entry.content)
|
||||||
@ -711,19 +705,15 @@ def delete_entry (bucket)
|
|||||||
entry = bucket.entries[$CONFIG[:search_term]]
|
entry = bucket.entries[$CONFIG[:search_term]]
|
||||||
else
|
else
|
||||||
puts "BucketEntry[#{$CONFIG[:search_term]}] Does not exist. Please make sure you provided the correct hash value"
|
puts "BucketEntry[#{$CONFIG[:search_term]}] Does not exist. Please make sure you provided the correct hash value"
|
||||||
exit
|
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Corresponding Entry: #{entry.info}"
|
puts "Corresponding Entry: #{entry.info}"
|
||||||
if get_verification "Are you sure you want to delete BucketEntry[#{entry.hash}]? "
|
if get_verification "Are you sure you want to delete BucketEntry[#{entry.hash}]? "
|
||||||
if get_verification "This cannot be undone. Are you sure you want to continue?: "
|
if get_verification "This cannot be undone. Are you sure you want to continue?: "
|
||||||
if entry.delete
|
entry.delete
|
||||||
puts "Ok. BucketEntry[#{entry.hash}] Has been deleted"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# END: Work Functions
|
# END: Work Functions
|
||||||
|
Loading…
Reference in New Issue
Block a user