lxdev 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/lxdev/main.rb +23 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bd005fcf499291c992c0176018a0feac0e2fca7bc8a130801d2089a92dabc313
|
4
|
+
data.tar.gz: fb3a2b1facc6caedd1928dd03f0c6cd710a99bfdc30355721978d9146e9616bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67cd321fc6066831e289c92887566034a452c8128d36be956c5f7021ebf618ab31d66abb9ef62ae02f745b64519fce38c069a00bed4791e00de9e9cd22183f87
|
7
|
+
data.tar.gz: 66be27cb60e0d0442b73c5be27d128aa8222614b62b53f1d2f300ed60978aa27b3ad439a9b9b6434946ae0cc4d169eea39333283c5e4107f69bcc87c1ebb8f11
|
data/lib/lxdev/main.rb
CHANGED
@@ -8,7 +8,7 @@ module LxDev
|
|
8
8
|
WHITELISTED_SUDO_COMMANDS = ["lxc", "redir", "kill"]
|
9
9
|
SHELLS = ["bash", "zsh", "sh", "csh", "tcsh", "ash"]
|
10
10
|
BOOT_TIMEOUT = 30
|
11
|
-
VERSION = '0.1.
|
11
|
+
VERSION = '0.1.3'
|
12
12
|
|
13
13
|
def initialize
|
14
14
|
@uid = System.exec("id -u").output.chomp
|
@@ -30,6 +30,7 @@ module LxDev
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.setup
|
33
|
+
self.check_requirements
|
33
34
|
unless lxd_initialized?
|
34
35
|
puts "Please run 'lxd init' and configure LXD first"
|
35
36
|
return false
|
@@ -339,8 +340,25 @@ module LxDev
|
|
339
340
|
end
|
340
341
|
end
|
341
342
|
|
343
|
+
def self.check_requirements
|
344
|
+
WHITELISTED_SUDO_COMMANDS.each do |cmd|
|
345
|
+
unless System.exec("which #{cmd}").exitstatus == 0
|
346
|
+
puts "The command '#{cmd}' is not installed or not available."
|
347
|
+
puts "Please install it before continuing."
|
348
|
+
exit 1
|
349
|
+
end
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
342
353
|
def self.create_sudoers_file
|
354
|
+
self.check_requirements
|
343
355
|
user = System.exec("whoami").output.chomp
|
356
|
+
content = []
|
357
|
+
content << "# Created by lxdev #{Time.now}"
|
358
|
+
WHITELISTED_SUDO_COMMANDS.each do |cmd|
|
359
|
+
cmd_with_path = System.exec("which #{cmd}").output.chomp
|
360
|
+
content << "#{user} ALL=(root) NOPASSWD: #{cmd_with_path}"
|
361
|
+
end
|
344
362
|
puts <<-EOS
|
345
363
|
!! WARNING !!
|
346
364
|
This will create a file, /etc/sudoers.d/lxdev,
|
@@ -350,19 +368,16 @@ the following commands :
|
|
350
368
|
with superuser privileges. If you do not know what you're
|
351
369
|
doing, this can be dangerous and insecure.
|
352
370
|
|
353
|
-
If you want to do this, type 'yesplease'
|
354
371
|
EOS
|
372
|
+
puts "The following content will be created in /etc/sudoers.d/lxdev :"
|
373
|
+
puts
|
374
|
+
puts content
|
375
|
+
puts "\nIf you want to do this, type 'yesplease'"
|
355
376
|
action = STDIN.gets.chomp
|
356
377
|
unless action == 'yesplease'
|
357
378
|
puts "Not creating sudoers file"
|
358
379
|
return
|
359
380
|
end
|
360
|
-
content = []
|
361
|
-
content << "# Created by lxdev #{Time.now}"
|
362
|
-
WHITELISTED_SUDO_COMMANDS.each do |cmd|
|
363
|
-
cmd_with_path = System.exec("which #{cmd}").output.chomp
|
364
|
-
content << "#{user} ALL=(root) NOPASSWD: #{cmd_with_path}"
|
365
|
-
end
|
366
381
|
System.exec(%{printf '#{content.join("\n")}\n' | sudo tee /etc/sudoers.d/lxdev})
|
367
382
|
System.exec("sudo chmod 0440 /etc/sudoers.d/lxdev")
|
368
383
|
puts "Created sudoers file."
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lxdev
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Lønaas
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
version: '0'
|
70
70
|
requirements: []
|
71
71
|
rubyforge_project:
|
72
|
-
rubygems_version: 2.
|
72
|
+
rubygems_version: 2.7.6
|
73
73
|
signing_key:
|
74
74
|
specification_version: 4
|
75
75
|
summary: Automagic development environment with LXD
|