1_settings.rb 4.35 KB
Newer Older
1 2
class Settings < Settingslogic
  source "#{Rails.root}/config/gitlab.yml"
3
  namespace Rails.env
4 5

  class << self
6 7 8 9 10 11
    def gitlab_on_non_standard_port?
      ![443, 80].include?(gitlab.port.to_i)
    end

    private

12 13 14
    def build_gitlab_shell_ssh_path_prefix
      if gitlab_shell.ssh_port != 22
        "ssh://#{gitlab_shell.ssh_user}@#{gitlab_shell.ssh_host}:#{gitlab_shell.ssh_port}/"
15
      else
16
        "#{gitlab_shell.ssh_user}@#{gitlab_shell.ssh_host}:"
17 18 19 20 21 22 23 24 25 26 27 28
      end
    end

    def build_gitlab_url
      if gitlab_on_non_standard_port?
        custom_port = ":#{gitlab.port}"
      else
        custom_port = nil
      end
      [ gitlab.protocol,
        "://",
        gitlab.host,
29 30
        custom_port,
        gitlab.relative_url_root
31 32
      ].join('')
    end
33 34
  end
end
35 36 37 38


# Default settings
Settings['ldap'] ||= Settingslogic.new({})
39
Settings.ldap['enabled'] = false if Settings.ldap['enabled'].nil?
40 41

Settings['omniauth'] ||= Settingslogic.new({})
42
Settings.omniauth['enabled']      = false if Settings.omniauth['enabled'].nil?
43 44
Settings.omniauth['providers']  ||= []

45 46
Settings['issues_tracker']  ||= {}

47 48 49
#
# GitLab
#
50
Settings['gitlab'] ||= Settingslogic.new({})
51 52
Settings.gitlab['default_projects_limit'] ||=  10
Settings.gitlab['host']       ||= 'localhost'
53
Settings.gitlab['https']        = false if Settings.gitlab['https'].nil?
54
Settings.gitlab['port']       ||= Settings.gitlab.https ? 443 : 80
55
Settings.gitlab['relative_url_root'] ||= ENV['RAILS_RELATIVE_URL_ROOT'] || ''
56
Settings.gitlab['protocol']   ||= Settings.gitlab.https ? "https" : "http"
57
Settings.gitlab['email_from'] ||= "gitlab@#{Settings.gitlab.host}"
58
Settings.gitlab['support_email']  ||= Settings.gitlab.email_from
59
Settings.gitlab['url']        ||= Settings.send(:build_gitlab_url)
60
Settings.gitlab['user']       ||= 'git'
61
Settings.gitlab['user_home']  ||= Etc.getpwnam(Settings.gitlab['user']).dir
Marin Jankovski's avatar
Marin Jankovski committed
62
Settings.gitlab['signup_enabled'] ||= false
63
Settings.gitlab['username_changing_enabled'] = true if Settings.gitlab['username_changing_enabled'].nil?
64 65 66 67
Settings.gitlab['default_projects_features'] ||= {}
Settings.gitlab.default_projects_features['issues']         = true if Settings.gitlab.default_projects_features['issues'].nil?
Settings.gitlab.default_projects_features['merge_requests'] = true if Settings.gitlab.default_projects_features['merge_requests'].nil?
Settings.gitlab.default_projects_features['wiki']           = true if Settings.gitlab.default_projects_features['wiki'].nil?
68 69
Settings.gitlab.default_projects_features['wall']           = false if Settings.gitlab.default_projects_features['wall'].nil?
Settings.gitlab.default_projects_features['snippets']       = false if Settings.gitlab.default_projects_features['snippets'].nil?
70

71 72 73
#
# Gravatar
#
74
Settings['gravatar'] ||= Settingslogic.new({})
75
Settings.gravatar['enabled']      = true if Settings.gravatar['enabled'].nil?
76 77
Settings.gravatar['plain_url']  ||= 'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
Settings.gravatar['ssl_url']    ||= 'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
78

79 80 81 82
#
# GitLab Shell
#
Settings['gitlab_shell'] ||= Settingslogic.new({})
83
Settings.gitlab_shell['hooks_path']   ||= Settings.gitlab['user_home'] + '/gitlab-shell/hooks/'
84 85
Settings.gitlab_shell['receive_pack']   = true if Settings.gitlab_shell['receive_pack'].nil?
Settings.gitlab_shell['upload_pack']    = true if Settings.gitlab_shell['upload_pack'].nil?
86
Settings.gitlab_shell['repos_path']   ||= Settings.gitlab['user_home'] + '/repositories/'
87 88 89 90 91
Settings.gitlab_shell['ssh_host']     ||= (Settings.gitlab.host || 'localhost')
Settings.gitlab_shell['ssh_port']     ||= 22
Settings.gitlab_shell['ssh_user']     ||= Settings.gitlab.user
Settings.gitlab_shell['owner_group']  ||= Settings.gitlab.user
Settings.gitlab_shell['ssh_path_prefix'] ||= Settings.send(:build_gitlab_shell_ssh_path_prefix)
92

93 94 95
#
# Backup
#
96
Settings['backup'] ||= Settingslogic.new({})
97 98
Settings.backup['keep_time']  ||= 0
Settings.backup['path']         = File.expand_path(Settings.backup['path'] || "tmp/backups/", Rails.root)
99

100 101 102
#
# Git
#
103
Settings['git'] ||= Settingslogic.new({})
104 105
Settings.git['max_size']  ||= 5242880 # 5.megabytes
Settings.git['bin_path']  ||= '/usr/bin/git'
106
Settings.git['timeout']   ||= 10
107

108
Settings['satellites'] ||= Settingslogic.new({})
Riyad Preukschas's avatar
Riyad Preukschas committed
109
Settings.satellites['path'] = File.expand_path(Settings.satellites['path'] || "tmp/repo_satellites/", Rails.root)
110 111 112 113 114

#
# Extra customization
#
Settings['extra'] ||= Settingslogic.new({})