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:
parent
30030fc949
commit
2958e7a60e
@ -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
|
||||
|
11
src/cli.cr
11
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
|
||||
|
Loading…
Reference in New Issue
Block a user