Gitlab EE安装与破解
Gitlab EE安装与破解
安装
设置卷的路径
在设置其他所有内容之前,配置指向配置、日志和数据文件所在的目录的新环境变量。确保目录存在并授予适当的权限。$GITLAB_HOME
linux用户设置为/srv/gitlab
1 | export GITLAB_HOME=/srv/gitlab |
macos,使用用户目录,设置为$HOME/gitlab
1 | export GITLAB_HOME=$HOME/gitlab |
主机路径 | 容器路径 | 用途 |
---|---|---|
$GITLAB_HOME/data |
/var/opt/gitlab | 应用数据存储. |
$GITLAB_HOME/logs |
/var/log/gitlab | 日志存储. |
$GITLAB_HOME/config |
/etc/gitlab | Gitlab配置文件存储 |
使用Docker 引擎安装GitLab
1 | sudo docker run --detach \ |
如果你使用的是 SELinux,请使用以下命令替换:
1 | sudo docker run --detach \ |
使用 sudo docker logs -f gitlab
来跟踪启动进程,这个过程需要较长时间.
访问对应域名:source.52dzd.com
,使用root
用户名登录,密码使用以下命令来查看
1 | sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password |
密码文件会在24小时后自动删除,请注意修改或者保存初始密码
使用 Docker Compose安装GitLab
安装 Docker Compose
新建文件:docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16web:
image: 'gitlab/gitlab-ee:latest'
restart: always
hostname: 'source.52dzd.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://source.52dzd.com'
# 添加任何其它的gitlab.rb配置这里,每个配置单独一行
ports:
- '80:80'
- '443:443'
- '22:22'
volumes:
- '$GITLAB_HOME/config:/etc/gitlab'
- '$GITLAB_HOME/logs:/var/log/gitlab'
- '$GITLAB_HOME/data:/var/opt/gitlab'在新建文件docker-compose.yml的目录里执行
1
docker-compose up -d
破解
- 进入docker容器
1 | sudo docker exec -it gitlab /bin/bash |
创建文件
vi license.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85require "openssl"
require "gitlab/license"
key_pair = OpenSSL::PKey::RSA.generate(2048)
File.open("license_key", "w") { |f| f.write(key_pair.to_pem) }
public_key = key_pair.public_key
File.open("license_key.pub", "w") { |f| f.write(public_key.to_pem) }
private_key = OpenSSL::PKey::RSA.new File.read("license_key")
Gitlab::License.encryption_key = private_key
license = Gitlab::License.new
license.licensee = {
"Name" => "none",
"Company" => "none",
"Email" => "example@test.com",
}
license.starts_at = Date.new(2020, 1, 1) # 开始时间
license.expires_at = Date.new(2050, 1, 1) # 结束时间
license.notify_admins_at = Date.new(2049, 12, 1)
license.notify_users_at = Date.new(2049, 12, 1)
license.block_changes_at = Date.new(2050, 1, 1)
license.restrictions = {
active_user_count: 10000,
}
puts "License:"
puts license
data = license.export
puts "Exported license:"
puts data
File.open("GitLabBV.gitlab-license", "w") { |f| f.write(data) }
public_key = OpenSSL::PKey::RSA.new File.read("license_key.pub")
Gitlab::License.encryption_key = public_key
data = File.read("GitLabBV.gitlab-license")
$license = Gitlab::License.import(data)
puts "Imported license:"
puts $license
unless $license
raise "The license is invalid."
end
if $license.restricted?(:active_user_count)
active_user_count = 10000
if active_user_count > $license.restrictions[:active_user_count]
raise "The active user count exceeds the allowed amount!"
end
end
if $license.notify_admins?
puts "The license is due to expire on #{$license.expires_at}."
end
if $license.notify_users?
puts "The license is due to expire on #{$license.expires_at}."
end
module Gitlab
class GitAccess
def check(cmd, changes = nil)
if $license.block_changes?
return build_status_object(false, "License expired")
end
end
end
end
puts "This instance of GitLab Enterprise Edition is licensed to:"
$license.licensee.each do |key, value|
puts "#{key}: #{value}"
end
if $license.expired?
puts "The license expired on #{$license.expires_at}"
elsif $license.will_expire?
puts "The license will expire on #{$license.expires_at}"
else
puts "The license will never expire."
end生成证书
1
ruby license.rb
生成 GitLabBV.gitlab-license license_key license_key.pub 这三个文件。
替换默认公钥
1
cp -f license_key.pub /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub
升级到ULTIMATE版本
修改文件 /opt/gitlab/embedded/service/gitlab-rails/ee/app/models/license.rb
替换对应
restricted_attr(:plan).presence || STARTER_PLAN
为restricted_attr(:plan).presence || ULTIMATE_PLAN
大约位于367行
重新配置gitlab
1
2gitlab-ctl reconfigure
gitlab-ctl restart导入许可证
登录gitlab后台,管理中心->许可证 (/admin/license),导入 GitLabBV.gitlab-license
可以选择cat GitLabBV.gitlab-license
打印出文件内容后,把密钥复制后使用密钥文本,而不是上传文件
参考文档
许可证生成
Gitlab EE安装与破解