lxdev 0.1.4 → 0.1.5

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/lxdev +3 -2
  3. data/lib/lxdev/main.rb +9 -8
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c603e8b103efda46294c12b2fd712467c36acbab
4
- data.tar.gz: 46e2fdf820c4a1991e393a9242d3c86a7c6d50fa
3
+ metadata.gz: f40399ea2c4422f9a5b4b789d1b9347721fbc5e3
4
+ data.tar.gz: 6dc6ebd630f013876eb045ff166fb986efce1e0b
5
5
  SHA512:
6
- metadata.gz: 7cd7b1a83e49543fb0f0efbd71c8910e0cdf812c31c369a65651c6acb18f8251b55b2b676344d431166ceb27b6a3dad95275058cb6aea2bcdac8589aafba75c4
7
- data.tar.gz: 12b3fd2021f8a09e39c332093c6e5e4c0dfbbe9a489a979e09551e31cac2115c4c3afd7a563e724662584e4693a7ce93980c1950ef14694203c627f9acdb2b93
6
+ metadata.gz: fe19314ba8389725a6153c0529135a2a63404d73f5ebeba49a36bd8a07e41a0e65fdbb7bd9a7a0617ed7cd35a636b6bac9e71f476fb7fcef0477f24d0df061d0
7
+ data.tar.gz: 3edf3032409230181054edb3a27f9acb643c5a0af3ae0aa8387b90a03b53923bced72eec0ac17b7cac92063d100e0241f72e1a573241cbfa9c9cbaacad7228c9
data/bin/lxdev CHANGED
@@ -3,6 +3,7 @@ require 'lxdev/main'
3
3
  require 'optparse'
4
4
 
5
5
  $config_file = 'lxdev.yml'
6
+ $state_file = 'state'
6
7
 
7
8
  def option_parser
8
9
  opt_parser = OptionParser.new do |opts|
@@ -19,9 +20,9 @@ def option_parser
19
20
  end
20
21
 
21
22
  opts.on("-c F", "--config F", String, "Specify config file, defaults to lxdev.yml") do |filename|
22
- puts filename
23
23
  unless filename.nil?
24
24
  $config_file = filename
25
+ $state_file = format("%s_%s", 'state', File.basename($config_file, '.yml'))
25
26
  end
26
27
  end
27
28
 
@@ -106,7 +107,7 @@ end
106
107
 
107
108
 
108
109
  option_parser
109
- lxdev = LxDev::Main.setup($config_file)
110
+ lxdev = LxDev::Main.setup($config_file, $state_file)
110
111
  if lxdev
111
112
  execute_main_command(lxdev)
112
113
  lxdev.save_state
data/lib/lxdev/main.rb CHANGED
@@ -9,9 +9,10 @@ module LxDev
9
9
  WHITELISTED_SUDO_COMMANDS = ["lxc", "redir", "kill"]
10
10
  SHELLS = ["bash", "zsh", "sh", "csh", "tcsh", "ash"]
11
11
  BOOT_TIMEOUT = 30
12
- VERSION = '0.1.4'
12
+ VERSION = '0.1.5'
13
13
 
14
- def initialize(config_file)
14
+ def initialize(config_file, state_file)
15
+ @state_file = format(".lxdev/%s", state_file)
15
16
  @uid = System.exec("id -u").output.chomp
16
17
  @gid = System.exec("id -g").output.chomp
17
18
  @config = YAML.load_file(config_file)
@@ -21,7 +22,7 @@ module LxDev
21
22
  @ports = @config['box']['ports'] || {}
22
23
  Dir.mkdir('.lxdev') unless File.directory?('.lxdev')
23
24
  begin
24
- @state = YAML.load_file('.lxdev/state')
25
+ @state = YAML.load_file(@state_file)
25
26
  rescue
26
27
  @state = Hash.new
27
28
  end
@@ -30,13 +31,13 @@ module LxDev
30
31
  exit 1
31
32
  end
32
33
 
33
- def self.setup(config_file = 'lxdev.yml')
34
+ def self.setup(config_file = 'lxdev.yml', state_file = 'state')
34
35
  self.check_requirements
35
36
  unless lxd_initialized?
36
37
  puts "Please run 'lxd init' and configure LXD first"
37
38
  return false
38
39
  end
39
- lxdev = Main.new(config_file)
40
+ lxdev = Main.new(config_file, state_file)
40
41
  unless lxdev.set_ssh_keys
41
42
  puts "No ssh keys detected. Make sure you have an ssh key, a running agent, and the key added to the agent, e.g. with ssh-add."
42
43
  return false
@@ -45,7 +46,7 @@ module LxDev
45
46
  end
46
47
 
47
48
  def save_state
48
- File.open('.lxdev/state', 'w') {|f| f.write @state.to_yaml} unless @state.empty?
49
+ File.open(@state_file, 'w') {|f| f.write @state.to_yaml} unless @state.empty?
49
50
  end
50
51
 
51
52
  def set_ssh_keys
@@ -89,7 +90,7 @@ module LxDev
89
90
  def up
90
91
  do_provision = false
91
92
  unless @state.empty?
92
- puts "Container state .lxdev/state exists, is it running? If not it might have stopped unexpectedly. Please remove the file before starting."
93
+ puts "Container state #{@state_file} exists, is it running? If not it might have stopped unexpectedly. Please remove the file before starting."
93
94
  exit 1
94
95
  end
95
96
  if get_container_status.empty?
@@ -211,7 +212,7 @@ module LxDev
211
212
  end
212
213
 
213
214
  def remove_state
214
- File.delete('.lxdev/state') if File.exists?('.lxdev/state')
215
+ File.delete(@state_file) if File.exists?(@state_file)
215
216
  @state = {}
216
217
  end
217
218
 
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
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Lønaas
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-03-18 00:00:00.000000000 Z
12
+ date: 2019-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json