From 2958e7a60e6ec141720e0e02d0d6fc419e1a4433 Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Fri, 8 Nov 2019 01:20:38 +0100 Subject: [PATCH] OpenBSD > Linux, do not fake uname --- src/autodetect_environment.cr | 3 ++- src/cli.cr | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/autodetect_environment.cr b/src/autodetect_environment.cr index 5a7a5ff..7387ae1 100644 --- a/src/autodetect_environment.cr +++ b/src/autodetect_environment.cr @@ -2,7 +2,8 @@ class Autodetect def self.uname os = nil : String? - Do.run("uname") do |p| + # do not fake it + Process.run("uname") do |p| p.output.each_line do |line| os = line end diff --git a/src/cli.cr b/src/cli.cr index 35a92e6..d103213 100644 --- a/src/cli.cr +++ b/src/cli.cr @@ -109,7 +109,13 @@ possible_wireless_configuration_cmds = { Context.os = Autodetect.uname case Context.os +when "OpenBSD" + NetworkCommands.cmd_network_configuration = NetworkCommands::OpenBSDIfconfigCommand + NetworkCommands.cmd_wireless_configuration = NetworkCommands::OpenBSDIfconfigCommand + NetworkCommands.cmd_dhcp_client = NetworkCommands::OpenBSDDHClientCommand + NetworkCommands.cmd_sysctl = NetworkCommands::OpenBSDSysctlCommand when "Linux" + puts "I'm on linux, look at me!" key = Context.prefered_network_configuration_program key = possible_network_configuration_cmds.keys.find { |key| Autodetect.which(key) } if key.nil? # should crash if there is no network command installed @@ -125,11 +131,6 @@ when "Linux" # should not crash if there is no dhcp client on the system NetworkCommands.cmd_dhcp_client = possible_dhcp_clients[key] unless key.nil? NetworkCommands.cmd_sysctl = NetworkCommands::SysctlCommand -when "OpenBSD" - NetworkCommands.cmd_network_configuration = NetworkCommands::OpenBSDIfconfigCommand - NetworkCommands.cmd_wireless_configuration = NetworkCommands::OpenBSDIfconfigCommand - NetworkCommands.cmd_dhcp_client = NetworkCommands::OpenBSDDHClientCommand - NetworkCommands.cmd_sysctl = NetworkCommands::OpenBSDSysctlCommand end files = Array(String).new