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
|
||||
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>]
|
||||
|
||||
Description:
|
||||
This utlity is meant to be used to interact with & manage the filebucket in the same capacity as
|
||||
the builtin filebucket utility. However, it does not handle any puppet tie ins.
|
||||
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.
|
||||
|
||||
I created this due to the puppet filebucket utility in my companies P4 envrionments not
|
||||
functioning
|
||||
This implements the same functionality (minus the puppet tie-in) and will allow the user to
|
||||
search the filebucket and restore from it.
|
||||
|
||||
Actions:
|
||||
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
|
||||
|
||||
if $CONFIG[:alt_filepath] != ""
|
||||
return entry, $CONFIG[:alt_filepath]
|
||||
end
|
||||
|
||||
if filename[0] != '/'
|
||||
filename = "/#{filename}"
|
||||
end
|
||||
@ -582,12 +578,6 @@ end
|
||||
def get_entry_by_hash (bucket)
|
||||
if bucket.entries.has_key? $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 = ""
|
||||
if entry.filepaths.count == 1
|
||||
filepath = entry.filepaths[0]
|
||||
@ -615,6 +605,10 @@ def restore_entry (bucket)
|
||||
entry, filepath = get_entry_by_hash bucket
|
||||
end
|
||||
|
||||
if $CONFIG[:alt_filepath] != ""
|
||||
filepath=$CONFIG[:alt_filepath]
|
||||
end
|
||||
|
||||
if get_verification "Are you sure you want to overwrite #{filepath}?"
|
||||
File.open(filepath,'w') do |file|
|
||||
file.write(entry.content)
|
||||
@ -711,18 +705,14 @@ def delete_entry (bucket)
|
||||
entry = bucket.entries[$CONFIG[:search_term]]
|
||||
else
|
||||
puts "BucketEntry[#{$CONFIG[:search_term]}] Does not exist. Please make sure you provided the correct hash value"
|
||||
exit
|
||||
end
|
||||
|
||||
puts "Corresponding Entry: #{entry.info}"
|
||||
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 entry.delete
|
||||
puts "Ok. BucketEntry[#{entry.hash}] Has been deleted"
|
||||
entry.delete
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user