1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/gitlab_ynh.git synced 2024-09-03 18:36:35 +02:00

Merge branch 'testing' into new-permissions-system

This commit is contained in:
Kay0u 2021-01-19 01:13:42 +01:00
commit f81d841fd4
No known key found for this signature in database
GPG key ID: AAFEEB16CFA2AE2D
24 changed files with 1221 additions and 711 deletions

View file

@ -1,46 +1,50 @@
# Gitlab for Yunohost # GitLab for YunoHost
[![Integration level](https://dash.yunohost.org/integration/gitlab.svg)](https://dash.yunohost.org/appci/app/gitlab) [![Integration level](https://dash.yunohost.org/integration/gitlab.svg)](https://dash.yunohost.org/appci/app/gitlab) ![](https://ci-apps.yunohost.org/ci/badges/gitlab.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/gitlab.maintain.svg)
[![Install gitlab with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=gitlab) [![Install GitLab with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=gitlab)
> *This package allow you to install gitlab quickly and simply on a YunoHost server. *[Lire ce readme en français.](./README_fr.md)*
> *This package allow you to install GitLab quickly and simply on a YunoHost server.
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
## Overview ## Overview
GitLab is a web-based Git-repository manager providing wiki, issue-tracking and CI/CD pipeline features, using an open-source license, developed by GitLab Inc. GitLab is a web-based Git-repository manager providing wiki, issue-tracking and CI/CD pipeline features, using an open-source license, developed by GitLab Inc.
**Shipped version:** 12.4.1 **Shipped version:** 13.7.4
## Screenshots ## Screenshots
![](https://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/GitLab_running_11.0_%282018-07%29.png/300px-GitLab_running_11.0_%282018-07%29.png) ![](https://upload.wikimedia.org/wikipedia/commons/9/9a/GitLab_running_11.0_%282018-07%29.png)
## Configuration ## Configuration
How to configure this app: How to configure GitLab:
- An admin panel
- The file: `/etc/gitlab/gitlab-persistent.rb` (use `sudo gitlab-ctl reconfigure` after any modification of this file) - With the GitLab admin panel.
- By editing the configuration file `/etc/gitlab/gitlab-persistent.rb` (use `sudo gitlab-ctl reconfigure` after any modification of this file).
## Documentation ## Documentation
* Official documentation: https://docs.gitlab.com/ce/README.html * Official documentation: https://docs.gitlab.com/ce/README.html
* YunoHost documentation: https://yunohost.org/#/app_gitlab
## YunoHost specific features ## YunoHost specific features
#### Multi-users support #### Multi-users support
Yes with LDAP support. * Are LDAP and HTTP auth supported? **Yes**
* Can the app be used by multiple users? **Yes**
#### Supported architectures #### Supported architectures
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/gitlab%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/gitlab/) * x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/gitlab%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/gitlab/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/gitlab%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/gitlab/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/gitlab%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/gitlab/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/gitlab%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/gitlab/)
## Limitations ## Limitations
* Not compatible with a 32-bit architecture. * GitLab is not compatible with 32-bit architectures.
## Links ## Links
@ -51,10 +55,8 @@ Yes with LDAP support.
--- ---
Developers info ## Developers info
----------------
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/gitlab_ynh/tree/testing). Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/gitlab_ynh/tree/testing).
To try the testing branch, please proceed like that. To try the testing branch, please proceed like that.
@ -63,6 +65,3 @@ sudo yunohost app install https://github.com/YunoHost-Apps/gitlab_ynh/tree/testi
or or
sudo yunohost app upgrade gitlab -u https://github.com/YunoHost-Apps/gitlab_ynh/tree/testing --debug sudo yunohost app upgrade gitlab -u https://github.com/YunoHost-Apps/gitlab_ynh/tree/testing --debug
``` ```
**More information on the documentation page:**
https://yunohost.org/packaging_apps

67
README_fr.md Normal file
View file

@ -0,0 +1,67 @@
# GitLab pour YunoHost
[![Integration level](https://dash.yunohost.org/integration/gitlab.svg)](https://dash.yunohost.org/appci/app/gitlab) ![](https://ci-apps.yunohost.org/ci/badges/gitlab.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/gitlab.maintain.svg)
[![Installer GitLab pour YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=gitlab)
*[Read this readme in english.](./README.md)*
> *Ce package vous permet d'installer GitLab rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
## Vue d'ensemble
GitLab est un gestionnaire Web de dépôt Git fournissant des fonctionnalités de wiki, de rapports de bugs et de pipeline CI/CD. GitLab est une application open source développée par GitLab Inc.
**Version incluse :** 13.7.4
## Captures d'écran
![](https://upload.wikimedia.org/wikipedia/commons/9/9a/GitLab_running_11.0_%282018-07%29.png)
## Configuration
Comment configurer GitLab :
- Avec le panneau d'administration de GitLab.
- En éditant le fichier de configuration `/etc/gitlab/gitlab-persistent.rb` et en éxécutant la commande `sudo gitlab-ctl reconfigure` pour réactualiser la configuration.
## Documentation
* Documentation officielle : https://docs.gitlab.com/ce/README.html
* Documentation YunoHost : https://yunohost.org/#/app_gitlab_fr
## Caractéristiques spécifiques YunoHost
#### Support multi-utilisateurs
* L'authentification LDAP et HTTP est-elle prise en charge ? **Oui**
* L'application peut-elle être utilisée par plusieurs utilisateurs ? **Oui**
#### Architectures supportées
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/gitlab%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/gitlab/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/gitlab%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/gitlab/)
## Limitations
* L'application GitLab n'est pas compatible avec les architectures 32-bit.
## Liens
* Signaler un bug : https://github.com/YunoHost-Apps/gitlab_ynh/issues
* Site de l'application : https://gitlab.com
* Dépôt de l'application principale : https://gitlab.com/gitlab-org/omnibus-gitlab - https://gitlab.com/gitlab-org/gitlab-ce
* Site web YunoHost : https://yunohost.org/
---
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/gitlab_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
```
sudo yunohost app install https://github.com/YunoHost-Apps/gitlab_ynh/tree/testing --debug
or
sudo yunohost app upgrade gitlab -u https://github.com/YunoHost-Apps/gitlab_ynh/tree/testing --debug
```

View file

@ -16,12 +16,16 @@
setup_public=1 setup_public=1
upgrade=1 upgrade=1
upgrade=1 from_commit=2cc84310aeff7055342b445c1aee01d4183d5ae2 upgrade=1 from_commit=2cc84310aeff7055342b445c1aee01d4183d5ae2
upgrade=1 from_commit=7c352aff3fb13fc425d76716477c28db5d54ac99
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
port_already_use=1 (8080) port_already_use=1 (8080)
change_url=1 change_url=1
;;; Levels
Level 5=auto
;;; Options ;;; Options
Email= Email=
Notification=none Notification=none
;;; Upgrade options
; commit=2cc84310aeff7055342b445c1aee01d4183d5ae2
name=11.6.3
; commit=7c352aff3fb13fc425d76716477c28db5d54ac99
name=12.9.2

View file

@ -1,4 +1,4 @@
SOURCE_URL=https://packages.gitlab.com/gitlab/raspberry-pi2/packages/raspbian/stretch/gitlab-ce___VERSION__-ce.0_armhf.deb/download.deb SOURCE_URL=https://packages.gitlab.com/gitlab/raspberry-pi2/packages/raspbian/__DEBIAN_VERSION__/gitlab-ce___VERSION__-ce.0_armhf.deb/download.deb
SOURCE_SUM=__SHA256_SUM__ SOURCE_SUM=__SHA256_SUM__
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FILENAME=__SOURCE_FILENAME__ SOURCE_FILENAME=__SOURCE_FILENAME__

File diff suppressed because it is too large Load diff

View file

@ -1,13 +1,27 @@
location __PATH__/ { location __PATH__/ {
proxy_pass http://localhost:__PORT__; # Adapted from https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/lib/support/nginx/gitlab-ssl
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size __CLIENT_MAX_BODY_SIZE__; client_max_body_size __CLIENT_MAX_BODY_SIZE__;
gzip off;
## https://github.com/gitlabhq/gitlabhq/issues/694
## Some requests take more than 30 seconds.
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
proxy_http_version 1.1;
proxy_pass http://localhost:__PORT__;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
proxy_set_header Accept-Encoding "";
} }

View file

@ -1,4 +1,4 @@
SOURCE_URL=https://packages.gitlab.com/gitlab/gitlab-ce/packages/debian/stretch/gitlab-ce___VERSION__-ce.0_amd64.deb/download.deb SOURCE_URL=https://packages.gitlab.com/gitlab/gitlab-ce/packages/debian/__DEBIAN_VERSION__/gitlab-ce___VERSION__-ce.0_amd64.deb/download.deb
SOURCE_SUM=__SHA256_SUM__ SOURCE_SUM=__SHA256_SUM__
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FILENAME=__SOURCE_FILENAME__ SOURCE_FILENAME=__SOURCE_FILENAME__

View file

@ -35,85 +35,6 @@
"default": true "default": true
} }
] ]
},
{
"name": "Backup strategy",
"id": "backup_strategy",
"help": "WARNING: If you disable one of these backup, it will not be restored in case of error, use this feature at your own risk",
"options": [
{
"name": "backup_db",
"ask": {
"en": "Should gitlab backup the database ?"
},
"help": "https://docs.gitlab.com/ce/raketasks/backup_restore.html#excluding-specific-directories-from-the-backup",
"type": "boolean",
"default": true
},
{
"name": "backup_uploads",
"ask": {
"en": "Should gitlab backup attachments ?"
},
"help": "https://docs.gitlab.com/ce/raketasks/backup_restore.html#excluding-specific-directories-from-the-backup",
"type": "boolean",
"default": true
},
{
"name": "backup_repositories",
"ask": {
"en": "Should gitlab backup git repositories data ?"
},
"help": "https://docs.gitlab.com/ce/raketasks/backup_restore.html#excluding-specific-directories-from-the-backup",
"type": "boolean",
"default": true
},
{
"name": "backup_builds",
"ask": {
"en": "Should gitlab backup CI job output logs ?"
},
"help": "https://docs.gitlab.com/ce/raketasks/backup_restore.html#excluding-specific-directories-from-the-backup",
"type": "boolean",
"default": true
},
{
"name": "backup_artifacts",
"ask": {
"en": "Should gitlab backup CI job artifacts ?"
},
"help": "https://docs.gitlab.com/ce/raketasks/backup_restore.html#excluding-specific-directories-from-the-backup",
"type": "boolean",
"default": true
},
{
"name": "backup_lfs",
"ask": {
"en": "Should gitlab backup LFS objects ?"
},
"help": "https://docs.gitlab.com/ce/raketasks/backup_restore.html#excluding-specific-directories-from-the-backup",
"type": "boolean",
"default": true
},
{
"name": "backup_registry",
"ask": {
"en": "Should gitlab backup container registry images ?"
},
"help": "https://docs.gitlab.com/ce/raketasks/backup_restore.html#excluding-specific-directories-from-the-backup",
"type": "boolean",
"default": true
},
{
"name": "backup_pages",
"ask": {
"en": "Should gitlab backup pages content ?"
},
"help": "https://docs.gitlab.com/ce/raketasks/backup_restore.html#excluding-specific-directories-from-the-backup",
"type": "boolean",
"default": true
}
]
} }
] ]
} }

View file

@ -1,11 +1,11 @@
{ {
"name": "Gitlab", "name": "GitLab",
"id": "gitlab", "id": "gitlab",
"packaging_format": 1, "packaging_format": 1,
"version": "12.4.1~ynh1", "version": "13.7.4~ynh1",
"description": { "description": {
"en": "GitLab is a Git-repository manager.", "en": "Git-repository manager.",
"fr": "GitLab est un gestionnaire de dépôts Git." "fr": "Gestionnaire de dépôts Git."
}, },
"url": "https://gitlab.com", "url": "https://gitlab.com",
"license": "MIT", "license": "MIT",
@ -14,7 +14,7 @@
"email": "pierre@kayou.io" "email": "pierre@kayou.io"
}, },
"requirements": { "requirements": {
"yunohost": ">= 3.7.0" "yunohost": ">= 4.1.5"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [
@ -26,8 +26,8 @@
"name": "domain", "name": "domain",
"type": "domain", "type": "domain",
"ask": { "ask": {
"en": "Choose a domain name for gitlab", "en": "Choose a domain name for GitLab",
"fr": "Choisissez un nom de domaine pour gitlab" "fr": "Choisissez un nom de domaine pour GitLab"
}, },
"example": "example.com" "example": "example.com"
}, },
@ -35,11 +35,11 @@
"name": "path", "name": "path",
"type": "path", "type": "path",
"ask": { "ask": {
"en": "Choose a path for gitlab", "en": "Choose a path for GitLab",
"fr": "Choisissez un chemin pour gitlab" "fr": "Choisissez un chemin pour GitLab"
}, },
"example": "/", "example": "/gitlab",
"default": "/" "default": "/gitlab"
}, },
{ {
"name": "admin", "name": "admin",
@ -63,8 +63,8 @@
"name": "use_web_account", "name": "use_web_account",
"type": "boolean", "type": "boolean",
"ask": { "ask": {
"en": "Allow account creation via the gitlab web interface?", "en": "Authorize account creation from GitLab web interface",
"fr": "Autoriser la création de compte via l'interface web de gitlab ?" "fr": "Autoriser la création de compte depuis l'interface web de GitLab ?"
}, },
"default": false "default": false
} }

View file

@ -4,7 +4,7 @@
# SET ALL CONSTANTS # SET ALL CONSTANTS
#================================================= #=================================================
pkg_dependencies="openssh-server bc" pkg_dependencies="openssh-server"
#================================================= #=================================================
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
@ -101,74 +101,3 @@ ynh_is_main_device_a_sd_card () {
return 1 return 1
fi fi
} }
# Check the amount of available RAM
#
# usage: ynh_check_ram [--required=RAM required in Mb] [--no_swap|--only_swap] [--free_ram]
# | arg: -r, --required= - Amount of RAM required in Mb. The helper will return 0 is there's enough RAM, or 1 otherwise.
# If --required isn't set, the helper will print the amount of RAM, in Mb.
# | arg: -s, --no_swap - Ignore swap
# | arg: -o, --only_swap - Ignore real RAM, consider only swap.
# | arg: -f, --free_ram - Count only free RAM, not the total amount of RAM available.
ynh_check_ram () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [r]=required= [s]=no_swap [o]=only_swap [f]=free_ram )
local required
local no_swap
local only_swap
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
required=${required:-}
no_swap=${no_swap:-0}
only_swap=${only_swap:-0}
local total_ram=$(vmstat --stats --unit M | grep "total memory" | awk '{print $1}')
local total_swap=$(vmstat --stats --unit M | grep "total swap" | awk '{print $1}')
local total_ram_swap=$(( total_ram + total_swap ))
local free_ram=$(vmstat --stats --unit M | grep "free memory" | awk '{print $1}')
local free_swap=$(vmstat --stats --unit M | grep "free swap" | awk '{print $1}')
local free_ram_swap=$(( free_ram + free_swap ))
# Use the total amount of ram
local ram=$total_ram_swap
if [ $free_ram -eq 1 ]
then
# Use the total amount of free ram
ram=$free_ram_swap
if [ $no_swap -eq 1 ]
then
# Use only the amount of free ram
ram=$free_ram
elif [ $only_swap -eq 1 ]
then
# Use only the amount of free swap
ram=$free_swap
fi
else
if [ $no_swap -eq 1 ]
then
# Use only the amount of free ram
ram=$total_ram
elif [ $only_swap -eq 1 ]
then
# Use only the amount of free swap
ram=$total_swap
fi
fi
if [ -n "$required" ]
then
# Return 1 if the amount of ram isn't enough.
if [ $ram -lt $required ]
then
return 1
else
return 0
fi
# If no RAM is required, return the amount of available ram.
else
echo $ram
fi
}

View file

@ -24,83 +24,38 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
config_path=$(ynh_app_setting_get --app=$app --key=config_path) config_path=$(ynh_app_setting_get --app=$app --key=config_path)
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
backup_db=$(ynh_app_setting_get --app="$app" --key=backup_db)
backup_uploads=$(ynh_app_setting_get --app="$app" --key=backup_uploads)
backup_repositories=$(ynh_app_setting_get --app="$app" --key=backup_repositories)
backup_builds=$(ynh_app_setting_get --app="$app" --key=backup_builds)
backup_artifacts=$(ynh_app_setting_get --app="$app" --key=backup_artifacts)
backup_lfs=$(ynh_app_setting_get --app="$app" --key=backup_lfs)
backup_registry=$(ynh_app_setting_get --app="$app" --key=backup_registry)
backup_pages=$(ynh_app_setting_get --app="$app" --key=backup_pages)
#================================================= #=================================================
# STANDARD BACKUP STEPS # DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Backing up nginx web server configuration..." --weight=1
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# BACKUP GITLAB DATABASE # BACKUP GITLAB DATABASE
#================================================= #=================================================
ynh_script_progression --message="Backuping of Gitlab..." --weight=9
to_skip="" # Use gitlab-backup to backup
if [ $backup_db -eq 0 ]; then
to_skip="db,"$to_skip
fi
if [ $backup_uploads -eq 0 ]; then
to_skip="uploads,"$to_skip
fi
if [ $backup_repositories -eq 0 ]; then
to_skip="repositories,"$to_skip
fi
if [ $backup_builds -eq 0 ]; then
to_skip="builds,"$to_skip
fi
if [ $backup_artifacts -eq 0 ]; then
to_skip="artifacts,"$to_skip
fi
if [ $backup_lfs -eq 0 ]; then
to_skip="lfs,"$to_skip
fi
if [ $backup_registry -eq 0 ]; then
to_skip="registry,"$to_skip
fi
if [ $backup_pages -eq 0 ]; then
to_skip="pages,"$to_skip
fi
# Use gitlab-rake to backup
# For the complete doc: https://docs.gitlab.com/ce/raketasks/backup_restore.html # For the complete doc: https://docs.gitlab.com/ce/raketasks/backup_restore.html
# For the filename: https://docs.gitlab.com/ce/raketasks/backup_restore.html#backup-filename # For the filename: https://docs.gitlab.com/ce/raketasks/backup_restore.html#backup-filename
# For the backup strategy: https://docs.gitlab.com/ce/raketasks/backup_restore.html#excluding-specific-directories-from-the-backup gitlab-backup create BACKUP=last
gitlab-backup create BACKUP=last SKIP=$to_skip
ynh_backup --src_path="/var/opt/$app/backups/last_gitlab_backup.tar" ynh_backup --src_path="/var/opt/$app/backups/last_gitlab_backup.tar"
#================================================= #=================================================
# BACKUP CONF FILES # BACKUP CONF FILES
#================================================= #=================================================
ynh_script_progression --message="Backuping configuration files of Gitlab..." --weight=1
ynh_backup --src_path="$config_path/gitlab-secrets.json" ynh_backup --src_path="$config_path/gitlab-secrets.json"
ynh_backup --src_path="$config_path/gitlab.rb" ynh_backup --src_path="$config_path/gitlab.rb"
@ -110,4 +65,4 @@ ynh_backup --src_path="$config_path/gitlab-persistent.rb"
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -27,12 +27,13 @@ app=$YNH_APP_INSTANCE_NAME
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config" # Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
config_path=$(ynh_app_setting_get --app=$app --key=config_path) config_path=$(ynh_app_setting_get --app=$app --key=config_path)
port=$(ynh_app_setting_get --app="$app" --key=web_port) port=$(ynh_app_setting_get --app="$app" --key=web_port)
portUnicorn=$(ynh_app_setting_get --app="$app" --key=unicorn_port) portPuma=$(ynh_app_setting_get --app="$app" --key=puma_port)
portSidekiq=$(ynh_app_setting_get --app="$app" --key=sidekiq_port) portSidekiq=$(ynh_app_setting_get --app="$app" --key=sidekiq_port)
unicorn_worker_processes=$(ynh_app_setting_get --app="$app" --key=unicorn_worker_processes) puma_worker_processes=$(ynh_app_setting_get --app="$app" --key=puma_worker_processes)
puma_min_threads=$(ynh_app_setting_get --app="$app" --key=puma_min_threads)
puma_max_threads=$(ynh_app_setting_get --app="$app" --key=puma_max_threads)
client_max_body_size=$(ynh_app_setting_get --app="$app" --key=client_max_body_size) client_max_body_size=$(ynh_app_setting_get --app="$app" --key=client_max_body_size)
#================================================= #=================================================
@ -54,7 +55,7 @@ fi
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
ynh_script_progression --message="Updating nginx web server configuration..." --weight=1 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
@ -63,7 +64,7 @@ if [ $change_path -eq 1 ]; then
#doc in: https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab #doc in: https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
gitlab-ctl stop unicorn gitlab-ctl stop puma
gitlab-ctl stop sidekiq gitlab-ctl stop sidekiq
# Make a backup of the original nginx config file if modified # Make a backup of the original nginx config file if modified
@ -91,7 +92,7 @@ fi
#================================================= #=================================================
# CONFIGURE GITLAB # CONFIGURE GITLAB
#================================================= #=================================================
ynh_script_progression --message="Configure gitlab..." --weight=28 ynh_script_progression --message="Configure GitLab..." --weight=28
ynh_backup_if_checksum_is_different --file="$config_path/gitlab.rb" ynh_backup_if_checksum_is_different --file="$config_path/gitlab.rb"
@ -105,8 +106,10 @@ path_url="$new_path"
ynh_replace_string --match_string="__GENERATED_EXTERNAL_URL__" --replace_string="https://$domain${path_url%/}" --target_file="$config_path/gitlab.rb" ynh_replace_string --match_string="__GENERATED_EXTERNAL_URL__" --replace_string="https://$domain${path_url%/}" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_path/gitlab.rb" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__UNICORN_PORT__" --replace_string="$portUnicorn" --target_file="$config_path/gitlab.rb" ynh_replace_string --match_string="__PUMA_PORT__" --replace_string="$portPuma" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__UNICORN_WORKER_PROCESSES__" --replace_string="$unicorn_worker_processes" --target_file="$config_path/gitlab.rb" ynh_replace_string --match_string="__PUMA_WORKER_PROCESSES__" --replace_string="$puma_worker_processes" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__PUMA_MIN_THREADS__" --replace_string="$puma_min_threads" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__PUMA_MAX_THREADS__" --replace_string="$puma_max_threads" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__CLIENT_MAX_BODY_SIZE__" --replace_string="$client_max_body_size" --target_file="$config_path/gitlab.rb" ynh_replace_string --match_string="__CLIENT_MAX_BODY_SIZE__" --replace_string="$client_max_body_size" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__SSH_PORT__" --replace_string="$ssh_port" --target_file="$config_path/gitlab.rb" ynh_replace_string --match_string="__SSH_PORT__" --replace_string="$ssh_port" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__SIDEKIQ_PORT__" --replace_string="$portSidekiq" --target_file="$config_path/gitlab.rb" ynh_replace_string --match_string="__SIDEKIQ_PORT__" --replace_string="$portSidekiq" --target_file="$config_path/gitlab.rb"
@ -122,16 +125,16 @@ gitlab-ctl reconfigure
#================================================= #=================================================
# WAITING GITLAB # WAITING GITLAB
#================================================= #=================================================
ynh_script_progression --message="Waiting for gitlab..." --weight=15 ynh_script_progression --message="Waiting for GitLab..." --weight=15
ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="adopted" --timeout=300 ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/puma/current" --line_match="Listening on tcp://127.0.0.1:$portPuma" --timeout=300
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=1 ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --action=reload --service_name=nginx ynh_systemd_action --action=reload --service_name=nginx
@ -139,4 +142,4 @@ ynh_systemd_action --action=reload --service_name=nginx
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Change of URL completed for $app" --last ynh_script_progression --message="Change of URL completed for GitLab" --last

View file

@ -33,31 +33,6 @@ overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwri
old_use_web_account="$(ynh_app_setting_get --app=$app --key=use_web_account)" old_use_web_account="$(ynh_app_setting_get --app=$app --key=use_web_account)"
use_web_account="${YNH_CONFIG_MAIN_USERS_USE_WEB_ACCOUNT:-$old_use_web_account}" use_web_account="${YNH_CONFIG_MAIN_USERS_USE_WEB_ACCOUNT:-$old_use_web_account}"
# backup_strategy
old_backup_db="$(ynh_app_setting_get --app=$app --key=backup_db)"
backup_db="${YNH_CONFIG_MAIN_BACKUP_STRATEGY_BACKUP_DB:-$old_backup_db}"
old_backup_uploads="$(ynh_app_setting_get --app=$app --key=backup_uploads)"
backup_uploads="${YNH_CONFIG_MAIN_BACKUP_STRATEGY_BACKUP_UPLOADS:-$old_backup_uploads}"
old_backup_repositories="$(ynh_app_setting_get --app=$app --key=backup_repositories)"
backup_repositories="${YNH_CONFIG_MAIN_BACKUP_STRATEGY_BACKUP_REPOSITORIES:-$old_backup_repositories}"
old_backup_builds="$(ynh_app_setting_get --app=$app --key=backup_builds)"
backup_builds="${YNH_CONFIG_MAIN_BACKUP_STRATEGY_BACKUP_BUILDS:-$old_backup_builds}"
old_backup_artifacts="$(ynh_app_setting_get --app=$app --key=backup_artifacts)"
backup_artifacts="${YNH_CONFIG_MAIN_BACKUP_STRATEGY_BACKUP_ARTIFACTS:-$old_backup_artifacts}"
old_backup_lfs="$(ynh_app_setting_get --app=$app --key=backup_lfs)"
backup_lfs="${YNH_CONFIG_MAIN_BACKUP_STRATEGY_BACKUP_LFS:-$old_backup_lfs}"
old_backup_registry="$(ynh_app_setting_get --app=$app --key=backup_registry)"
backup_registry="${YNH_CONFIG_MAIN_BACKUP_STRATEGY_BACKUP_REGISTRY:-$old_backup_registry}"
old_backup_pages="$(ynh_app_setting_get --app=$app --key=backup_pages)"
backup_pages="${YNH_CONFIG_MAIN_BACKUP_STRATEGY_BACKUP_PAGES:-$old_backup_pages}"
#================================================= #=================================================
# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND # SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND
#================================================= #=================================================
@ -69,22 +44,6 @@ show_config() {
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx" ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
ynh_return "YNH_CONFIG_MAIN_USERS_USE_WEB_ACCOUNT=$use_web_account" ynh_return "YNH_CONFIG_MAIN_USERS_USE_WEB_ACCOUNT=$use_web_account"
ynh_return "YNH_CONFIG_MAIN_BACKUP_STRATEGY_BACKUP_DB=$backup_db"
ynh_return "YNH_CONFIG_MAIN_BACKUP_STRATEGY_BACKUP_UPLOADS=$backup_uploads"
ynh_return "YNH_CONFIG_MAIN_BACKUP_STRATEGY_BACKUP_REPOSITORIES=$backup_repositories"
ynh_return "YNH_CONFIG_MAIN_BACKUP_STRATEGY_BACKUP_BUILDS=$backup_builds"
ynh_return "YNH_CONFIG_MAIN_BACKUP_STRATEGY_BACKUP_ARTIFACTS=$backup_artifacts"
ynh_return "YNH_CONFIG_MAIN_BACKUP_STRATEGY_BACKUP_LFS=$backup_lfs"
ynh_return "YNH_CONFIG_MAIN_BACKUP_STRATEGY_BACKUP_REGISTRY=$backup_registry"
ynh_return "YNH_CONFIG_MAIN_BACKUP_STRATEGY_BACKUP_PAGES=$backup_pages"
} }
#================================================= #=================================================
@ -97,23 +56,6 @@ apply_config() {
# Set overwrite_nginx # Set overwrite_nginx
ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx" ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx"
# Set backup_db
ynh_app_setting_set --app=$app --key=backup_db --value="$backup_db"
# Set backup_uploads
ynh_app_setting_set --app=$app --key=backup_uploads --value="$backup_uploads"
# Set backup_repositories
ynh_app_setting_set --app=$app --key=backup_repositories --value="$backup_repositories"
# Set backup_builds
ynh_app_setting_set --app=$app --key=backup_builds --value="$backup_builds"
# Set backup_artifacts
ynh_app_setting_set --app=$app --key=backup_artifacts --value="$backup_artifacts"
# Set backup_lfs
ynh_app_setting_set --app=$app --key=backup_lfs --value="$backup_lfs"
# Set backup_registry
ynh_app_setting_set --app=$app --key=backup_registry --value="$backup_registry"
# Set backup_pages
ynh_app_setting_set --app=$app --key=backup_pages --value="$backup_pages"
} }
#================================================= #=================================================

View file

@ -43,7 +43,9 @@ final_path=/opt/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Detect the system architecture # Detect the system architecture
if [ -n "$(uname -m | grep 64)" ]; then if [ -n "$(uname -m | grep aarch64)" ]; then
ynh_die "Gitlab is not compatible with arm64 architecture"
elif [ -n "$(uname -m | grep x86_64)" ]; then
architecture="x86-64" architecture="x86-64"
elif [ -n "$(uname -m | grep 86)" ]; then elif [ -n "$(uname -m | grep 86)" ]; then
ynh_die "Gitlab is not compatible with x86 architecture" ynh_die "Gitlab is not compatible with x86 architecture"
@ -84,11 +86,11 @@ ynh_script_progression --message="Find internal port..." --weight=1
# Find free ports # Find free ports
port=$(ynh_find_port --port=8080) port=$(ynh_find_port --port=8080)
portUnicorn=$(ynh_find_port --port=$(($port + 1))) portPuma=$(ynh_find_port --port=$(($port + 1)))
portSidekiq=$(ynh_find_port --port=$(($portUnicorn + 1))) portSidekiq=$(ynh_find_port --port=$(($portPuma + 1)))
ynh_app_setting_set --app=$app --key=web_port --value=$port ynh_app_setting_set --app=$app --key=web_port --value=$port
ynh_app_setting_set --app=$app --key=unicorn_port --value=$portUnicorn ynh_app_setting_set --app=$app --key=puma_port --value=$portPuma
ynh_app_setting_set --app=$app --key=sidekiq_port --value=$portSidekiq ynh_app_setting_set --app=$app --key=sidekiq_port --value=$portSidekiq
#================================================= #=================================================
@ -102,26 +104,28 @@ ynh_install_app_dependencies $pkg_dependencies
# DEFINE THE NUMBER OF WORKERS USED # DEFINE THE NUMBER OF WORKERS USED
#================================================= #=================================================
# https://docs.gitlab.com/ce/install/requirements.html#unicorn-workers #https://docs.gitlab.com/ce/install/requirements.html#puma-workers
unicorn_worker_processes=$(bc <<< "($(nproc) * 1.5 + 1) / 1") puma_worker_processes=$(( $(nproc) > 2 ? $(nproc) : 2 ))
# If the server has at least 2GB of RAM # If the server has less than 2GB of RAM
if [ $(ynh_check_ram --no_swap) -ge 2000 ]; then if [ $(ynh_get_ram --total --ignore_swap) -lt 2000 ]; then
# Min 3 worker processes puma_min_threads=1
unicorn_worker_processes=$(($unicorn_worker_processes>3?$unicorn_worker_processes:3)) puma_max_threads=1
else else
# 2 worker processes puma_min_threads=2
unicorn_worker_processes=2 puma_max_threads=4
fi fi
ynh_app_setting_set --app=$app --key=unicorn_worker_processes --value=$unicorn_worker_processes ynh_app_setting_set --app=$app --key=puma_workers --value=$puma_worker_processes
ynh_app_setting_set --app=$app --key=puma_max_threads --value=$puma_max_threads
ynh_app_setting_set --app=$app --key=puma_min_threads --value=$puma_min_threads
#================================================= #=================================================
# ADD SWAP IF NEEDED # ADD SWAP IF NEEDED
#================================================= #=================================================
total_memory=$(ynh_check_ram) total_memory=$(ynh_get_ram --total)
total_swap=$(ynh_check_ram --only_swap) total_swap=$(ynh_get_ram --total --only_swap)
swap_needed=0 swap_needed=0
# https://docs.gitlab.com/ce/install/requirements.html#memory # https://docs.gitlab.com/ce/install/requirements.html#memory
@ -135,13 +139,15 @@ if [ $(($total_swap + $swap_needed)) -lt 2048 ]; then
swap_needed=$((2048 - $total_swap)) swap_needed=$((2048 - $total_swap))
fi fi
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 if [ $swap_needed -gt 0 ]; then
ynh_add_swap --size=$swap_needed ynh_script_progression --message="Adding $swap_needed Mo to swap..."
ynh_add_swap --size=$swap_needed
fi
#================================================= #=================================================
# PRECONFIGURE GITLAB # PRECONFIGURE GITLAB
#================================================= #=================================================
ynh_script_progression --message="Preconfigure gitlab..." --weight=1 ynh_script_progression --message="Preconfigure GitLab..." --weight=1
mkdir -p $config_path mkdir -p $config_path
@ -153,8 +159,10 @@ ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+")
ynh_replace_string --match_string="__GENERATED_EXTERNAL_URL__" --replace_string="https://$domain${path_url%/}" --target_file="$config_path/gitlab.rb" ynh_replace_string --match_string="__GENERATED_EXTERNAL_URL__" --replace_string="https://$domain${path_url%/}" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_path/gitlab.rb" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__UNICORN_PORT__" --replace_string="$portUnicorn" --target_file="$config_path/gitlab.rb" ynh_replace_string --match_string="__PUMA_PORT__" --replace_string="$portPuma" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__UNICORN_WORKER_PROCESSES__" --replace_string="$unicorn_worker_processes" --target_file="$config_path/gitlab.rb" ynh_replace_string --match_string="__PUMA_WORKER_PROCESSES__" --replace_string="$puma_worker_processes" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__PUMA_MIN_THREADS__" --replace_string="$puma_min_threads" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__PUMA_MAX_THREADS__" --replace_string="$puma_max_threads" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__CLIENT_MAX_BODY_SIZE__" --replace_string="$client_max_body_size" --target_file="$config_path/gitlab.rb" ynh_replace_string --match_string="__CLIENT_MAX_BODY_SIZE__" --replace_string="$client_max_body_size" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__SSH_PORT__" --replace_string="$ssh_port" --target_file="$config_path/gitlab.rb" ynh_replace_string --match_string="__SSH_PORT__" --replace_string="$ssh_port" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__SIDEKIQ_PORT__" --replace_string="$portSidekiq" --target_file="$config_path/gitlab.rb" ynh_replace_string --match_string="__SIDEKIQ_PORT__" --replace_string="$portSidekiq" --target_file="$config_path/gitlab.rb"
@ -168,18 +176,14 @@ ynh_store_file_checksum --file="$config_path/gitlab.rb"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=200 ynh_script_progression --message="Setting up source files..." --weight=50
source ./upgrade.d/upgrade.last.sh source ./upgrade.d/upgrade.last.sh
cp ../conf/$architecture.src.default ../conf/$architecture.src cp ../conf/$architecture.src.default ../conf/$architecture.src
ynh_replace_string --match_string="__VERSION__" --replace_string="$gitlab_version" --target_file="../conf/$architecture.src" ynh_replace_string --match_string="__VERSION__" --replace_string="$gitlab_version" --target_file="../conf/$architecture.src"
ynh_replace_string --match_string="__SOURCE_FILENAME__" --replace_string="$gitlab_filename" --target_file="../conf/$architecture.src" ynh_replace_string --match_string="__SOURCE_FILENAME__" --replace_string="$gitlab_filename" --target_file="../conf/$architecture.src"
ynh_replace_string --match_string="__DEBIAN_VERSION__" --replace_string="$gitlab_debian_version" --target_file="../conf/$architecture.src"
if [ $architecture = "x86-64" ]; then ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$gitlab_source_sha256" --target_file="../conf/$architecture.src"
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$gitlab_x86_64_source_sha256" --target_file="../conf/$architecture.src"
elif [ $architecture = "arm" ]; then
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$gitlab_arm_source_sha256" --target_file="../conf/$architecture.src"
fi
tempdir="$(mktemp -d)" tempdir="$(mktemp -d)"
@ -194,9 +198,9 @@ fi
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring nginx web server..." --weight=2 ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated nginx config # Create a dedicated NGINX config
ynh_add_nginx_config client_max_body_size ynh_add_nginx_config client_max_body_size
#================================================= #=================================================
@ -216,24 +220,10 @@ newuser.confirmation_token = nil
newuser.save newuser.save
ApplicationSetting.last.update_attributes(password_authentication_enabled_for_web: $use_web_account, signup_enabled: $use_web_account)" | gitlab-rails console ApplicationSetting.last.update_attributes(password_authentication_enabled_for_web: $use_web_account, signup_enabled: $use_web_account)" | gitlab-rails console
#=================================================
# DEFINE THE BACKUP STRATEGY: https://docs.gitlab.com/ce/raketasks/backup_restore.html#excluding-specific-directories-from-the-backup
#=================================================
ynh_app_setting_set --app=$app --key=backup_db --value=1
ynh_app_setting_set --app=$app --key=backup_uploads --value=1
ynh_app_setting_set --app=$app --key=backup_repositories --value=1
ynh_app_setting_set --app=$app --key=backup_builds --value=1
ynh_app_setting_set --app=$app --key=backup_artifacts --value=1
ynh_app_setting_set --app=$app --key=backup_lfs --value=1
ynh_app_setting_set --app=$app --key=backup_registry --value=1
ynh_app_setting_set --app=$app --key=backup_pages --value=1
#================================================= #=================================================
# RECONFIGURE TO TAKE INTO ACCOUNT CHANGES # RECONFIGURE TO TAKE INTO ACCOUNT CHANGES
#================================================= #=================================================
ynh_script_progression --message="Reconfigure gitlab..." --weight=13 ynh_script_progression --message="Reconfigure GitLab..." --weight=13
gitlab-ctl reconfigure gitlab-ctl reconfigure
@ -243,7 +233,7 @@ gitlab-ctl reconfigure
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/application.log" "/var/log/$app/gitlab-rails/api_json.log" "/var/log/$app/gitlab-rails/production.log" "/var/log/$app/gitlab-rails/production_json.log" "/var/log/$app/gitlab-rails/sidekiq.log" "/var/log/$app/unicorn/unicorn_stderr.log" "/var/log/$app/unicorn/current" "/var/log/$app/alertmanager/current" "/var/log/$app/gitaly/current" "/var/log/$app/gitlab-monitor/current" "/var/log/$app/gitlab-shell/gitlab-shell.log" "/var/log/$app/gitlab-workhorse/current" "/var/log/$app/logrotate/current" "/var/log/$app/nginx/current" "/var/log/$app/nginx/access.log" "/var/log/$app/nginx/error.log" "/var/log/$app/nginx/gitlab_access.log" "/var/log/$app/nginx/gitlab_error.log" "/var/log/$app/node-exporter/current" "/var/log/$app/postgres-exporter/current" "/var/log/$app/postgresql/current" "/var/log/$app/prometheus/current" "/var/log/$app/redis/current" "/var/log/$app/redis-exporter/current" yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/application.log" "/var/log/$app/gitlab-rails/api_json.log" "/var/log/$app/gitlab-rails/production.log" "/var/log/$app/gitlab-rails/production_json.log" "/var/log/$app/gitlab-rails/sidekiq.log" "/var/log/$app/puma/puma_stderr.log" "/var/log/$app/puma/current" "/var/log/$app/alertmanager/current" "/var/log/$app/gitaly/current" "/var/log/$app/gitlab-monitor/current" "/var/log/$app/gitlab-shell/gitlab-shell.log" "/var/log/$app/gitlab-workhorse/current" "/var/log/$app/logrotate/current" "/var/log/$app/nginx/current" "/var/log/$app/nginx/access.log" "/var/log/$app/nginx/error.log" "/var/log/$app/nginx/gitlab_access.log" "/var/log/$app/nginx/gitlab_error.log" "/var/log/$app/node-exporter/current" "/var/log/$app/postgres-exporter/current" "/var/log/$app/postgresql/current" "/var/log/$app/prometheus/current" "/var/log/$app/redis/current" "/var/log/$app/redis-exporter/current"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
@ -258,19 +248,19 @@ fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=1 ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --action=reload --service_name=nginx ynh_systemd_action --action=reload --service_name=nginx
#================================================= #=================================================
# RESTART GITLAB # RESTART GITLAB
#================================================= #=================================================
ynh_script_progression --message="Restarting gitlab..." --weight=15 ynh_script_progression --message="Restarting GitLab..." --weight=15
ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="adopted" --timeout=300 ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/puma/current" --line_match="Listening on tcp://127.0.0.1:$portPuma" --timeout=300
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression --message="Installation of GitLab completed" --last

View file

@ -16,12 +16,14 @@ ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app="$app" --key=domain)
port=$(ynh_app_setting_get --app="$app" --key=web_port) port=$(ynh_app_setting_get --app="$app" --key=web_port)
portUnicorn=$(ynh_app_setting_get --app="$app" --key=unicorn_port) portPuma=$(ynh_app_setting_get --app="$app" --key=puma_port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
config_path=$(ynh_app_setting_get --app=$app --key=config_path) config_path=$(ynh_app_setting_get --app=$app --key=config_path)
# Used by ynh_remove_nginx_config
domain=$(ynh_app_setting_get --app="$app" --key=domain)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
@ -37,7 +39,7 @@ fi
#================================================= #=================================================
# STOP GITLAB # STOP GITLAB
#================================================= #=================================================
ynh_script_progression --message="Stopping gitlab" --weight=8 ynh_script_progression --message="Stopping GitLab" --weight=8
# I use gitlab-ctl and not ynh_systemd_action or systemctl to stop the service to avoid this error: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/common_installation_problems/README.md#reconfigure-freezes-at-ruby_blocksupervise_redis_sleep-action-run during the reinstall of the app # I use gitlab-ctl and not ynh_systemd_action or systemctl to stop the service to avoid this error: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/common_installation_problems/README.md#reconfigure-freezes-at-ruby_blocksupervise_redis_sleep-action-run during the reinstall of the app
gitlab-ctl stop gitlab-ctl stop
@ -45,7 +47,7 @@ gitlab-ctl stop
#================================================= #=================================================
# REMOVE GITLAB # REMOVE GITLAB
#================================================= #=================================================
ynh_script_progression --message="Removing Gitlab" --weight=4 ynh_script_progression --message="Removing GitLab" --weight=4
dpkg --remove gitlab-ce dpkg --remove gitlab-ce
@ -69,9 +71,9 @@ ynh_secure_remove --file="$config_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing nginx web server configuration" --weight=1 ynh_script_progression --message="Removing NGINX web server configuration" --weight=1
# Remove the dedicated nginx config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#================================================= #=================================================
@ -84,9 +86,9 @@ if yunohost firewall list | grep -q "\- $port$"; then
ynh_exec_warn_less yunohost firewall disallow TCP $port ynh_exec_warn_less yunohost firewall disallow TCP $port
fi fi
if yunohost firewall list | grep -q "\- $portUnicorn$"; then if yunohost firewall list | grep -q "\- $portPuma$"; then
ynh_script_progression --message="Closing port $portUnicorn" --weight=1 ynh_script_progression --message="Closing port $portPuma" --weight=1
ynh_exec_warn_less yunohost firewall disallow TCP $portUnicorn ynh_exec_warn_less yunohost firewall disallow TCP $portPuma
fi fi
#================================================= #=================================================
@ -108,4 +110,4 @@ ynh_del_swap
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression --message="Removal of GitLab completed" --last

View file

@ -33,8 +33,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
config_path=$(ynh_app_setting_get --app=$app --key=config_path) config_path=$(ynh_app_setting_get --app=$app --key=config_path)
port=$(ynh_app_setting_get --app="$app" --key=web_port) portPuma=$(ynh_app_setting_get --app="$app" --key=puma_port)
portUnicorn=$(ynh_app_setting_get --app="$app" --key=unicorn_port)
architecture=$(ynh_app_setting_get --app="$app" --key=architecture) architecture=$(ynh_app_setting_get --app="$app" --key=architecture)
#================================================= #=================================================
@ -67,8 +66,8 @@ ynh_install_app_dependencies $pkg_dependencies
# ADD SWAP IF NEEDED # ADD SWAP IF NEEDED
#================================================= #=================================================
total_memory=$(ynh_check_ram) total_memory=$(ynh_get_ram --total)
total_swap=$(ynh_check_ram --only_swap) total_swap=$(ynh_get_ram --total --only_swap)
swap_needed=0 swap_needed=0
# https://docs.gitlab.com/ce/install/requirements.html#memory # https://docs.gitlab.com/ce/install/requirements.html#memory
@ -88,7 +87,7 @@ ynh_add_swap --size=$swap_needed
#================================================= #=================================================
# RESTORE CONF FILES # RESTORE CONF FILES
#================================================= #=================================================
ynh_script_progression --message="Restoring configuration files of Gitlab..." --weight=1 ynh_script_progression --message="Restoring configuration files of GitLab..." --weight=1
ynh_restore_file --origin_path="$config_path/gitlab-secrets.json" ynh_restore_file --origin_path="$config_path/gitlab-secrets.json"
ynh_restore_file --origin_path="$config_path/gitlab.rb" ynh_restore_file --origin_path="$config_path/gitlab.rb"
@ -97,19 +96,15 @@ ynh_restore_file --origin_path="$config_path/gitlab-persistent.rb"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Reinstalling gitlab..." --weight=200 ynh_script_progression --message="Reinstalling GitLab..." --weight=50
source ../settings/scripts/upgrade.d/upgrade.last.sh source ../settings/scripts/upgrade.d/upgrade.last.sh
mkdir -p ../conf/ mkdir -p ../conf/
cp ../settings/conf/$architecture.src.default ../conf/$architecture.src cp ../settings/conf/$architecture.src.default ../conf/$architecture.src
ynh_replace_string --match_string="__VERSION__" --replace_string="$gitlab_version" --target_file="../conf/$architecture.src" ynh_replace_string --match_string="__VERSION__" --replace_string="$gitlab_version" --target_file="../conf/$architecture.src"
ynh_replace_string --match_string="__SOURCE_FILENAME__" --replace_string="$gitlab_filename" --target_file="../conf/$architecture.src" ynh_replace_string --match_string="__SOURCE_FILENAME__" --replace_string="$gitlab_filename" --target_file="../conf/$architecture.src"
ynh_replace_string --match_string="__DEBIAN_VERSION__" --replace_string="$gitlab_debian_version" --target_file="../conf/$architecture.src"
if [ $architecture = "x86-64" ]; then ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$gitlab_source_sha256" --target_file="../conf/$architecture.src"
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$gitlab_x86_64_source_sha256" --target_file="../conf/$architecture.src"
elif [ $architecture = "arm" ]; then
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$gitlab_arm_source_sha256" --target_file="../conf/$architecture.src"
fi
tempdir="$(mktemp -d)" tempdir="$(mktemp -d)"
@ -126,13 +121,13 @@ fi
#================================================= #=================================================
# RESTORE GITLAB DATABASE # RESTORE GITLAB DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring Gitlab..." --weight=55 ynh_script_progression --message="Restoring GitLab..." --weight=35
ynh_restore_file --origin_path="/var/opt/$app/backups/last_gitlab_backup.tar" ynh_restore_file --origin_path="/var/opt/$app/backups/last_gitlab_backup.tar"
last_backup="last" last_backup="last"
gitlab-ctl stop unicorn gitlab-ctl stop puma
gitlab-ctl stop sidekiq gitlab-ctl stop sidekiq
# Use gitlab-rake to backup # Use gitlab-rake to backup
@ -150,14 +145,14 @@ fi
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/application.log" "/var/log/$app/gitlab-rails/api_json.log" "/var/log/$app/gitlab-rails/production.log" "/var/log/$app/gitlab-rails/production_json.log" "/var/log/$app/gitlab-rails/sidekiq.log" "/var/log/$app/unicorn/unicorn_stderr.log" "/var/log/$app/unicorn/current" "/var/log/$app/alertmanager/current" "/var/log/$app/gitaly/current" "/var/log/$app/gitlab-monitor/current" "/var/log/$app/gitlab-shell/gitlab-shell.log" "/var/log/$app/gitlab-workhorse/current" "/var/log/$app/logrotate/current" "/var/log/$app/nginx/current" "/var/log/$app/nginx/access.log" "/var/log/$app/nginx/error.log" "/var/log/$app/nginx/gitlab_access.log" "/var/log/$app/nginx/gitlab_error.log" "/var/log/$app/node-exporter/current" "/var/log/$app/postgres-exporter/current" "/var/log/$app/postgresql/current" "/var/log/$app/prometheus/current" "/var/log/$app/redis/current" "/var/log/$app/redis-exporter/current" yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/application.log" "/var/log/$app/gitlab-rails/api_json.log" "/var/log/$app/gitlab-rails/production.log" "/var/log/$app/gitlab-rails/production_json.log" "/var/log/$app/gitlab-rails/sidekiq.log" "/var/log/$app/puma/puma_stderr.log" "/var/log/$app/puma/current" "/var/log/$app/alertmanager/current" "/var/log/$app/gitaly/current" "/var/log/$app/gitlab-monitor/current" "/var/log/$app/gitlab-shell/gitlab-shell.log" "/var/log/$app/gitlab-workhorse/current" "/var/log/$app/logrotate/current" "/var/log/$app/nginx/current" "/var/log/$app/nginx/access.log" "/var/log/$app/nginx/error.log" "/var/log/$app/nginx/gitlab_access.log" "/var/log/$app/nginx/gitlab_error.log" "/var/log/$app/node-exporter/current" "/var/log/$app/postgres-exporter/current" "/var/log/$app/postgresql/current" "/var/log/$app/prometheus/current" "/var/log/$app/redis/current" "/var/log/$app/redis-exporter/current"
#================================================= #=================================================
# WAITING GITLAB # WAITING GITLAB
#================================================= #=================================================
ynh_script_progression --message="Waiting for gitlab..." --weight=14 ynh_script_progression --message="Waiting for GitLab..." --weight=14
ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="adopted" --timeout=300 ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/puma/current" --line_match="Listening on tcp://127.0.0.1:$portPuma" --timeout=300
#================================================= #=================================================
# CHECK THE RESTORED DATA # CHECK THE RESTORED DATA
@ -168,7 +163,7 @@ gitlab-rake gitlab:check SANITIZE=true
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=1 ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --action=reload --service_name=nginx ynh_systemd_action --action=reload --service_name=nginx
@ -176,4 +171,4 @@ ynh_systemd_action --action=reload --service_name=nginx
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --last ynh_script_progression --message="Restoration completed for GitLab" --last

View file

@ -6,12 +6,9 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# IMPORT GENERIC HELPERS source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Load common variables and helpers
source ./_common.sh
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
@ -21,27 +18,19 @@ app=$YNH_APP_INSTANCE_NAME
# Retrieve app settings # Retrieve app settings
domain=$(ynh_app_setting_get --app="$app" --key=domain) domain=$(ynh_app_setting_get --app="$app" --key=domain)
path_url=$(ynh_app_setting_get --app="$app" --key=path) path_url=$(ynh_app_setting_get --app="$app" --key=path)
admin=$(ynh_app_setting_get --app="$app" --key=admin)
is_public=$(ynh_app_setting_get --app="$app" --key=is_public) is_public=$(ynh_app_setting_get --app="$app" --key=is_public)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
config_path=$(ynh_app_setting_get --app=$app --key=config_path) config_path=$(ynh_app_setting_get --app=$app --key=config_path)
port=$(ynh_app_setting_get --app="$app" --key=web_port) port=$(ynh_app_setting_get --app="$app" --key=web_port)
portUnicorn=$(ynh_app_setting_get --app="$app" --key=unicorn_port) portPuma=$(ynh_app_setting_get --app="$app" --key=puma_port)
portSidekiq=$(ynh_app_setting_get --app="$app" --key=sidekiq_port) portSidekiq=$(ynh_app_setting_get --app="$app" --key=sidekiq_port)
architecture=$(ynh_app_setting_get --app="$app" --key=architecture) architecture=$(ynh_app_setting_get --app="$app" --key=architecture)
unicorn_worker_processes=$(ynh_app_setting_get --app="$app" --key=unicorn_worker_processes) puma_worker_processes=$(ynh_app_setting_get --app="$app" --key=puma_worker_processes)
puma_min_threads=$(ynh_app_setting_get --app="$app" --key=puma_min_threads)
puma_max_threads=$(ynh_app_setting_get --app="$app" --key=puma_max_threads)
client_max_body_size=$(ynh_app_setting_get --app="$app" --key=client_max_body_size) client_max_body_size=$(ynh_app_setting_get --app="$app" --key=client_max_body_size)
overwrite_nginx=$(ynh_app_setting_get --app="$app" --key=overwrite_nginx) overwrite_nginx=$(ynh_app_setting_get --app="$app" --key=overwrite_nginx)
backup_db=$(ynh_app_setting_get --app="$app" --key=backup_db)
backup_uploads=$(ynh_app_setting_get --app="$app" --key=backup_uploads)
backup_repositories=$(ynh_app_setting_get --app="$app" --key=backup_repositories)
backup_builds=$(ynh_app_setting_get --app="$app" --key=backup_builds)
backup_artifacts=$(ynh_app_setting_get --app="$app" --key=backup_artifacts)
backup_lfs=$(ynh_app_setting_get --app="$app" --key=backup_lfs)
backup_registry=$(ynh_app_setting_get --app="$app" --key=backup_registry)
backup_pages=$(ynh_app_setting_get --app="$app" --key=backup_pages)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
@ -69,31 +58,31 @@ if [ -z "$config_path" ]; then
ynh_app_setting_set --app=$app --key=config_path --value=$config_path ynh_app_setting_set --app=$app --key=config_path --value=$config_path
fi fi
if [ -z "$unicorn_worker_processes" ]; then if [ -z "$puma_worker_processes" ]; then
# https://docs.gitlab.com/ce/install/requirements.html#unicorn-workers #https://docs.gitlab.com/ce/install/requirements.html#puma-workers
unicorn_worker_processes=$(($(nproc) + 1 )) puma_worker_processes=$(( $(nproc) > 2 ? $(nproc) : 2 ))
# If the server has at least 2GB of RAM # If the server has less than 2GB of RAM
if [ $(free -g --si | grep Mem: | awk '{print $2}') -ge 2 ]; then if [ $(ynh_get_ram --total --ignore_swap) -lt 2000 ]; then
# Min 3 worker processes puma_min_threads=1
unicorn_worker_processes=$(($unicorn_worker_processes>3?$unicorn_worker_processes:3)) puma_max_threads=1
else else
# 2 worker processes puma_min_threads=2
unicorn_worker_processes=2 puma_max_threads=4
fi fi
ynh_app_setting_set --app=$app --key=unicorn_worker_processes --value=$unicorn_worker_processes
fi
if [ -z "$portSidekiq" ]; then ynh_app_setting_set --app=$app --key=puma_workers --value=$puma_worker_processes
portSidekiq=$(ynh_find_port $(($portUnicorn + 1))) ynh_app_setting_set --app=$app --key=puma_max_threads --value=$puma_max_threads
ynh_app_setting_set --app=$app --key=puma_min_threads --value=$puma_min_threads
ynh_app_setting_set --app=$app --key=sidekiq_port --value=$portSidekiq ynh_app_setting_delete --app=$app --key=unicorn_worker_processes
fi fi
# If architecture doesn't exist, create it # If architecture doesn't exist, create it
if [ -z "$architecture" ]; then if [ -z "$architecture" ]; then
# Detect the system architecture if [ -n "$(uname -m | grep aarch64)" ]; then
if [ -n "$(uname -m | grep 64)" ]; then ynh_die "Gitlab is not compatible with arm64 architecture"
elif [ -n "$(uname -m | grep x86_64)" ]; then
architecture="x86-64" architecture="x86-64"
elif [ -n "$(uname -m | grep 86)" ]; then elif [ -n "$(uname -m | grep 86)" ]; then
ynh_die "Gitlab is not compatible with x86 architecture" ynh_die "Gitlab is not compatible with x86 architecture"
@ -141,9 +130,19 @@ if [ -z "$port" ]; then
fi fi
# If port doesn't exist, retrieve it # If port doesn't exist, retrieve it
if [ -z "$portUnicorn" ]; then if [ -z "$portPuma" ]; then
portUnicorn=$(grep -F "unicorn['port']" "/etc/gitlab/gitlab.rb" | cut -d' ' -f3) if [ -z "$(ynh_app_setting_get --app="$app" --key=unicorn_port)" ]; then
ynh_app_setting_set --app=$app --key=unicorn_port --value=$portUnicorn portPuma=$(grep -F "unicorn['port']" "/etc/gitlab/gitlab.rb" | cut -d' ' -f3)
else
portPuma=$(ynh_app_setting_get --app="$app" --key=unicorn_port)
fi
ynh_app_setting_set --app=$app --key=puma_port --value=$portPuma
ynh_app_setting_delete --app=$app --key=unicorn_port
fi
if [ -z "$portSidekiq" ]; then
portSidekiq=$(ynh_find_port $(($portPuma + 1)))
ynh_app_setting_set --app=$app --key=sidekiq_port --value=$portSidekiq
fi fi
# if this source file exist, remove it # if this source file exist, remove it
@ -151,39 +150,6 @@ if [ -e "/etc/apt/sources.list.d/gitlab-ce.list" ]; then
ynh_secure_remove --file="/etc/apt/sources.list.d/gitlab-ce.list" ynh_secure_remove --file="/etc/apt/sources.list.d/gitlab-ce.list"
fi fi
# Define the backup strategy: https://docs.gitlab.com/ce/raketasks/backup_restore.html#excluding-specific-directories-from-the-backup
if [ -z "$backup_db" ]; then
ynh_app_setting_set --app=$app --key=backup_db --value=1
fi
if [ -z "$backup_uploads" ]; then
ynh_app_setting_set --app=$app --key=backup_uploads --value=1
fi
if [ -z "$backup_repositories" ]; then
ynh_app_setting_set --app=$app --key=backup_repositories --value=1
fi
if [ -z "$backup_builds" ]; then
ynh_app_setting_set --app=$app --key=backup_builds --value=1
fi
if [ -z "$backup_artifacts" ]; then
ynh_app_setting_set --app=$app --key=backup_artifacts --value=1
fi
if [ -z "$backup_lfs" ]; then
ynh_app_setting_set --app=$app --key=backup_lfs --value=1
fi
if [ -z "$backup_registry" ]; then
ynh_app_setting_set --app=$app --key=backup_registry --value=1
fi
if [ -z "$backup_pages" ]; then
ynh_app_setting_set --app=$app --key=backup_pages --value=1
fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
@ -202,13 +168,6 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#=================================================
# CHECK THE PATH
#=================================================
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url)
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -222,8 +181,8 @@ ynh_install_app_dependencies $pkg_dependencies
# ADD SWAP IF NEEDED # ADD SWAP IF NEEDED
#================================================= #=================================================
total_memory=$(ynh_check_ram) total_memory=$(ynh_get_ram --total)
total_swap=$(ynh_check_ram --only_swap) total_swap=$(ynh_get_ram --total --only_swap)
swap_needed=0 swap_needed=0
# https://docs.gitlab.com/ce/install/requirements.html#memory # https://docs.gitlab.com/ce/install/requirements.html#memory
@ -240,39 +199,13 @@ fi
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
ynh_add_swap --size=$swap_needed ynh_add_swap --size=$swap_needed
#=================================================
# PRECONFIGURE GITLAB
#=================================================
ynh_script_progression --message="Preconfigure gitlab..." --weight=1
ynh_backup_if_checksum_is_different --file="$config_path/gitlab.rb"
mkdir -p $config_path
cp -f ../conf/gitlab.rb "$config_path/gitlab.rb"
ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+")
ynh_replace_string --match_string="__GENERATED_EXTERNAL_URL__" --replace_string="https://$domain${path_url%/}" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__UNICORN_PORT__" --replace_string="$portUnicorn" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__UNICORN_WORKER_PROCESSES__" --replace_string="$unicorn_worker_processes" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__CLIENT_MAX_BODY_SIZE__" --replace_string="$client_max_body_size" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__SSH_PORT__" --replace_string="$ssh_port" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__SIDEKIQ_PORT__" --replace_string="$portSidekiq" --target_file="$config_path/gitlab.rb"
ynh_store_file_checksum --file="$config_path/gitlab.rb"
touch "$config_path/gitlab-persistent.rb"
chown admin: "$config_path/gitlab-persistent.rb"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Setting up source files..." --weight=200 ynh_script_progression --message="Setting up source files..." --weight=50
# To avoid the automatic backup, already performed by YunoHost: https://docs.gitlab.com/omnibus/update/#updating-methods # To avoid the automatic backup, already performed by YunoHost: https://docs.gitlab.com/omnibus/update/#updating-methods
touch $config_path/skip-auto-backup touch $config_path/skip-auto-backup
@ -282,7 +215,22 @@ then
# Load the last available version # Load the last available version
source ./upgrade.d/upgrade.last.sh source ./upgrade.d/upgrade.last.sh
last_version=$gitlab_version last_version=$gitlab_version
last_major_version=${gitlab_version%%.*}
source_current_major_version () {
if [ -e "./upgrade.d/upgrade.$current_major_version.first.sh" ]; then
source ./upgrade.d/upgrade.$current_major_version.first.sh
elif [ -e "./upgrade.d/upgrade.$current_major_version.last.sh" ]; then
source ./upgrade.d/upgrade.$current_major_version.last.sh
# Finish with the last migration if the file doesn't exist
else
source ./upgrade.d/upgrade.last.sh
fi
}
# To update GitLab from major version A to B, we have to go to the last minor version
# of the major version A and then go to the first minor version of the major version B
# to finally go to the current minor version of the major version B
# A.last -> B.first -> B.last
# While the current version is not the last version, do an upgrade # While the current version is not the last version, do an upgrade
while [ "$last_version" != "$current_version" ] while [ "$last_version" != "$current_version" ]
@ -290,27 +238,28 @@ then
current_major_version=${current_version%%.*} current_major_version=${current_version%%.*}
# If the current version is equal to the last minor version of upgrade.$current_major_version.sh, increment the major version source_current_major_version
if [ "$gitlab_version" = "$current_version" ]; then
current_major_version=$(($current_major_version + 1)) # if the version stored in the upgrade.$current_major_version.first.sh file is less than or equal
# to the current version, and if the version stored in the upgrade.$current_major_version.last.sh file
# increment the major version to upgrade to the next version
if dpkg --compare-versions "$gitlab_version" "le" "$current_version"; then
if [ -e "./upgrade.d/upgrade.$current_major_version.last.sh" ]; then
source ./upgrade.d/upgrade.$current_major_version.last.sh
else
source ./upgrade.d/upgrade.last.sh
fi
if dpkg --compare-versions "$gitlab_version" "le" "$current_version"; then
current_major_version=$(($current_major_version + 1))
source_current_major_version
fi
fi fi
# If the current version has the same major version than the next one,
# then it's the last upgrade to do
if [ "$last_major_version" -eq "$current_major_version" ]; then
current_major_version=last
fi
source ./upgrade.d/upgrade.$current_major_version.sh
cp ../conf/$architecture.src.default ../conf/$architecture.src cp ../conf/$architecture.src.default ../conf/$architecture.src
ynh_replace_string --match_string="__VERSION__" --replace_string="$gitlab_version" --target_file="../conf/$architecture.src" ynh_replace_string --match_string="__VERSION__" --replace_string="$gitlab_version" --target_file="../conf/$architecture.src"
ynh_replace_string --match_string="__SOURCE_FILENAME__" --replace_string="$gitlab_filename" --target_file="../conf/$architecture.src" ynh_replace_string --match_string="__SOURCE_FILENAME__" --replace_string="$gitlab_filename" --target_file="../conf/$architecture.src"
ynh_replace_string --match_string="__DEBIAN_VERSION__" --replace_string="$gitlab_debian_version" --target_file="../conf/$architecture.src"
if [ $architecture = "x86-64" ]; then ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$gitlab_source_sha256" --target_file="../conf/$architecture.src"
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$gitlab_x86_64_source_sha256" --target_file="../conf/$architecture.src"
elif [ $architecture = "arm" ]; then
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$gitlab_arm_source_sha256" --target_file="../conf/$architecture.src"
fi
tempdir="$(mktemp -d)" tempdir="$(mktemp -d)"
@ -328,6 +277,35 @@ then
done done
fi fi
#=================================================
# RECONFIGURE GITLAB
#=================================================
ynh_script_progression --message="Reconfigure GitLab..." --weight=13
ynh_backup_if_checksum_is_different --file="$config_path/gitlab.rb"
mkdir -p $config_path
cp -f ../conf/gitlab.rb "$config_path/gitlab.rb"
ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+")
ynh_replace_string --match_string="__GENERATED_EXTERNAL_URL__" --replace_string="https://$domain${path_url%/}" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__PUMA_PORT__" --replace_string="$portPuma" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__PUMA_WORKER_PROCESSES__" --replace_string="$puma_worker_processes" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__PUMA_MIN_THREADS__" --replace_string="$puma_min_threads" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__PUMA_MAX_THREADS__" --replace_string="$puma_max_threads" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__CLIENT_MAX_BODY_SIZE__" --replace_string="$client_max_body_size" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__SSH_PORT__" --replace_string="$ssh_port" --target_file="$config_path/gitlab.rb"
ynh_replace_string --match_string="__SIDEKIQ_PORT__" --replace_string="$portSidekiq" --target_file="$config_path/gitlab.rb"
ynh_store_file_checksum --file="$config_path/gitlab.rb"
touch "$config_path/gitlab-persistent.rb"
chown admin: "$config_path/gitlab-persistent.rb"
gitlab-ctl reconfigure
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -335,7 +313,7 @@ fi
# Overwrite the nginx configuration only if it's allowed # Overwrite the nginx configuration only if it's allowed
if [ $overwrite_nginx -eq 1 ] if [ $overwrite_nginx -eq 1 ]
then then
ynh_script_progression --message="Configuring nginx web server..." --weight=2 ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config client_max_body_size ynh_add_nginx_config client_max_body_size
fi fi
@ -346,7 +324,7 @@ fi
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/application.log" "/var/log/$app/gitlab-rails/api_json.log" "/var/log/$app/gitlab-rails/production.log" "/var/log/$app/gitlab-rails/production_json.log" "/var/log/$app/gitlab-rails/sidekiq.log" "/var/log/$app/unicorn/unicorn_stderr.log" "/var/log/$app/unicorn/current" "/var/log/$app/alertmanager/current" "/var/log/$app/gitaly/current" "/var/log/$app/gitlab-monitor/current" "/var/log/$app/gitlab-shell/gitlab-shell.log" "/var/log/$app/gitlab-workhorse/current" "/var/log/$app/logrotate/current" "/var/log/$app/nginx/current" "/var/log/$app/nginx/access.log" "/var/log/$app/nginx/error.log" "/var/log/$app/nginx/gitlab_access.log" "/var/log/$app/nginx/gitlab_error.log" "/var/log/$app/node-exporter/current" "/var/log/$app/postgres-exporter/current" "/var/log/$app/postgresql/current" "/var/log/$app/prometheus/current" "/var/log/$app/redis/current" "/var/log/$app/redis-exporter/current" yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/application.log" "/var/log/$app/gitlab-rails/api_json.log" "/var/log/$app/gitlab-rails/production.log" "/var/log/$app/gitlab-rails/production_json.log" "/var/log/$app/gitlab-rails/sidekiq.log" "/var/log/$app/puma/puma_stderr.log" "/var/log/$app/puma/current" "/var/log/$app/alertmanager/current" "/var/log/$app/gitaly/current" "/var/log/$app/gitlab-monitor/current" "/var/log/$app/gitlab-shell/gitlab-shell.log" "/var/log/$app/gitlab-workhorse/current" "/var/log/$app/logrotate/current" "/var/log/$app/nginx/current" "/var/log/$app/nginx/access.log" "/var/log/$app/nginx/error.log" "/var/log/$app/nginx/gitlab_access.log" "/var/log/$app/nginx/gitlab_error.log" "/var/log/$app/node-exporter/current" "/var/log/$app/postgres-exporter/current" "/var/log/$app/postgresql/current" "/var/log/$app/prometheus/current" "/var/log/$app/redis/current" "/var/log/$app/redis-exporter/current"
#================================================= #=================================================
# WAITING GITLAB # WAITING GITLAB
@ -354,15 +332,15 @@ yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/applica
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Restarting gitlab..." --weight=15 ynh_script_progression --message="Restarting GitLab..." --weight=15
ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="adopted" --timeout=300 ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/puma/current" --line_match="Listening on tcp://127.0.0.1:$portPuma" --timeout=300
fi fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=1 ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --action=reload --service_name=nginx ynh_systemd_action --action=reload --service_name=nginx
@ -370,4 +348,4 @@ ynh_systemd_action --action=reload --service_name=nginx
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression --message="Upgrade of GitLab completed" --last

View file

@ -0,0 +1,27 @@
#!/bin/bash
gitlab_version="11.11.5"
# There is no buster version for gitlab 11.X
gitlab_debian_version="stretch"
gitlab_x86_64_stretch_source_sha256="1ee3d6e8d2cc198f5466de0884c03f6016299db24859126af9a191501dbdef10"
gitlab_arm_stretch_source_sha256="366e12b1f3d3b1694fcb6f13da9de908360ba93f75768d97e8d01e61e8652705"
architecture=$(ynh_app_setting_get --app="$app" --key=architecture)
if [ "$architecture" = "x86-64" ]; then
gitlab_source_sha256=$gitlab_x86_64_stretch_source_sha256
elif [ "$architecture" = "arm" ]; then
gitlab_source_sha256=$gitlab_arm_stretch_source_sha256
fi
gitlab_filename="gitlab-ce-${gitlab_version}.deb"
# Action to do in case of failure of the package_check
package_check_action() {
local sysctl_file="$final_path/embedded/cookbooks/package/resources/sysctl.rb"
ynh_replace_string --match_string="command \"sysctl -e \(.*\)\"" --replace_string="command \"sysctl -e \1 || true\"" --target_file=$sysctl_file
}

View file

@ -1,13 +0,0 @@
gitlab_version="11.11.5"
gitlab_x86_64_source_sha256="1ee3d6e8d2cc198f5466de0884c03f6016299db24859126af9a191501dbdef10"
gitlab_arm_source_sha256="366e12b1f3d3b1694fcb6f13da9de908360ba93f75768d97e8d01e61e8652705"
gitlab_filename="gitlab-ce-${gitlab_version}.deb"
# Action to do in case of failure of the package_check
package_check_action() {
ynh_replace_string --match_string="command \"cat \/etc\/sysctl.conf \/etc\/sysctl.d\/\*.conf | sysctl -e -p -\"" --replace_string="command \"cat \/etc\/sysctl.conf\"" --target_file="$final_path/embedded/cookbooks/package/resources/sysctl.rb"
}

View file

@ -0,0 +1,28 @@
#!/bin/bash
# It's required to upgrade to the latest 12.0.x version before to another 12.X verion.
gitlab_version="12.0.12"
# There is no buster version for gitlab 12.0.X
gitlab_debian_version="stretch"
gitlab_x86_64_stretch_source_sha256="e80cda4c328c2627278a3d74dbdd53420e1fec9ecbeaeb5d4dcb4773726e5904"
gitlab_arm_stretch_source_sha256="a0862e3c31b61d9274a55b7307d15daa5258473ccb97b8ae0d807f7474c971df"
architecture=$(ynh_app_setting_get --app="$app" --key=architecture)
if [ "$architecture" = "x86-64" ]; then
gitlab_source_sha256=$gitlab_x86_64_stretch_source_sha256
elif [ "$architecture" = "arm" ]; then
gitlab_source_sha256=$gitlab_arm_stretch_source_sha256
fi
gitlab_filename="gitlab-ce-${gitlab_version}.deb"
# Action to do in case of failure of the package_check
package_check_action() {
local sysctl_file="$final_path/embedded/cookbooks/package/resources/sysctl.rb"
ynh_replace_string --match_string="command \"sysctl -e \(.*\)\"" --replace_string="command \"sysctl -e \1 || true\"" --target_file=$sysctl_file
}

View file

@ -0,0 +1,39 @@
#!/bin/bash
gitlab_version="12.10.12"
# sha256sum found here: https://packages.gitlab.com/gitlab
gitlab_x86_64_buster_source_sha256="17df2dfa71678109f7f1031b43d7c4e30ae34749258b9f48dd49380dd9cc3488"
gitlab_x86_64_stretch_source_sha256="fbe744d04544465f6c97fd6fbc0dc11fb36ce2a75c4e943d911027b189634bee"
gitlab_arm_stretch_source_sha256="43fc988516251295653d660b927a311593c22df31b58e5d3d91f40c8164a08ee"
architecture=$(ynh_app_setting_get --app="$app" --key=architecture)
if [ "$architecture" = "x86-64" ]; then
gitlab_debian_version="$(lsb_release -sc)"
if [ "$gitlab_debian_version" = "buster" ]
then
gitlab_source_sha256=$gitlab_x86_64_buster_source_sha256
else
gitlab_source_sha256=$gitlab_x86_64_stretch_source_sha256
fi
elif [ "$architecture" = "arm" ]; then
gitlab_debian_version="stretch"
gitlab_source_sha256=$gitlab_arm_stretch_source_sha256
fi
gitlab_filename="gitlab-ce-${gitlab_version}.deb"
# Action to do in case of failure of the package_check
package_check_action() {
local sysctl_file="$final_path/embedded/cookbooks/package/resources/gitlab_sysctl.rb"
ynh_replace_string --match_string="command \"sysctl -e \(.*\)\"" --replace_string="command \"sysctl -e \1 || true\"" --target_file=$sysctl_file
sysctl_file="/opt/gitlab/embedded/cookbooks/package/recipes/sysctl.rb"
ynh_replace_string --match_string="command \"sysctl -e \(.*\)\"" --replace_string="command \"sysctl -e \1 || true\"" --target_file=$sysctl_file
}

View file

@ -0,0 +1,40 @@
#!/bin/bash
# It's required to upgrade to the latest 13.0.x version before to another 13.X verion.
gitlab_version="13.0.12"
# sha256sum found here: https://packages.gitlab.com/gitlab
gitlab_x86_64_buster_source_sha256="b568a8f45fdcb0c94e125fcc1e393e3f7364a4ab04d195bcf9b0797e71e0a8dd"
gitlab_x86_64_stretch_source_sha256="464b3d5923d945856fc851d0a01fc43fe223003a32a80bf90a84b599009fdce7"
gitlab_arm_stretch_source_sha256="39d7af79b80da73f26c8d2fa1ff95dfbca1573d36d6ee362e6f8fadceb17325e"
architecture=$(ynh_app_setting_get --app="$app" --key=architecture)
if [ "$architecture" = "x86-64" ]; then
gitlab_debian_version="$(lsb_release -sc)"
if [ "$gitlab_debian_version" = "buster" ]
then
gitlab_source_sha256=$gitlab_x86_64_buster_source_sha256
else
gitlab_source_sha256=$gitlab_x86_64_stretch_source_sha256
fi
elif [ "$architecture" = "arm" ]; then
gitlab_debian_version="stretch"
gitlab_source_sha256=$gitlab_arm_stretch_source_sha256
fi
gitlab_filename="gitlab-ce-${gitlab_version}.deb"
# Action to do in case of failure of the package_check
package_check_action() {
local sysctl_file="$final_path/embedded/cookbooks/package/resources/gitlab_sysctl.rb"
ynh_replace_string --match_string="command \"sysctl -e \(.*\)\"" --replace_string="command \"sysctl -e \1 || true\"" --target_file=$sysctl_file
sysctl_file="/opt/gitlab/embedded/cookbooks/package/recipes/sysctl.rb"
ynh_replace_string --match_string="command \"sysctl -e \(.*\)\"" --replace_string="command \"sysctl -e \1 || true\"" --target_file=$sysctl_file
}

View file

@ -1,16 +1,29 @@
gitlab_version="12.4.1" #!/bin/bash
gitlab_x86_64_source_sha256="c648d9b00ed5070a3cae6df508479380757040682ac71b7e43fb6466b1c2bb38" gitlab_version="13.7.4"
gitlab_arm_source_sha256="9634c287b75e849c7424c1bbf9507ad7f63bef14f340c2ce156e39e64a38cea5" # sha256sum found here: https://packages.gitlab.com/gitlab
gitlab_debian_version="buster"
gitlab_x86_64_buster_source_sha256="73341390775bdece7e084b7c76833338e9c00a26e849ac483db74dd279bcf9b0"
gitlab_arm_buster_source_sha256="21070aa0f991ec88f4149765ce1273c6a44cb8c3a91f301e27b3142235f75394"
architecture=$(ynh_app_setting_get --app="$app" --key=architecture)
if [ "$architecture" = "x86-64" ]; then
gitlab_source_sha256=$gitlab_x86_64_buster_source_sha256
elif [ "$architecture" = "arm" ]; then
gitlab_source_sha256=$gitlab_arm_buster_source_sha256
fi
gitlab_filename="gitlab-ce-${gitlab_version}.deb" gitlab_filename="gitlab-ce-${gitlab_version}.deb"
# Action to do in case of failure of the package_check # Action to do in case of failure of the package_check
package_check_action() { package_check_action() {
local sysctl_file="$final_path/embedded/cookbooks/package/resources/gitlab_sysctl.rb" local sysctl_file="$final_path/embedded/cookbooks/package/resources/gitlab_sysctl.rb"
if [ ! -f "$sysctl_file" ]; then ynh_replace_string --match_string="command \"sysctl -e \(.*\)\"" --replace_string="command \"sysctl -e \1 || true\"" --target_file=$sysctl_file
sysctl_file="$final_path/embedded/cookbooks/package/resources/sysctl.rb"
fi sysctl_file="/opt/gitlab/embedded/cookbooks/package/recipes/sysctl.rb"
ynh_replace_string --match_string="command \"sysctl -e --system\"" --replace_string="command \"sysctl -e --system || true\"" --target_file=$sysctl_file ynh_replace_string --match_string="command \"sysctl -e \(.*\)\"" --replace_string="command \"sysctl -e \1 || true\"" --target_file=$sysctl_file
} }

118
upgrade-versions.sh Executable file
View file

@ -0,0 +1,118 @@
#!/bin/bash
# /!\ This is a quick and dirty bash script, which does not respect the YNH format.
# This script will upgrade sha256sum, manifest, readme and config template
# /!\ before committing the modifications, check if nothing is broken if files
# Usage: ./upgrade-versions.sh path_to_upgrade_file version
# Example: ./upgrade-versions.sh scripts/upgrade.d/upgrade.last.sh 13.3.1
file=$(basename $1)
version=$2
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
gitlab_directory="$( cd "$( dirname "$current_dir/$1" )/../../" >/dev/null 2>&1 && pwd )"
sed -i -e "s/gitlab_version=\"[^0-9.]*[0-9.]*[0-9.]\"/gitlab_version=\"$version\"/" $gitlab_directory/scripts/upgrade.d/$file
# x86_64
url=https://packages.gitlab.com/gitlab/gitlab-ce/packages/debian/buster/gitlab-ce_$version-ce.0_amd64.deb
new_sha256=$(curl -s $url | sed -n '/SHA256$/,/<\/tr>$/{ /SHA256$/d; /<\/tr>$/d; p; }' | cut -d$'\n' -f3 | xargs)
echo url: $url
echo sha256: $new_sha256
sed -i -e "s/gitlab_x86_64_buster_source_sha256=\".*\"/gitlab_x86_64_buster_source_sha256=\"$new_sha256\"/" $gitlab_directory/scripts/upgrade.d/$file
# arm
url=https://packages.gitlab.com/gitlab/raspberry-pi2/packages/raspbian/buster/gitlab-ce_$version-ce.0_armhf.deb
new_sha256=$(curl -s $url | sed -n '/SHA256$/,/<\/tr>$/{ /SHA256$/d; /<\/tr>$/d; p; }' | cut -d$'\n' -f3 | xargs)
echo url: $url
echo sha256: $new_sha256
sed -i -e "s/gitlab_arm_buster_source_sha256=\".*\"/gitlab_arm_buster_source_sha256=\"$new_sha256\"/" $gitlab_directory/scripts/upgrade.d/$file
if [[ "$(basename $file)" == upgrade.last.sh ]]; then
# Update manifest
sed -i -e "s/\"version\": \"[^0-9.]*[0-9.]*[0-9.]~ynh[0-9.]\"/\"version\": \"$version~ynh1\"/" $gitlab_directory/manifest.json
# Update readme
sed -i -e "s/\*\*Shipped version:\*\* [^0-9.]*[0-9.]*[0-9.]/**Shipped version:** $version/" $gitlab_directory/README.md
sed -i -e "s/\*\*Version incluse :\*\* [^0-9.]*[0-9.]*[0-9.]/**Version incluse :** $version/" $gitlab_directory/README_fr.md
# Update gitlab.rb
conf_file=$gitlab_directory/conf/gitlab.rb
url=https://gitlab.com/gitlab-org/omnibus-gitlab/-/raw/$version+ce.0/files/gitlab-config-template/gitlab.rb.template
header="################################################################################
################################################################################
## FOR YUNOHOST USERS ##
################################################################################
################################################################################
# Please do not modify this file, it will be reset with the next update.
# You can create or modify the file:
# /etc/gitlab/gitlab-persistent.rb
# and add all the configuration you want.
# Options you add in gitlab-presistent.rb will overide these one,
# but you can use options and documentations in this file to know what
# is it possible to do.
################################################################################
################################################################################
"
footer="
from_file '/etc/gitlab/gitlab-persistent.rb'"
echo "$header" > $conf_file
curl -s "$url" >> $conf_file
echo "$footer" >> $conf_file
# Change external url
sed -i "s/external_url 'GENERATED_EXTERNAL_URL'/external_url '__GENERATED_EXTERNAL_URL__'/" $conf_file
# Activate ldap
sed -i "s/# gitlab_rails\['ldap_enabled'\] = .*/gitlab_rails['ldap_enabled'] = true/" $conf_file
ldap_conf="
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS' # remember to close this block with 'EOS' below
main: # 'main' is the GitLab 'provider ID' of this LDAP server
label: 'YunoHost LDAP'
host: 'localhost'
port: 389
uid: 'uid'
encryption: 'plain' # 'start_tls' or 'simple_tls' or 'plain'
bind_dn: 'ou=users,dc=yunohost,dc=org'
password: ''
active_directory: false
allow_username_or_email_login: false
block_auto_created_users: false
base: 'dc=yunohost,dc=org'
user_filter: '(&(objectClass=posixAccount)(permission=cn=gitlab.main,ou=permission,dc=yunohost,dc=org))'
EOS"
# Add ldap conf
sed -i "/^# EOS/r "<(echo "$ldap_conf") $conf_file
# Change ssh port
sed -i "s/# gitlab_rails\['gitlab_shell_ssh_port'\] = 22/gitlab_rails['gitlab_shell_ssh_port'] = __SSH_PORT__/" $conf_file
# Change puma settings
sed -i "s/# puma\['worker_processes'\] = .*/puma['worker_processes'] = __PUMA_WORKER_PROCESSES__/" $conf_file
sed -i "s/# puma\['min_threads'\] = .*/puma['min_threads'] = __PUMA_MIN_THREADS__/" $conf_file
sed -i "s/# puma\['max_threads'\] = .*/puma['max_threads'] = __PUMA_MAX_THREADS__/" $conf_file
sed -i "s/# puma\['port'\] = .*/puma['port'] = __PUMA_PORT__/" $conf_file
# Change sidekiq settings
sed -i "s/# sidekiq\['listen_port'\] = .*/sidekiq['listen_port'] = __SIDEKIQ_PORT__/" $conf_file
# Change nginx settings
sed -i "s/# nginx\['client_max_body_size'\] = .*/nginx['client_max_body_size'] = '__CLIENT_MAX_BODY_SIZE__'/" $conf_file
sed -i "s/# nginx\['listen_port'\] = .*/nginx['listen_port'] = __PORT__/" $conf_file
sed -i "s/# nginx\['listen_https'\] = .*/nginx['listen_https'] = false/" $conf_file
fi