linecook-gem 0.4.0 → 0.4.1
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/lib/linecook/builder/linux_backend.rb +0 -10
- data/lib/linecook/util/config.rb +27 -18
- data/lib/linecook/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: c897a173dfc0fbfff66b44853e4d7e5fbf735fb3
|
4
|
+
data.tar.gz: ad92c0dd3f835ea109f2dd2d5024133a91774e00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82ea68ce99f675787d7c03b0c039cf74c0cb28c3715238ccf87440e8833e9dec6c48adbd71e021012655a87f7fedad1e4d54318cd7e0f704ac43fbdc505a2371
|
7
|
+
data.tar.gz: 88072bf2787e866ff4d5ac44301966796ab465c0fe471955034c22cc819e18629d809db97b27c04556d65043e3587dd232e21231e7719f2b5a713de70da4643a
|
@@ -1,21 +1,11 @@
|
|
1
1
|
module Linecook
|
2
2
|
module LinuxBuilder
|
3
3
|
extend self
|
4
|
-
LXC_MIN_VERSION = '1.1.4'
|
5
4
|
|
6
5
|
def backend
|
7
|
-
check_lxc_version
|
8
6
|
config = Linecook.config[:builder]
|
9
7
|
images = Linecook.config[:image][:images]
|
10
8
|
Linecook::Lxc::Container.new(name: config[:name], home: config[:home], image: config[:image], bridge: true)
|
11
9
|
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
# FIXME: move to dependency check during initial setup if on linux
|
16
|
-
def check_lxc_version
|
17
|
-
version = `lxc-info --version`
|
18
|
-
fail "lxc too old (<#{LXC_MIN_VERSION}) or not present" unless Gem::Version.new(version) >= Gem::Version.new(LXC_MIN_VERSION)
|
19
|
-
end
|
20
10
|
end
|
21
11
|
end
|
data/lib/linecook/util/config.rb
CHANGED
@@ -14,6 +14,7 @@ module Linecook
|
|
14
14
|
extend self
|
15
15
|
attr_reader :config
|
16
16
|
|
17
|
+
LXC_MIN_VERSION = '1.1.4'
|
17
18
|
CONFIG_PATH = File.join(Dir.pwd, 'linecook.yml').freeze # File.expand_path('../../../config/config.yml', __FILE__)
|
18
19
|
SECRETS_PATH = File.join(Dir.pwd, 'secrets.ejson').freeze # File.expand_path('../../../config/config.yml', __FILE__)
|
19
20
|
LINECOOK_HOME = File.expand_path('~/.linecook').freeze
|
@@ -81,24 +82,6 @@ module Linecook
|
|
81
82
|
end
|
82
83
|
end
|
83
84
|
|
84
|
-
def setup
|
85
|
-
FileUtils.mkdir_p(LINECOOK_HOME)
|
86
|
-
config = {}
|
87
|
-
config.merge!(YAML.load(File.read(DEFAULT_CONFIG_PATH))) if File.exist?(DEFAULT_CONFIG_PATH)
|
88
|
-
File.write(DEFAULT_CONFIG_PATH, YAML.dump(DEFAULT_CONFIG.deep_merge(config)))
|
89
|
-
check_perms if platform == 'darwin'
|
90
|
-
end
|
91
|
-
|
92
|
-
def check_perms
|
93
|
-
fix_perms if (File.stat(Xhyve::BINARY_PATH).uid != 0 || !File.stat(Xhyve::BINARY_PATH).setuid?)
|
94
|
-
end
|
95
|
-
|
96
|
-
def fix_perms
|
97
|
-
puts "Xhyve requires root until https://github.com/mist64/xhyve/issues/60 is resolved\nPlease enter your sudo password to setuid on the xhyve binary"
|
98
|
-
system("sudo chown root #{Xhyve::BINARY_PATH}")
|
99
|
-
system("sudo chmod +s #{Xhyve::BINARY_PATH}")
|
100
|
-
end
|
101
|
-
|
102
85
|
def load_config
|
103
86
|
@config ||= begin
|
104
87
|
config_path = ENV['LINECOOK_CONFIG_PATH'] || CONFIG_PATH
|
@@ -120,6 +103,32 @@ module Linecook
|
|
120
103
|
end
|
121
104
|
end
|
122
105
|
|
106
|
+
private
|
107
|
+
|
108
|
+
def setup
|
109
|
+
FileUtils.mkdir_p(LINECOOK_HOME)
|
110
|
+
config = {}
|
111
|
+
config.merge!(YAML.load(File.read(DEFAULT_CONFIG_PATH))) if File.exist?(DEFAULT_CONFIG_PATH)
|
112
|
+
File.write(DEFAULT_CONFIG_PATH, YAML.dump(DEFAULT_CONFIG.deep_merge(config)))
|
113
|
+
check_perms if platform == 'darwin'
|
114
|
+
check_lxc if platform == 'linux'
|
115
|
+
end
|
116
|
+
|
117
|
+
def check_lxc
|
118
|
+
version = `sudo lxc-info --version`
|
119
|
+
fail "lxc too old (<#{LXC_MIN_VERSION}) or not present" unless Gem::Version.new(version) >= Gem::Version.new(LXC_MIN_VERSION)
|
120
|
+
end
|
121
|
+
|
122
|
+
def check_perms
|
123
|
+
fix_perms if (File.stat(Xhyve::BINARY_PATH).uid != 0 || !File.stat(Xhyve::BINARY_PATH).setuid?)
|
124
|
+
end
|
125
|
+
|
126
|
+
def fix_perms
|
127
|
+
puts "Xhyve requires root until https://github.com/mist64/xhyve/issues/60 is resolved\nPlease enter your sudo password to setuid on the xhyve binary"
|
128
|
+
system("sudo chown root #{Xhyve::BINARY_PATH}")
|
129
|
+
system("sudo chmod +s #{Xhyve::BINARY_PATH}")
|
130
|
+
end
|
131
|
+
|
123
132
|
setup
|
124
133
|
end
|
125
134
|
end
|
data/lib/linecook/version.rb
CHANGED