Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #17 from OverStyleFR/main
Browse files Browse the repository at this point in the history
Update | 'README.md' Improve tutorial guide and add French language version.
  • Loading branch information
Lakr233 authored Oct 2, 2024
2 parents fde0da3 + f79eda4 commit 7e31f7f
Show file tree
Hide file tree
Showing 2 changed files with 275 additions and 37 deletions.
157 changes: 120 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,155 @@
<div align="center">

# GitLab License Generator

This project aims to generate a GitLab License for development purpose. If you encounter any problem, please solve them yourself.
<p align="center">
<a href="./README.md">English</a> |
<a href="./README_FR.md">Français</a>
</p>

</div>

## Description

**GitLab License Generator** This project generates a GitLab license for **development purposes**. If you encounter any problems, please troubleshoot them on your own.

Last tested on GitLab v17.4.1-ee .
Last tested on GitLab v17.4.1-ee.

## Principles

**src/generator.keys.rb**
### **src/generator.keys.rb**

The GitLab uses public/private key pair to encrypt the license. The public key is shipped with the GitLab distro and the private key is kept privately. The license it self is just a json dictionary. Since GitLab made their code open source, we can easily generate a license by our own.
GitLab uses a public/private key pair to encrypt its license. The public key is shipped with the GitLab distribution, while the private key is kept secure. The license itself is simply a JSON dictionary. Since GitLab has made its code open-source, we can easily generate our own license.

**src/generator.license.rb**
### **src/generator.license.rb**

The `lib` folder is extracted from GitLab's source. It is used for building and validating the license. Script `src/generator.license.rb` will load it.
The `lib` folder is extracted from GitLab's source code. It is used to build and validate the license. The script `src/generator.license.rb` loads this functionality.

**src/scan.features.rb**
### **src/scan.features.rb**

The features is extracted from a object full of constant. The most powerful plan for a license is ultimate, but features like geo mirror is not included in any type of the plan. So here by we add them manually.
Features are extracted from an object filled with constants. The most comprehensive plan for a license is **Ultimate**, but features like Geo Mirroring are not included in any standard plan. Therefore, we manually add these features.

## Usage

Follow the procedure below to generate and install a license for your development use.
### Prerequisites

### Get License
Before starting, ensure your environment is properly configured.

**GitHub Action**
#### 1. Install Ruby and gem
To run this project, you need **Ruby** and the **gem** package manager.

Navigate to GitHub Action to download an artifact.
- **On Linux (Ubuntu/Debian)**:
```bash
sudo apt update
sudo apt install ruby-full
```

**make.sh**
- **On macOS** (via Homebrew):
```bash
brew install ruby
```

This script is only tested on macOS. To build on Linux or other platform, you need to setup ruby with gem.
#### 2. Install Bundler and necessary gems
After installing Ruby, you need to install **Bundler** to manage Ruby dependencies.

### Install Test Key
```bash
gem install bundler
```

#### 3. Install the `gitlab-license` gem
The project requires the `gitlab-license` gem, which will be automatically downloaded and used by the script.

You will need to replace the public key shipped within GitLab distro. It is located at `/opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub` most of the time.
```bash
gem install gitlab-license
```

If you are using Docker, there is a easy way to do this.
### Steps to Generate the GitLab License

```yml
image: "gitlab/gitlab-ee:latest"
# ...
volumes:
- "public.key:/opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub"
#### 1. Clone the project repository
Clone this project to your local machine.

```bash
git clone https://github.com/Lakr233/GitLab-License-Generator.git
cd GitLab-License-Generator
```

#### 2. Run the `make.sh` script
Once all the prerequisites are met, run the script:

```bash
./make.sh
```

### Install License
The script will perform the following actions:
- Download and extract the `gitlab-license` gem.
- Copy and modify the required files.
- Clone the GitLab source code from GitLab.com.
- Generate a public/private key pair.
- Generate a GitLab license.

#### 3. Replace the public key in GitLab
The script generates a public key located in `build/public.key`. You need to replace GitLab’s existing public key with this newly generated one to ensure the license is accepted.

- **If GitLab is installed on your server**:
```bash
sudo cp ./build/public.key /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
```

- **If GitLab is installed via Docker**:
Modify your `docker-compose.yml` file to mount the new public key inside the container:

```yaml
volumes:
- "./build/public.key:/opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub"
```
Then restart the container:
```bash
docker-compose down
docker-compose up -d
```

#### 4. Install the license in GitLab
Once the public key is replaced, log in to GitLab’s admin interface to install the generated license.

1. Log in to GitLab as an administrator.
2. Navigate to the **Admin Area** from the upper-right corner.
3. Go to **Settings > General** and upload the generated license file (`build/result.gitlab-license`).
4. Check the **Terms of Service** checkbox and click **Add License**.

If necessary, you can directly access the license upload page via:
```
<YourGitLabURL>/admin/license/new
```

See [GitLab Document](https://archives.docs.gitlab.com/16.3/ee/administration/license_file.html). Follow are part of the document.
#### 5. Disable Service Ping (optional)
If you want to disable GitLab’s usage data collection (Service Ping), modify GitLab’s configuration file:

- Sign in to GitLab as an administrator.
- On the left sidebar, expand the top-most chevron.
- Select Admin Area.
- Select Settings > General.
- or entering the key.
- Select the Terms of Service checkbox.
- Select Add license.
- Open the configuration file:
```bash
sudo nano /etc/gitlab/gitlab.rb
```

> In GitLab 14.7.x to 14.9.x, you can add the license file with the UI. In GitLab 14.1.x to 14.7, if you have already activated your subscription with an activation code, you cannot access Add License from the Admin Area. You must access Add License directly from the URL, <YourGitLabURL>/admin/license/new.
- Add the following line:
```bash
gitlab_rails['usage_ping_enabled'] = false
```

### Disable Service Ping
- Reconfigure and restart GitLab:
```bash
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
```

> Service Ping is a GitLab process that collects and sends a weekly payload to GitLab. The payload provides important high-level data that helps our product, support, and sales teams understand how GitLab is used.
### Troubleshooting

See [GitLab Document](https://docs.gitlab.com/ee/development/internal_analytics/service_ping) for details.
- **HTTP 502 Error**:
If you encounter this error, wait for GitLab to finish starting up (it may take some time).

## LICENSE

This project is licensed under the WTFPL License.
This project is licensed under the **WTFPL License**.

Copyrigth (c) 2023, Tim Cook, All Rights Not Reserved.
Copyright (c) 2023, Tim Cook, All Rights Not Reserved.
155 changes: 155 additions & 0 deletions README_FR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
<div align="center">

# GitLab License Generator

<p align="center">
<a href="./README.md">English</a> |
<a href="./README_FR.md">Français</a>
</p>

</div>

## Description

**GitLab License Generator** Ce projet permet de générer une licence GitLab à des **fins de développement**. Si vous rencontrez des problèmes, merci de les résoudre par vous-même.

Dernier test effectué sur GitLab v17.4.1-ee.

## Principes

### **src/generator.keys.rb**

GitLab utilise une paire de clés publique/privée pour chiffrer sa licence. La clé publique est fournie avec la distribution GitLab, tandis que la clé privée est conservée de manière sécurisée. La licence est simplement un dictionnaire JSON. Comme GitLab a rendu son code open-source, il est facile de générer sa propre licence.

### **src/generator.license.rb**

Le dossier `lib` est extrait du code source de GitLab. Il est utilisé pour générer et valider la licence. Le script `src/generator.license.rb` le charge pour effectuer cette tâche.

### **src/scan.features.rb**

Les fonctionnalités sont extraites d'un objet contenant des constantes. Le plan le plus complet est **Ultimate**, mais des fonctionnalités comme le Geo Mirroring ne sont incluses dans aucun plan standard. Nous les ajoutons donc manuellement.

## Utilisation

### Prérequis

Avant de commencer, assurez-vous que votre environnement est correctement configuré.

#### 1. Installer Ruby et gem
Pour exécuter ce projet, vous devez installer **Ruby** et le gestionnaire de paquets **gem**.

- **Sous Linux (Ubuntu/Debian)** :
```bash
sudo apt update
sudo apt install ruby-full
```

- **Sous macOS** (via Homebrew) :
```bash
brew install ruby
```

#### 2. Installer Bundler et les gems nécessaires
Une fois Ruby installé, vous devez installer **Bundler** pour gérer les dépendances Ruby.

```bash
gem install bundler
```

#### 3. Installer le gem `gitlab-license`
Le projet nécessite le gem `gitlab-license`, qui sera automatiquement téléchargé et utilisé par le script.

```bash
gem install gitlab-license
```

### Étapes pour générer la licence GitLab

#### 1. Cloner le dépôt du projet
Clonez ce projet sur votre machine locale.

```bash
git clone https://github.com/Lakr233/GitLab-License-Generator.git
cd GitLab-License-Generator
```

#### 2. Exécuter le script `make.sh`
Une fois que tous les prérequis sont en place, exécutez le script :

```bash
./make.sh
```

Le script effectuera les actions suivantes :
- Téléchargement et extraction du gem `gitlab-license`.
- Copie et modification des fichiers nécessaires.
- Clonage du code source GitLab depuis GitLab.com.
- Génération d’une paire de clés publique/privée.
- Génération d’une licence GitLab.

#### 3. Remplacer la clé publique dans GitLab
Le script génère une clé publique dans le fichier `build/public.key`. Vous devez remplacer la clé publique utilisée par GitLab avec celle générée pour que la licence soit acceptée.

- **Si GitLab est installé sur votre serveur** :
```bash
sudo cp ./build/public.key /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
```

- **Si GitLab est installé via Docker** :
Modifiez votre fichier `docker-compose.yml` pour monter la nouvelle clé publique dans le conteneur :

```yaml
volumes:
- "./build/public.key:/opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub"
```
Puis redémarrez le conteneur :
```bash
docker-compose down
docker-compose up -d
```

#### 4. Installer la licence dans GitLab
Une fois la clé publique remplacée, connectez-vous à l'interface d'administration de GitLab pour installer la licence générée.

1. Connectez-vous à GitLab en tant qu’administrateur.
2. Accédez à **Admin Area** via le coin supérieur droit.
3. Allez dans **Settings > General** et téléchargez le fichier de licence généré (`build/result.gitlab-license`).
4. Cochez la case **Terms of Service** et cliquez sur **Add License**.

Si nécessaire, accédez directement à la page de téléchargement de la licence via :
```
<YourGitLabURL>/admin/license/new
```

#### 5. Désactiver Service Ping (optionnel)
Si vous souhaitez désactiver la collecte de données d'utilisation par GitLab (Service Ping), modifiez le fichier de configuration GitLab :

- Ouvrez le fichier de configuration :
```bash
sudo nano /etc/gitlab/gitlab.rb
```

- Ajoutez la ligne suivante :
```bash
gitlab_rails['usage_ping_enabled'] = false
```

- Reconfigurez et redémarrez GitLab :
```bash
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
```

### Résolution des problèmes

- **Erreur HTTP 502** :
Si vous obtenez cette erreur, patientez simplement, car GitLab peut mettre du temps à démarrer.

## LICENCE

Ce projet est sous licence **WTFPL License**.

Copyright (c) 2023, Tim Cook, All Rights Not Reserved.

0 comments on commit 7e31f7f

Please sign in to comment.