Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/17621 fix rbcli service in proxy/ips #60

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions resources/libraries/ips_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ def ips_services
end
end

begin
file_services = JSON.parse(File.read('/etc/redborder/services.json'))
rescue Errno::ENOENT, JSON::ParserError => e
Chef::Log.warn("Error loading services from file: #{e.message}")
file_services = {}
end

systemd_services = node.attributes['redborder']['systemdservices']
systemd_services.each do |service_name, systemd_name|
sys_name = systemd_name.join(',')
if file_services.key?(sys_name)
ips_services[service_name] = file_services[sys_name]
end
end

ips_services
end
end
Expand Down
4 changes: 2 additions & 2 deletions resources/recipes/configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
if ips_services['snmp']
action :add
else
actopm :remove
action :remove
end
end

Expand Down Expand Up @@ -338,7 +338,7 @@
if ips_services['redborder-monitor'] && sensor_id > 0
action :add
else
actio :remove
action :remove
end
end

Expand Down
18 changes: 10 additions & 8 deletions resources/recipes/prepare_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@
memory_services(sysmem_total)

# Build service list for rbcli
services = node['redborder']['services'] || []
systemd_services = node['redborder']['systemdservices'] || []
service_enablement = {}
unless File.exist?('/etc/redborder/services.json')
services = node['redborder']['services'] || []
systemd_services = node['redborder']['systemdservices'] || []
service_enablement = {}

systemd_services.each do |service_name, systemd_name|
service_enablement[systemd_name.first] = services[service_name]
end
systemd_services.each do |service_name, systemd_name|
service_enablement[systemd_name.first] = services[service_name]
end

Chef::Log.info('Saving services enablement into /etc/redborder/services.json')
File.write('/etc/redborder/services.json', JSON.pretty_generate(service_enablement))
Chef::Log.info('Saving services enablement into /etc/redborder/services.json')
File.write('/etc/redborder/services.json', JSON.pretty_generate(service_enablement))
end
Loading