nfsadmin 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bin/nfsadmin +4 -2
- data/lib/nfsadmin/tasks.rb +24 -5
- data/lib/nfsadmin/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a4ade82f161c6de715391d95d43c45b0d999135
|
4
|
+
data.tar.gz: f27866c6cb23523f7492d227a0d497d91a23a335
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dea59632b93fb1df2c210e9ddb6b6fc2a297b2e861e26b601594822b7a378888c57744f3a71533619198c3575c8cfd5bad2594812d76592c5a791ebd7f793a5
|
7
|
+
data.tar.gz: a959e3f73eff8e24ccb4a55091481b7df2a13e9ffaad0372a4fb3e0e830a4decb7f3c47197117c4771fc9ddd50d7d6c4fa57c9785e39f9f46532fe82fd86cf7a
|
data/Gemfile.lock
CHANGED
data/bin/nfsadmin
CHANGED
@@ -33,8 +33,10 @@ command :export do |c|
|
|
33
33
|
add.flag [:a, :address]
|
34
34
|
add.desc 'The NFS options for this share, e.g. rw,sync,no_root_squash,no_subtree_check'
|
35
35
|
add.flag [:o, :options]
|
36
|
+
add.desc 'This option forces the location to be created'
|
37
|
+
add.switch [:c, :create]
|
36
38
|
add.action do |global_options,options,args|
|
37
|
-
Nfsadmin::Tasks.create_share(global_options[:c], options[:l], options[:a], options[:o])
|
39
|
+
Nfsadmin::Tasks.create_share(global_options[:c], options[:l], options[:a], options[:o], options[:c])
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
@@ -48,7 +50,7 @@ command :export do |c|
|
|
48
50
|
c.desc 'Get information about a specific share'
|
49
51
|
c.command [:get] do |get|
|
50
52
|
get.action do |global_options,options,args|
|
51
|
-
Nfsadmin::Tasks.
|
53
|
+
Nfsadmin::Tasks.print_share(global_options[:c], options[:l], options[:f])
|
52
54
|
end
|
53
55
|
end
|
54
56
|
end
|
data/lib/nfsadmin/tasks.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
module Nfsadmin
|
4
5
|
|
@@ -72,9 +73,11 @@ module Nfsadmin
|
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
75
|
-
def self.create_share(exportsfile, location, address, options)
|
76
|
+
def self.create_share(exportsfile, location, address, options, createlocation)
|
76
77
|
if location.nil?
|
77
78
|
fail 'Location must be specified'
|
79
|
+
else
|
80
|
+
fail 'Location must be an absolute path' unless (Pathname.new(location)).absolute?
|
78
81
|
end
|
79
82
|
if address.nil?
|
80
83
|
fail 'Address must be specified'
|
@@ -82,6 +85,9 @@ module Nfsadmin
|
|
82
85
|
if options.nil?
|
83
86
|
fail 'Options must be specified'
|
84
87
|
end
|
88
|
+
if createlocation
|
89
|
+
FileUtils::mkdir_p location unless File.directory?(location)
|
90
|
+
end
|
85
91
|
share = { :location => location,
|
86
92
|
:acl => [{
|
87
93
|
:address => address,
|
@@ -93,6 +99,7 @@ module Nfsadmin
|
|
93
99
|
if existingshare.nil?
|
94
100
|
shares << share
|
95
101
|
write_exports(exportsfile, shares)
|
102
|
+
puts 'Share created'
|
96
103
|
else
|
97
104
|
puts 'Share already exists. Use nfsadmin export modify to change it. Skipping'
|
98
105
|
end
|
@@ -104,16 +111,28 @@ module Nfsadmin
|
|
104
111
|
end
|
105
112
|
shares = get_shares(exportsfile)
|
106
113
|
share = shares.find { |share| share[:location] == location }
|
107
|
-
|
108
|
-
|
114
|
+
if share.nil?
|
115
|
+
fail "#{location} not found"
|
116
|
+
else
|
117
|
+
shares.delete(share)
|
118
|
+
write_exports(exportsfile, shares)
|
119
|
+
puts "Deleted #{location}"
|
120
|
+
end
|
109
121
|
end
|
110
122
|
|
111
|
-
def self.get_share(exportsfile, location
|
123
|
+
def self.get_share(exportsfile, location)
|
112
124
|
if location.nil?
|
113
125
|
fail 'Location must be specified with -l or --location='
|
114
126
|
end
|
115
127
|
shares = get_shares(exportsfile)
|
116
|
-
|
128
|
+
shares.find { |share| share[:location] == location }
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.print_share(exportsfile, location, output_type)
|
132
|
+
share = get_share(exportsfile, location)
|
133
|
+
if share.nil?
|
134
|
+
fail 'share not found'
|
135
|
+
end
|
117
136
|
if output_type.downcase == 'text'
|
118
137
|
printf('%-40s', share[:location])
|
119
138
|
share[:acl].each do |acl|
|
data/lib/nfsadmin/version.rb
CHANGED