summaryrefslogtreecommitdiff
path: root/byteback-setup-client
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2015-06-03 15:55:28 +0100
committerSteve Kemp <steve@steve.org.uk>2015-06-03 15:55:28 +0100
commita29380762b93737ae6949121010cd9bceb8196b2 (patch)
tree4dfe2931401d0cc73c38b9a90377e31210d6706e /byteback-setup-client
parentc4da983bd2a1e35450dcb21bdc7110f5fc0d166a (diff)
Relocated the binaries to bin/
Diffstat (limited to 'byteback-setup-client')
-rwxr-xr-xbyteback-setup-client70
1 files changed, 0 insertions, 70 deletions
diff --git a/byteback-setup-client b/byteback-setup-client
deleted file mode 100755
index d8ffbfa..0000000
--- a/byteback-setup-client
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/ruby
-#
-# Run on a client machine to set up backups for the first time
-#
-
-$LOAD_PATH.unshift('/usr/lib/byteback')
-
-require 'fileutils'
-require 'trollop'
-require 'byteback/util'
-require 'byteback/log'
-include Byteback::Util
-include Byteback::Log
-
-def error(message)
- STDERR.print "*** #{message}\n"
- exit 1
-end
-
-def verbose(message)
- print "#{message}\n"
-end
-
-opts = Trollop.options do
- opt :hostname, 'Set host name for backups',
- type: :string
-
- opt :destination, 'Backup destination (i.e. user@host:/path)',
- type: :string
-end
-
-@destination = opts[:destination]
-@hostname = opts[:hostname]
-
-_dummy, @destination_user, @destination_host, colon, @destination_path =
- /^(.*)?(?:@)([^:]+)(:)(.*)?$/.match(@destination).to_a
-
-@destination_user ||= 'byteback'
-@destination_path ||= ''
-@destination_host ||= @destination
-
-unless @hostname
- @hostname = `hostname -f`.chomp
- warn "No hostname set, using #{@hostname}\n"
-end
-
-FileUtils.mkdir_p('/etc/byteback')
-
-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
- system <<-KEYGEN
- ssh-keygen -q -t rsa -C "byteback client key" \
- -N "" -f /etc/byteback/key
- KEYGEN
-
-end
-
-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|
- f.print "#{@destination_user}@#{@destination_host}:#{@destination_path}"
-end
-
-print "Setup worked! To take your first backup run: byteback-backup --verbose\n"