Skip to content

Commit 2aea2f1

Browse files
authored
Merge pull request #65 from redBorder/development
release 3.1.4
2 parents 320df46 + baace04 commit 2aea2f1

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.3
1+
3.1.4

resources/lib/rb_config_utils.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515

1616
module Config_utils
1717

18+
LOG_DIRECTORY = '/var/log/rb-register-common'
19+
LOG_FILE_NAME = 'register.log'
1820

1921
@modelist_path="/usr/lib/redborder/mode-list.yml"
22+
2023
#Function to check if mode is valid (if defined in mode-list.yml)
2124
#Returns true if it's valid and false if not
2225
#TODO: protect from exception like file not found
@@ -80,13 +83,15 @@ def self.replace_chef_server_url(cdomain)
8083
end
8184
end
8285

86+
def self.log_file
87+
File.join(LOG_DIRECTORY, LOG_FILE_NAME)
88+
end
89+
8390
# Create log file for registration without rb-register
8491
def self.ensure_log_file_exists
85-
log_directory = '/var/log/rb-register-common'
86-
log_file = "#{log_directory}/register.log"
8792

88-
unless Dir.exist?(log_directory)
89-
system("mkdir -p #{log_directory}")
93+
unless Dir.exist?(LOG_DIRECTORY)
94+
system("mkdir -p #{LOG_DIRECTORY}")
9095
end
9196

9297
if File.exist?(log_file)

resources/scripts/rb_init_conf.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,18 +344,23 @@ def local_tty_warning_wizard
344344
end
345345
else
346346
system("sudo hostnamectl set-hostname #{ips_node_name}")
347-
system("/usr/lib/redborder/scripts/rb_associate_sensor.rb -u #{webui_user} -p #{webui_pass} -i #{Config_utils.get_ip_address} -m #{webui_host}")
347+
Config_utils.ensure_log_file_exists
348+
system("echo 'Sensor #{ips_node_name} association in progress...' > #{Config_utils.log_file}")
349+
system("/usr/lib/redborder/scripts/rb_associate_sensor.rb -u #{webui_user} -p #{webui_pass} -i #{Config_utils.get_ip_address} -m #{webui_host} >> #{Config_utils.log_file} 2>&1")
348350
if $?.exitstatus == 0
349351
Config_utils.hook_hosts(webui_host, cdomain)
350352
Config_utils.replace_chef_server_url(cdomain)
351-
Config_utils.ensure_log_file_exists
353+
352354
system("sed -i '/webui_pass/d' #{INITCONF}")
353355
puts "Sensor registered to the manager, please wait..."
354-
puts "You can see logs in /var/log/rb-register-common/register.log"
355-
system('/usr/lib/redborder/bin/rb_register_finish.sh > /var/log/rb-register-common/register.log 2>&1')
356+
puts "You can see logs in #{Config_utils.log_file}"
357+
system("/usr/lib/redborder/bin/rb_register_finish.sh >> #{Config_utils.log_file} 2>&1")
356358
puts "Registration and configuration finished!"
357359
else
358-
puts "Error: rb_associate_sensor.rb failed with exit status #{$?.exitstatus}. Please review #{INITCONF} file or network configuration..."
360+
361+
puts "Error: Sensor association failed with exit status #{$?.exitstatus}."
362+
puts "Please review #{INITCONF} file or network configuration..."
363+
puts "See \"#{Config_utils.log_file}\" for more details."
359364
end
360365
end
361366
end

0 commit comments

Comments
 (0)