Last active
December 17, 2015 07:39
-
-
Save denvazh/5573930 to your computer and use it in GitHub Desktop.
Currently, gitlab supports only Debian based OS where scripts are installed under /etc/init.d/ by default.
Patches below has few improvements to the gitlab check and task_helper rake scripts to verify whether init script was installed on FreeBSD machine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake | |
index a57c349..3253e16 100644 | |
--- a/lib/tasks/gitlab/check.rake | |
+++ b/lib/tasks/gitlab/check.rake | |
@@ -118,7 +118,7 @@ namespace :gitlab do | |
def check_init_script_exists | |
print "Init script exists? ... " | |
- script_path = "/etc/init.d/gitlab" | |
+ script_path = get_init_script_syspath | |
if File.exists?(script_path) | |
puts "yes".green | |
@@ -137,13 +137,15 @@ namespace :gitlab do | |
def check_init_script_up_to_date | |
print "Init script up-to-date? ... " | |
- script_path = "/etc/init.d/gitlab" | |
+ script_path = get_init_script_syspath | |
+ | |
unless File.exists?(script_path) | |
puts "can't check because of previous errors".magenta | |
return | |
end | |
- recipe_content = `curl https://raw.github.com/gitlabhq/gitlab-recipes/5-1-stable/init.d/gitlab 2>/dev/null` | |
+ recipe_content_url = get_recipe_content_url | |
+ recipe_content = `curl #{recipe_content_url} 2>/dev/null` | |
script_content = File.read(script_path) | |
if recipe_content == script_content | |
@@ -620,6 +622,33 @@ namespace :gitlab do | |
end | |
end | |
+ def get_init_script_syspath | |
+ init_script_path = | |
+ if "#{RUBY_PLATFORM}".include?('freebsd') | |
+ "/usr/local/etc/rc.d/gitlab" | |
+ elsif "#{RUBY_PLATFORM}".include?('darwin') | |
+ # in case somebody would create a LunchDaemon plist for OS X | |
+ "/Library/LaunchDaemons/org.gitlab.daemon.plist" | |
+ else | |
+ # default is Linux | |
+ "/etc/init.d/gitlab" | |
+ end | |
+ | |
+ return init_script_path | |
+ end | |
+ | |
+ def get_recipe_content_url | |
+ recipe_content_url = | |
+ if "#{RUBY_PLATFORM}".include?('freebsd') | |
+ "https://gist.github.com/denvazh/5588936/raw/a99653679831368b7029ae0959e18da68799bff4/gitlab" | |
+ else | |
+ # default is Linux | |
+ "https://raw.github.com/gitlabhq/gitlab-recipes/5-1-stable/init.d/gitlab" | |
+ end | |
+ | |
+ return recipe_content_url | |
+ end | |
+ | |
def finished_checking(component) | |
puts "" | |
puts "Checking #{component.yellow} ... #{"Finished".green}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/tasks/gitlab/task_helpers.rake b/lib/tasks/gitlab/task_helpers.rake | |
index 34a4a32..335aeee 100644 | |
--- a/lib/tasks/gitlab/task_helpers.rake | |
+++ b/lib/tasks/gitlab/task_helpers.rake | |
@@ -35,6 +35,9 @@ namespace :gitlab do | |
os_name ||= if File.readable?('/etc/os-release') | |
File.read('/etc/os-release').match(/PRETTY_NAME=\"(.+)\"/)[1] | |
end | |
+ os_name ||= if bsd_version = run("uname -rs") | |
+ "#{bsd_version}" | |
+ end | |
os_name.try(:squish!) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to apply patches
Directly from github like this:
curl "https://gist.github.com/denvazh/5573930/raw/9b7380bbac5ba496f5cf87b54fe6240925f7ab4d/task_helpers.rake" | git apply -
curl "https://gist.github.com/denvazh/5573930/raw/2670867f8c8089c89a10ba4c7d923054c8e86f36/check.rake" | git apply -