pi_customizer 0.3.0.pre.alpha → 0.3.1.pre.alpha
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/.gitignore +24 -0
- data/.travis.yml +28 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/LICENSE +1 -1
- data/README.md +208 -2
- data/Rakefile +134 -6
- data/Vagrantfile +13 -2
- data/docs/concept.md +27 -0
- data/docs/incubation.md +38 -0
- data/pi_build_modifier/.gitignore +12 -0
- data/{.rspec → pi_build_modifier/.rspec} +0 -0
- data/pi_build_modifier/Gemfile +6 -0
- data/pi_build_modifier/LICENSE.txt +21 -0
- data/pi_build_modifier/README.md +3 -0
- data/pi_build_modifier/Rakefile +13 -0
- data/pi_build_modifier/bin/pi_build_modifier +25 -0
- data/pi_build_modifier/lib/pi_build_modifier.rb +53 -0
- data/pi_build_modifier/lib/pi_build_modifier/boot-files/boot.rb +64 -0
- data/pi_build_modifier/lib/pi_build_modifier/boot-files/templates/07-resize-init.diff.erb +5 -0
- data/pi_build_modifier/lib/pi_build_modifier/config/logex.rb +25 -0
- data/pi_build_modifier/lib/pi_build_modifier/locale/locale_debconf.rb +66 -0
- data/pi_build_modifier/lib/pi_build_modifier/locale/templates/00-debconf.erb +6 -0
- data/pi_build_modifier/lib/pi_build_modifier/modifier/erb_mapper.rb +72 -0
- data/pi_build_modifier/lib/pi_build_modifier/modifier/mapper.rb +49 -0
- data/pi_build_modifier/lib/pi_build_modifier/modifier/pi_modifier.rb +81 -0
- data/pi_build_modifier/lib/pi_build_modifier/modifier_task.rb +79 -0
- data/pi_build_modifier/lib/pi_build_modifier/net-tweaks/templates/wpa_supplicant.conf.erb +5 -0
- data/pi_build_modifier/lib/pi_build_modifier/net-tweaks/wifi_network.rb +124 -0
- data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/run_modifier.rb +63 -0
- data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/ssh.rb +61 -0
- data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/templates/ssh.sh.erb +8 -0
- data/pi_build_modifier/lib/pi_build_modifier/system/system_type.rb +84 -0
- data/pi_build_modifier/lib/pi_build_modifier/version.rb +23 -0
- data/pi_build_modifier/pi_build_modifier.gemspec +32 -0
- data/pi_build_modifier/spec/fixtures/config.json +26 -0
- data/pi_build_modifier/spec/pi_build_modifier/boot/boot_spec.rb +103 -0
- data/pi_build_modifier/spec/pi_build_modifier/locale/locale_spec.rb +87 -0
- data/pi_build_modifier/spec/pi_build_modifier/modifier/mapper_spec.rb +105 -0
- data/pi_build_modifier/spec/pi_build_modifier/modifier/modifier_spec.rb +83 -0
- data/pi_build_modifier/spec/pi_build_modifier/modifier_task_spec.rb +63 -0
- data/pi_build_modifier/spec/pi_build_modifier/net-tweaks/wifi_network_spec.rb +91 -0
- data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/run_modifier_spec.rb +74 -0
- data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/ssh_spec.rb +73 -0
- data/pi_build_modifier/spec/pi_build_modifier/system/system_spec.rb +66 -0
- data/pi_build_modifier/spec/pi_build_modifier_spec.rb +73 -0
- data/pi_build_modifier/spec/spec_helper.rb +10 -0
- data/pi_customizer/.rspec +2 -0
- data/{Gemfile → pi_customizer/Gemfile} +0 -0
- data/pi_customizer/LICENSE +21 -0
- data/pi_customizer/README.md +3 -0
- data/pi_customizer/Rakefile +13 -0
- data/pi_customizer/Vagrantfile +16 -0
- data/{bin → pi_customizer/bin}/pi_customizer +1 -1
- data/{envs → pi_customizer/envs}/aws/outputs.tf +0 -0
- data/{envs → pi_customizer/envs}/aws/pi-build-env.tf +0 -0
- data/{envs → pi_customizer/envs}/aws/variables.tf +0 -0
- data/{envs → pi_customizer/envs}/docker/Dockerfile +0 -0
- data/{envs → pi_customizer/envs}/sh/build-pi-img.sh +0 -0
- data/{lib → pi_customizer/lib}/pi_customizer.rb +7 -6
- data/{lib → pi_customizer/lib}/pi_customizer/build/builder/build_executor.rb +31 -2
- data/{lib → pi_customizer/lib}/pi_customizer/build/builder/builder.rb +4 -2
- data/{lib → pi_customizer/lib}/pi_customizer/build/builder/prepare_start_execute_builder.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/builder/start_prepare_execute_builder.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/aws/aws.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/docker/docker.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/environment.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/environment_builder_factory.rb +9 -3
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/vagrant/templates/Vagrantfile.erb +3 -7
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/vagrant/vagrant.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/environment/vagrant/vagrant_file.rb +2 -2
- data/{lib → pi_customizer/lib}/pi_customizer/build/workspace/local_workspace.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/build/workspace/remote_workspace.rb +14 -4
- data/{lib → pi_customizer/lib}/pi_customizer/utils/logex.rb +1 -1
- data/{lib → pi_customizer/lib}/pi_customizer/version.rb +2 -2
- data/{lib → pi_customizer/lib}/pi_customizer/write/image_writer.rb +1 -1
- data/{pi_customizer.gemspec → pi_customizer/pi_customizer.gemspec} +5 -5
- data/pi_customizer/spec/fixtures/TestVagrantfile +61 -0
- data/pi_customizer/spec/fixtures/image.img +1 -0
- data/pi_customizer/spec/fixtures/image.zip +0 -0
- data/pi_customizer/spec/pi_customizer/builder/build_executor_spec.rb +64 -0
- data/pi_customizer/spec/pi_customizer/environment/aws_spec.rb +57 -0
- data/pi_customizer/spec/pi_customizer/environment/environment_builder_factory_spec.rb +48 -0
- data/pi_customizer/spec/pi_customizer/environment/environment_spec.rb +75 -0
- data/pi_customizer/spec/pi_customizer/environment/vagrant/vagrant_file_spec.rb +63 -0
- data/pi_customizer/spec/pi_customizer/environment/vagrant/vagrant_spec.rb +41 -0
- data/pi_customizer/spec/pi_customizer/version_spec.rb +29 -0
- data/pi_customizer/spec/pi_customizer/workspace/local_workspace_spec.rb +74 -0
- data/pi_customizer/spec/pi_customizer/workspace/remote_workspace_spec.rb +51 -0
- data/pi_customizer/spec/pi_customizer/write/image_writer_spec.rb +59 -0
- data/pi_customizer/spec/pi_customizer_spec.rb +93 -0
- data/pi_customizer/spec/spec_helper.rb +10 -0
- data/version.rb +21 -0
- metadata +102 -41
@@ -0,0 +1,49 @@
|
|
1
|
+
# Copyright (c) 2017-2019 Beate Ottenwälder
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
|
21
|
+
module PiBuildModifier
|
22
|
+
|
23
|
+
##
|
24
|
+
# Mapper represents a container that is used by the pi_build_modifier to call
|
25
|
+
# the necessary steps to modify a build configuration.
|
26
|
+
# It triggers check, mapping, and modification steps for one build configuration.
|
27
|
+
|
28
|
+
class Mapper
|
29
|
+
|
30
|
+
attr_reader :data
|
31
|
+
|
32
|
+
def initialize(data)
|
33
|
+
@data = data
|
34
|
+
end
|
35
|
+
|
36
|
+
def check(json_data)
|
37
|
+
@data.check(json_data) unless @data.nil?
|
38
|
+
end
|
39
|
+
|
40
|
+
def map(json_data)
|
41
|
+
@data.map(json_data) unless @data.nil?
|
42
|
+
end
|
43
|
+
|
44
|
+
def modify
|
45
|
+
@data.modify unless @data.nil?
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# Copyright (c) 2017-2019 Beate Ottenwälder
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
|
21
|
+
require 'json'
|
22
|
+
|
23
|
+
module PiBuildModifier
|
24
|
+
class PiModifier
|
25
|
+
|
26
|
+
attr_reader :mappers
|
27
|
+
|
28
|
+
def initialize
|
29
|
+
@mappers = Array.new
|
30
|
+
@json_path = nil
|
31
|
+
@json_data = nil
|
32
|
+
end
|
33
|
+
|
34
|
+
def with_json_configuration(json_file)
|
35
|
+
@json_path = json_file
|
36
|
+
end
|
37
|
+
|
38
|
+
def with_mapper(mapper)
|
39
|
+
if mapper.is_a? Mapper
|
40
|
+
@mappers << mapper
|
41
|
+
else
|
42
|
+
raise 'Parameter must be of type Mapper'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def modify(do_check = false)
|
47
|
+
load_config
|
48
|
+
check_all if do_check
|
49
|
+
map_all
|
50
|
+
modify_all
|
51
|
+
end
|
52
|
+
|
53
|
+
private def load_config
|
54
|
+
if File.file?(@json_path)
|
55
|
+
File.open(@json_path, 'r+') do |f|
|
56
|
+
@json_data = JSON.parse(f.read)
|
57
|
+
end
|
58
|
+
else
|
59
|
+
raise "Json configuration file does not exist at '#{@json_path}!'"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
private def check_all
|
64
|
+
@mappers.each do |mapper|
|
65
|
+
mapper.check(@json_data)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
private def map_all
|
70
|
+
@mappers.each do |mapper|
|
71
|
+
mapper.map(@json_data)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
private def modify_all
|
76
|
+
@mappers.each do |mapper|
|
77
|
+
mapper.modify
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# Copyright (c) 2017-2019 Beate Ottenwälder
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
|
21
|
+
require 'pi_build_modifier/modifier/pi_modifier'
|
22
|
+
require 'pi_build_modifier/modifier/erb_mapper'
|
23
|
+
require 'pi_build_modifier/net-tweaks/wifi_network'
|
24
|
+
require 'pi_build_modifier/system/system_type'
|
25
|
+
require 'pi_build_modifier/sys_tweaks/run_modifier'
|
26
|
+
require 'pi_build_modifier/sys_tweaks/ssh'
|
27
|
+
require 'pi_build_modifier/locale/locale_debconf'
|
28
|
+
require 'pi_build_modifier/boot-files/boot'
|
29
|
+
|
30
|
+
module PiBuildModifier
|
31
|
+
module Task
|
32
|
+
|
33
|
+
##
|
34
|
+
# Modifier triggers all changes specified in the config. To this end,
|
35
|
+
# it configures and calls specialized mappers which map the config to
|
36
|
+
# the the individual pi-gen build scripts.
|
37
|
+
|
38
|
+
class Modifier
|
39
|
+
|
40
|
+
attr_reader :pi_modifier
|
41
|
+
|
42
|
+
##
|
43
|
+
# Initialization and configuration of the mappers that are used to change in the pi-gen build sources
|
44
|
+
|
45
|
+
def initialize(config, workspace, pi_modifier = PiModifier.new)
|
46
|
+
@mappers = create_mappers
|
47
|
+
@pi_modifier = pi_modifier
|
48
|
+
configure_pi_modifier(config, workspace)
|
49
|
+
end
|
50
|
+
|
51
|
+
##
|
52
|
+
# Defines all mappers
|
53
|
+
|
54
|
+
private def create_mappers
|
55
|
+
mappers = {
|
56
|
+
:wpa_supplicant => WPASupplicant.new,
|
57
|
+
:system => System.new,
|
58
|
+
:ssh => Ssh.new,
|
59
|
+
:run_modifier => RunModifier.new,
|
60
|
+
:locale => Locale.new,
|
61
|
+
:boot => Boot.new
|
62
|
+
}
|
63
|
+
mappers[:run_modifier].append(mappers[:ssh]) #TODO: This connection has to be established somewhere else
|
64
|
+
mappers
|
65
|
+
end
|
66
|
+
|
67
|
+
private def configure_pi_modifier(config, workspace)
|
68
|
+
@pi_modifier.with_json_configuration(config)
|
69
|
+
@mappers.each do |*, mapper_data|
|
70
|
+
@pi_modifier.with_mapper(mapper_data.mapper(workspace))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def execute
|
75
|
+
@pi_modifier.modify
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# Copyright (c) 2017-2019 Beate Ottenwälder
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
|
21
|
+
require 'erb'
|
22
|
+
require 'json'
|
23
|
+
require 'openssl'
|
24
|
+
require 'pi_build_modifier/modifier/erb_mapper'
|
25
|
+
|
26
|
+
module PiBuildModifier
|
27
|
+
|
28
|
+
##
|
29
|
+
# WifiNetwork represents a network in the wpa_supplicant configuration
|
30
|
+
|
31
|
+
class WifiNetwork
|
32
|
+
|
33
|
+
attr_reader :ssid, :psk
|
34
|
+
|
35
|
+
def initialize(ssid, psk)
|
36
|
+
@ssid = ssid
|
37
|
+
@psk = psk
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_s
|
41
|
+
sprintf('{
|
42
|
+
ssid="%s"
|
43
|
+
psk=%s
|
44
|
+
}', ssid, psk)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# WPASupplicant represents the wpa_supplicant's configuration
|
50
|
+
|
51
|
+
class WPASupplicant
|
52
|
+
|
53
|
+
PASSPHRASE = 'passphrase'
|
54
|
+
|
55
|
+
WPA_PASSPHRASE = 'wpa_passphrase'
|
56
|
+
|
57
|
+
SSID = 'ssid'
|
58
|
+
|
59
|
+
attr_reader :template_path, :relative_output_path
|
60
|
+
|
61
|
+
##
|
62
|
+
# By default, WPASupplicant is configured with:
|
63
|
+
# wpa_country: DE
|
64
|
+
# template: './templates/wpa_supplicant.conf.erb'
|
65
|
+
# output path: 'stage2/02-net-tweaks/files/wpa_supplicant.conf'
|
66
|
+
|
67
|
+
def initialize
|
68
|
+
@networks = map_network(nil)
|
69
|
+
@wpa_country = 'DE'
|
70
|
+
@template_path = File.join(File.dirname(__FILE__), '/templates/wpa_supplicant.conf.erb').to_s
|
71
|
+
@relative_output_path = 'stage2/02-net-tweaks/files/wpa_supplicant.conf'
|
72
|
+
end
|
73
|
+
|
74
|
+
def mapper(workspace)
|
75
|
+
ERBMapper.new(self, workspace)
|
76
|
+
end
|
77
|
+
|
78
|
+
#TODO: test
|
79
|
+
def check(json_data)
|
80
|
+
unless File.file?(@relative_output_path)
|
81
|
+
raise "File #{relative_output_path} does not exist"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
##
|
86
|
+
# map the 'wifi' section in the json configuration to the instance variables.
|
87
|
+
|
88
|
+
def map(json_data)
|
89
|
+
unless json_data.nil?
|
90
|
+
@networks = map_network(json_data['wifi']) if json_data.has_key?('wifi')
|
91
|
+
@wpa_country = json_data['wifi']['wpa_country'] if json_data.has_key?('wifi') && json_data['wifi'].has_key?('wpa_country')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
private def map_network(json_data)
|
96
|
+
if json_data.nil? or not json_data.has_key?('networks')
|
97
|
+
networks = Array.new(0)
|
98
|
+
else
|
99
|
+
networks = json_data['networks'].map do |rd|
|
100
|
+
ssid = if rd.has_key?(SSID)
|
101
|
+
rd[SSID]
|
102
|
+
else
|
103
|
+
'no_ssid'
|
104
|
+
end
|
105
|
+
psk = if rd.has_key?(PASSPHRASE)
|
106
|
+
OpenSSL::PKCS5.pbkdf2_hmac_sha1(rd[PASSPHRASE], ssid, 4096, 32).unpack("H*").first
|
107
|
+
elsif rd.has_key?(WPA_PASSPHRASE)
|
108
|
+
rd[WPA_PASSPHRASE]
|
109
|
+
else
|
110
|
+
'no_psk'
|
111
|
+
end
|
112
|
+
WifiNetwork.new(ssid, psk)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
networks
|
116
|
+
end
|
117
|
+
|
118
|
+
def get_binding
|
119
|
+
binding
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Copyright (c) 2017-2019 Beate Ottenwälder
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
|
21
|
+
require 'fileutils'
|
22
|
+
require 'pi_build_modifier/modifier/mapper'
|
23
|
+
|
24
|
+
|
25
|
+
module PiBuildModifier
|
26
|
+
|
27
|
+
##
|
28
|
+
# RunModifier is a class which appends lines to the sys-tweaks run file in the pi-gen build directory.
|
29
|
+
# By default this is the file 'stage2/01-sys-tweaks/01-run.sh'.
|
30
|
+
|
31
|
+
class RunModifier < Mapper
|
32
|
+
|
33
|
+
attr_reader :relative_output_path, :appender
|
34
|
+
|
35
|
+
def initialize
|
36
|
+
@appender = Array.new
|
37
|
+
@workspace = nil
|
38
|
+
@relative_output_path = 'stage2/01-sys-tweaks/01-run.sh'
|
39
|
+
end
|
40
|
+
|
41
|
+
def mapper(workspace)
|
42
|
+
@workspace = workspace
|
43
|
+
self
|
44
|
+
end
|
45
|
+
|
46
|
+
def append(appender)
|
47
|
+
@appender << appender
|
48
|
+
end
|
49
|
+
|
50
|
+
##
|
51
|
+
# modify the sys-tweaks run file by adding lines at the end of the file
|
52
|
+
|
53
|
+
def modify
|
54
|
+
open("#{@workspace}/#{@relative_output_path}", 'a') do |f|
|
55
|
+
f.puts ''
|
56
|
+
@appender.each do |a|
|
57
|
+
f.puts "source #{@workspace}/#{a.append_line}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Copyright (c) 2017-2019 Beate Ottenwälder
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
|
21
|
+
require 'fileutils'
|
22
|
+
require 'pi_build_modifier/modifier/mapper'
|
23
|
+
require 'pi_build_modifier/sys_tweaks/run_modifier'
|
24
|
+
require 'pi_build_modifier/config/logex'
|
25
|
+
|
26
|
+
module PiBuildModifier
|
27
|
+
|
28
|
+
class Ssh
|
29
|
+
|
30
|
+
attr_accessor :enable
|
31
|
+
|
32
|
+
attr_reader :template_path, :relative_output_path
|
33
|
+
|
34
|
+
def initialize
|
35
|
+
@enable = 'enable'
|
36
|
+
@template_path = File.join(File.dirname(__FILE__), '/templates/ssh.sh.erb').to_s
|
37
|
+
@relative_output_path = 'stage2/01-sys-tweaks/ssh.sh'
|
38
|
+
end
|
39
|
+
|
40
|
+
def mapper(workspace)
|
41
|
+
ERBMapper.new(self, workspace)
|
42
|
+
end
|
43
|
+
|
44
|
+
def append_line
|
45
|
+
"#{@relative_output_path}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def map(json_data)
|
49
|
+
unless json_data.nil?
|
50
|
+
@enable = 'disable' if json_data.has_key?('ssh') && json_data['ssh'].has_key?('enabled') && (not json_data['ssh']['enabled'])
|
51
|
+
else
|
52
|
+
$logger.error 'Ssh could not be configured: Invalid json data.'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_binding
|
57
|
+
binding
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|