本文基于 Gitlab 官方套件生成 Gitlab EE 许可证。依赖于 Ruby 环境,请安装好 Ruby 环境后再执行脚本。

  1. Gitlab 官方证书套件 , Copy 官方套件 README.md 中 Usage 里的脚本内容,保存为 gitlab-ee-license.rb 脚本文件。
  2. 命令行输入 gem install gitlab-license 安装模块依赖。
  3. 修改脚本文件,在第一行加入
    require 'openssl'
    require 'gitlab/license'
    
  4. 修改脚本文件,搜索 license.licensee 将以下内容修改为你的组织信息:
    license.licensee = {
      "Name"    => "Douwe Maan",
      "Company" => "GitLab B.V.",
      "Email"   => "douwe@gitlab.com"
    }
    
  5. 修改脚本文件,搜索 license.restrictions 修改以下内容:
    license.restrictions  = {
      # The maximum allowed number of active users.
      # Not required.
      # active_user_count: 10000
      plan: 'ultimate'
      # We don't currently have any other restrictions, but we might in the future.
    }
    

    active_user_count 为许可证可用人数,plan 为许可证计划类型

  6. 修改脚本文件, 将以下内容的时间修改为实际需要的时间
    license.starts_at         = Date.new(2015, 4, 24)
    # The date the license expires. 
    # Not required, to allow lifetime licenses.
    license.expires_at        = Date.new(2016, 4, 23)
    
    # The below dates are hardcoded in the license so that you can play with the
    # period after which there are "repercussions" to license expiration.
    
    # The date admins will be notified about the license's pending expiration. 
    # Not required.
    license.notify_admins_at  = Date.new(2016, 4, 19)
    
    # The date regular users will be notified about the license's pending expiration.
    # Not required.
    license.notify_users_at   = Date.new(2016, 4, 23)
    
    # The date "changes" like code pushes, issue or merge request creation 
    # or modification and project creation will be blocked.
    # Not required.
    license.block_changes_at  = Date.new(2016, 5, 7)
    
  7. 修改脚本文件,搜索 active_user_count = User.active.count 修改为 active_user_count = 1
  8. 命令行执行脚本,输出一下内容则表示生成许可证成功:
    Exported license:
    eyJkYXRhIjoiR2U1T2dYMGUzYjJNNlMyQWZOeVZ5YzJXNTdINFRSZ2xRdURM
    azFNRmYzM05LVkRuU2loRXUyUzdLZithXG5yRXdtS0lGcnN0WHVJVllMZ2cx
    WmRRUjFXY3JoQVNoeWFPMFpLOGFqdzhJU1JzM0V1ZndERTVUUllwZlJcbmF4
    OWNmQmhrdjFNR0ZESkNNVWVJLzBWR3llL0ZlcmNXZTdRcUJXV3BMYVBlTUgy
    bTVTdkk5V0J1UktRN1xuUlBjQ0lHTmZmSzdqMkVVUDJ2RFpvK0lSZXNNYkR0
    bFUwbVc5czhqZnZydENsM1p1dkQ2QjBuclVkcjVoXG5Xb1pWMnJxRnFLSGpq
    aVg5QkZOc1FoRzJGRS8rSlVvUGJZeEZnVDVkcDkzd3ViTngzOVg5WmZhb0xR
    N1VcbktSaHJtOGh3YVpBNm5VSEVTbTNDVDVDRDc0NnFsMlo3RWl6M0ZSM2Jr
    UHo2c0FycmMzejR1NWQ1bmFZTlxuTTZ6YWc4MTI2NkU2azVJL01YNjFQNUIr
    XG4iLCJrZXkiOiJnN2E4Ny9SQUJObkxWK2gyWHFSOFRrNXBEbVlMc3VaUHgy
    RmFnU0lKNU94TGV5RG9PZ3VvYkRqaFlMUXRcbjZPVHhad1RyeDJXcC9BZnNY
    ZmtMeGJxSU52bzNIVm5yTkpSY29FVzg2MithVkVlUHZhZXExNzUxYU14QVxu
    T3V6UnBNYUY4bmRsMk5RaFUyQWpJU1FYRTVFdEdZekhMYlJJbHZsbEYzUFhP
    cGFSc1lVRkcvRlNxN1pnXG44SFZzWmZwdGlqcTA4NGlFa0E5NDVrRzVSWmJO
    dkR3K2FsbWFUTWFGeCtWQmkzUHVySWpLZVF1c3VRYkRcbmtLMXl5U2VmTnYx
    UEd4UHZzSjZlOVFBNmNXaFo2OUIybVRoaHNHTEhzdXdqaG1LQTV2Z1Fjeksw
    K2VmWVxuTHErT2xKUER0U1k4d0g2NkdvVC8weGVRaXNFWDMxL2EraGNBazh1
    TlhRPT1cbiIsIml2IjoiSis0K0d5SkZsRG5paFVWVWtzSXZHUT09XG4ifQ==
    Imported license:
    #<Gitlab::License:0x00000000056e1a68>
    This instance of GitLab Enterprise Edition is licensed to:
    Name: Douwe Maan
    Company: GitLab B.V.
    Email: douwe@gitlab.com
    The license will expire on 2021-08-23
    
  9. 脚本目录下会生成三个文件,license_key、license_key.pub、GitLabBV.gitlab-license。

    license_key 为私钥,license_key.pub 为公钥,GitLabBV.gitlab-license 为 license 文件

  10. 将公钥文件覆盖替换 Gitlab 自带的公钥,目录为 /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub,然后登录 Gitlab 上传 license 文件即可