summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Gerus <arachnist@i.am-a.cat>2013-09-01 21:32:36 +0200
committerRobert Gerus <arachnist@i.am-a.cat>2013-09-01 21:32:36 +0200
commitf933839257915bcc6b902df77b5e196210258f5a (patch)
tree3c8947baf7f2c6cd84424ff95025eb0048b1f181
parent8c9a965fb42e1a0dd942680487baebaa6e4b8198 (diff)
downloadzvolcreator-f933839257915bcc6b902df77b5e196210258f5a.tar.gz
zvolcreator-f933839257915bcc6b902df77b5e196210258f5a.tar.bz2
zvolcreator-f933839257915bcc6b902df77b5e196210258f5a.zip
Some extra messages.
-rwxr-xr-xzvolcreator.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/zvolcreator.rb b/zvolcreator.rb
index a98bee7..fb7de12 100755
--- a/zvolcreator.rb
+++ b/zvolcreator.rb
@@ -12,26 +12,32 @@ puts "Filesystem base: #{Config[:basefs]}"
puts "Default user quota: #{Config[:default_user_quota]}"
puts "Socket path: #{Config[:socketpath]}"
sockdir = File.dirname(Config[:socketpath])
-puts "socket directory: #{sockdir}"
+puts "Socket directory: #{sockdir}"
# Check if socket directory exists, if not - create if with apropriate options
Dir.mkdir(sockdir, 0700) if not File.exists?(sockdir)
File.umask(0077)
-puts "setting up UUID generator"
+puts "Setting up UUID generator"
UUID.state_file = false
+puts "Starting socket server"
server = UNIXServer.open(Config[:socketpath])
loop do
Thread.start(server.accept) do |client|
begin
+ puts "Accepted new client connection"
uuid = UUID.new
+ puts "Sending our greeting"
client.puts({:status => 0, :content => {:app => "zvolcreator", :apiversion => 0}}.to_json)
response = JSON.parse(client.read)
+ puts "Client response: #{response}"
raise ArgumentError.new("Bad status") if response["status"] != 0
+ puts "Sending basic server info"
client.puts({:status => 0, :content => {:basefs => Config[:basefs], :default_user_quota => Config[:default_user_quota]}}.to_json)
response = JSON.parse(client.read)
+ puts "Client response: #{response}"
raise ArgumentError.new("Bad status") if response["status"] != 0
raise ArgumentError.new("No user specified") if not response["content"]["user"]
raise ArgumentError.new("Volume size not specified") if not response["content"]["volsize"]
@@ -45,6 +51,7 @@ loop do
ZFS(volpath).create(:sparse => true, :volume => response["content"]["volsize"])
client.puts({:status => 0, :content => {:volpath => volpath}}.to_json)
rescue JSON::ParserError, ArgumentError => e
+ puts "Error: #{e.to_s}"
client.puts({:status => 1, :content => e.to_s})
client.close
Thread.kill