# check HOST OS
if not Utils.check_host_OS() then
- puts "Error: Your host OS is not supported!"
- exit 1
+
+ if Utils.is_linux_like_os Utils::HOST_OS then
+ Utils.set_default_linux_host_os
+ puts "Warning: Your host OS is not supported!\nWe assume your host OS as #{Utils::HOST_OS} !!!"
+ else
+ puts "Error: Your host OS is not supported!"
+ exit 1
+ end
end
def query( ip, port, sym )
# check HOST OS
if not Utils.check_host_OS() then
- puts "Error: Your host OS is not supported!"
- exit 1
+
+ if Utils.is_linux_like_os Utils::HOST_OS then
+ Utils.set_default_linux_host_os
+ puts "Warning: Your host OS is not supported!\nWe assume your host OS as #{Utils::HOST_OS} !!!"
+ else
+ puts "Error: Your host OS is not supported!"
+ exit 1
+ end
end
# if "--os" is not specified, use host os type
# check HOST OS
if not Utils.check_host_OS() then
- puts "Error: Your host OS is not supported!"
- exit 1
+
+ if Utils.is_linux_like_os Utils::HOST_OS then
+ Utils.set_default_linux_host_os
+ puts "Warning: Your host OS is not supported!\nWe assume your host OS as #{Utils::HOST_OS} !!!"
+ else
+ puts "Error: Your host OS is not supported!"
+ exit 1
+ end
end
#if "--os" is not specfied, use host os type
if option[:os].nil? then
case `uname -s`.strip
when "Linux"
+ arch = `getconf LONG_BIT`.strip
+ arch = "unknown" if arch.length != 2
if File.exist? "/etc/debian_version" then
- arch = (`uname -i`.strip == "x86_64") ? "64" : "32"
os = "ubuntu-#{arch}"
elsif File.exist? "/etc/redhat-release" then
- os = "redhat-unknown"
+ os = "redhat-#{arch}"
elsif File.exist? "/etc/SuSE-release" then
- arch = (`uname -i`.strip == "x86_64") ? "64" : "32"
os = "opensuse-#{arch}"
elsif File.exist? "/etc/mandrake-release" then
- os = "mandrake-unknown"
+ os = "mandrake-#{arch}"
+ else
+ os = "unknownlinux-#{arch}"
end
when "MINGW32_NT-5.1"
progfile_path = Utils.execute_shell_return("echo $PROGRAMFILES","windows")[0].strip
return os
end
+ def Utils.set_default_linux_host_os()
+ HOST_OS.sub!(/.*-/,"ubuntu-")
+ end
def Utils.check_host_OS()
if Utils.get_all_OSs().include? HOST_OS then
def Utils.get_all_OSs()
- return ["ubuntu-32","ubuntu-64","windows-32","windows-64","macos-64","opensuse-32", "opensuse-64"]
+ return ["ubuntu-32","ubuntu-64","windows-32","windows-64","macos-64"]
end
# check if the os is unix-like
def Utils.is_unix_like_os(os_name)
- if os_name.start_with? "ubuntu-" or
- os_name.start_with? "opensuse-" or
+ if Utils.is_linux_like_os os_name or
os_name.start_with?"macos-" then
return true
else
# check if the os is linux-like
def Utils.is_linux_like_os(os_name)
if os_name.start_with? "ubuntu-" or
- os_name.start_with? "opensuse-" then
+ os_name.start_with? "redhat-" or
+ os_name.start_with? "opensuse-" or
+ os_name.start_with? "mandrake-" or
+ os_name.start_with? "unknownlinux-" then
return true
else
return false
def Utils.get_os_category(os_name)
- if os_name.start_with? "ubuntu-" or os_name.start_with? "opensuse-" then
+ if is_linux_like_os os_name then
return "linux"
- elsif os_name.start_with?"macos-" then
+ elsif is_macos_like_os os_name then
return "macos"
- elsif os_name.start_with? "windows-" then
+ elsif is_windows_like_os os_name then
return "windows"
else
return os_name