Commit a213d4b9 authored by Riyad Preukschas's avatar Riyad Preukschas

Move OS detection to task helpers and add detection of OS X

parent fd836f54
...@@ -3,20 +3,6 @@ namespace :gitlab do ...@@ -3,20 +3,6 @@ namespace :gitlab do
desc "GITLAB | Show information about GitLab and its environment" desc "GITLAB | Show information about GitLab and its environment"
task info: :environment do task info: :environment do
# check which OS is running
os_name = run("lsb_release -irs")
os_name ||= if File.readable?('/etc/system-release')
File.read('/etc/system-release')
end
os_name ||= if File.readable?('/etc/debian_version')
debian_version = File.read('/etc/debian_version')
"Debian #{debian_version}"
end
os_name ||= if File.readable?('/etc/SuSE-release')
File.read('/etc/SuSE-release')
end
os_name.try(:squish!)
# check if there is an RVM environment # check if there is an RVM environment
rvm_version = run_and_match("rvm --version", /[\d\.]+/).try(:to_s) rvm_version = run_and_match("rvm --version", /[\d\.]+/).try(:to_s)
# check Ruby version # check Ruby version
......
namespace :gitlab do namespace :gitlab do
# Check which OS is running
#
# It will primarily use lsb_relase to determine the OS.
# It has fallbacks to Debian, SuSE and OS X.
def os_name
os_name = run("lsb_release -irs")
os_name ||= if File.readable?('/etc/system-release')
File.read('/etc/system-release')
end
os_name ||= if File.readable?('/etc/debian_version')
debian_version = File.read('/etc/debian_version')
"Debian #{debian_version}"
end
os_name ||= if File.readable?('/etc/SuSE-release')
File.read('/etc/SuSE-release')
end
os_name ||= if os_x_version = run("sw_vers -productVersion")
"Mac OS X #{os_x_version}"
end
os_name.try(:squish!)
end
# Runs the given command and matches the output agains the given pattern # Runs the given command and matches the output agains the given pattern
# #
# Returns nil if nothing matched # Returns nil if nothing matched
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment