1
0
mirror of https://git.baguette.netlib.re/Baguette/networkctl synced 2024-12-18 13:03:30 +00:00

OpenBSD > Linux, do not fake uname

This commit is contained in:
Philippe PITTOLI 2019-11-08 01:20:38 +01:00
parent 30030fc949
commit 2958e7a60e
2 changed files with 8 additions and 6 deletions

View File

@ -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

View File

@ -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