diff options
author | Steve Kemp <steve@steve.org.uk> | 2015-04-02 09:21:42 +0100 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2015-04-02 09:21:42 +0100 |
commit | e254303eec822eb7f19ef7e37da0a0d4c5ff9182 (patch) | |
tree | 38e29c83a18d6a23a30c952f95933f4cfcbac89b /byteback-setup-client | |
parent | 4a66fec4b42af038c9fffc25396fe6b5fc177e56 (diff) |
Use consistant load-path fiddling.
Diffstat (limited to 'byteback-setup-client')
-rwxr-xr-x | byteback-setup-client | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/byteback-setup-client b/byteback-setup-client index 70b8ea8..5e9389f 100755 --- a/byteback-setup-client +++ b/byteback-setup-client @@ -2,7 +2,8 @@ # # Run on a client machine to set up backups for the first time -$: << '/usr/lib/byteback' +$LOAD_PATH.unshift("/usr/lib/byteback") + require 'fileutils' require 'trollop' require 'byteback/util' @@ -24,7 +25,7 @@ opts = Trollop::options do opt :hostname, "Set host name for backups", :type => :string - opt :destination, "Backup destination (i.e. user@host:/path)", + opt :destination, "Backup destination (i.e. user@host:/path)", :type => :string end @@ -32,7 +33,7 @@ end @destination = opts[:destination] @hostname = opts[:hostname] -_dummy, @destination_user, @destination_host, colon, @destination_path = +_dummy, @destination_user, @destination_host, colon, @destination_path = /^(.*)?(?:@)([^:]+)(:)(.*)?$/.match(@destination).to_a @destination_user ||= 'byteback' @@ -50,7 +51,7 @@ if File.readable?("/etc/byteback/key") warn "Skipping key generation, delete /etc/byteback/key if that's wrong" else - error "Couldn't generate SSH key" unless + error "Couldn't generate SSH key" unless system <<-KEYGEN ssh-keygen -q -t rsa -C "byteback client key" \ -N "" -f /etc/byteback/key @@ -63,7 +64,7 @@ key_pub = File.read("/etc/byteback/key.pub").chomp error "Remote setup didn't work" unless system("ssh -i /etc/byteback/key -l #{@destination_user} #{@destination_host} byteback-setup-client-receive #{@hostname} #{key_pub}") -File.open("/etc/byteback/destination", "w") do |f| +File.open("/etc/byteback/destination", "w") do |f| f.print "#{@destination_user}@#{@destination_host}:#{@destination_path}" end |