Skip to content

Instantly share code, notes, and snippets.

@denvazh
Last active December 17, 2015 07:39
Show Gist options
  • Save denvazh/5573930 to your computer and use it in GitHub Desktop.
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.
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}"
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
@denvazh
Copy link
Author

denvazh commented May 15, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment