summaryrefslogtreecommitdiff
path: root/byteback-setup-client-receive
diff options
context:
space:
mode:
authorMatthew Bloch <mattbee@yoga.home.bloch.tv>2014-12-04 15:37:58 +0000
committerMatthew Bloch <matthew@bytemark.co.uk>2014-12-04 15:40:39 +0000
commit2fb6dde5a5bf3d7090d2a4b8f8770341c9cb3781 (patch)
treedb8da5003af62bfde13682d8baee8547749b8b5c /byteback-setup-client-receive
parent0158f0de3fd0a9bae070dfee9a5df4c2deb5c6f7 (diff)
Bug fixes to new client setup code.
Diffstat (limited to 'byteback-setup-client-receive')
-rwxr-xr-xbyteback-setup-client-receive20
1 files changed, 15 insertions, 5 deletions
diff --git a/byteback-setup-client-receive b/byteback-setup-client-receive
index 35a3b65..79df12b 100755
--- a/byteback-setup-client-receive
+++ b/byteback-setup-client-receive
@@ -2,7 +2,13 @@
#
# Called by byteback-setup-client to set up a new byteback-setup-client
+$: << '/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"
@@ -28,15 +34,19 @@ error("Couldn't create btrfs subvolume (needs sudo)") unless
FileUtils.mkdir_p(".ssh")
-error("This key already exists in .ssh/authorized_keys on server") if
- File.exists?(".ssh/authorized_keys") &&
+if File.exists?(".ssh/authorized_keys") &&
File.read(".ssh/authorized_keys").match(@pubkey.split(/\s+/)[1])
-File.open(".ssh/authorized_keys", "a+") do |fh|
- fh.print <<-LINE.gsub(/\n/,"")
+ warn("This key already exists in .ssh/authorized_keys on server, nothing to do!")
+
+else
+
+ File.open(".ssh/authorized_keys", "a+") do |fh|
+ fh.print <<-LINE.gsub(/\n/,"")
command="byteback-receive",
from="#{@client_ip}",
environment="BYTEBACK_HOST=#{@hostname}"
#{@pubkey}
- LINE
+ LINE
+ end
end