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

Upgrade to 13.0.0

This commit is contained in:
Kay0u 2020-05-23 02:07:01 +02:00
parent ea67cf647f
commit 21c6f76ef2
No known key found for this signature in database
GPG key ID: AAFEEB16CFA2AE2D
5 changed files with 87 additions and 36 deletions

View file

@ -18,15 +18,16 @@ 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)
@ -61,25 +62,24 @@ 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_check_ram --no_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
@ -133,9 +133,17 @@ 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)
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
@ -214,8 +222,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"
@ -242,26 +252,42 @@ then
source ./upgrade.d/upgrade.last.sh source ./upgrade.d/upgrade.last.sh
last_version=$gitlab_version last_version=$gitlab_version
# 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" ]
do do
current_major_version=${current_version%%.*} current_major_version=${current_version%%.*}
source ./upgrade.d/upgrade.$current_major_version.sh 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
fi
# if the version stored in the upgrade.$current_major_version.sh file is less than or equal # if the version stored in the upgrade.$current_major_version.first.sh file is less than or equal
# to the current version, increment the major version to upgrade to the next version # 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 dpkg --compare-versions "$gitlab_version" "le" "$current_version"; then
current_major_version=$(($current_major_version + 1)) 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))
fi
fi fi
# Finish with the last migration if the file doesn't exist # Finish with the last migration if the file doesn't exist
if [ ! -e "./upgrade.d/upgrade.$current_major_version.sh" ]; then if [ ! -e "./upgrade.d/upgrade.$current_major_version.first.sh" ] && [ ! -e "./upgrade.d/upgrade.$current_major_version.last.sh" ]; then
current_major_version=last source ./upgrade.d/upgrade.last.sh
fi 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"
@ -307,7 +333,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"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
@ -327,7 +353,7 @@ 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
#================================================= #=================================================

View file

@ -0,0 +1,25 @@
gitlab_version="12.10.6"
# sha256sum found here: https://packages.gitlab.com/gitlab
gitlab_x86_64_debian_version="$(lsb_release -sc)"
if [ "$gitlab_x86_64_debian_version" = "buster" ]
then
gitlab_x86_64_source_sha256="8305869246a70fb033fda3ba533f7b3459e7a044c0777dbc0215d868d73a22e6"
else
gitlab_x86_64_source_sha256="f7c5a76bbb3cd192328be09832cce81d85847f22e97677c46087d5d1b8234cba"
fi
gitlab_arm_source_sha256="2e44c2c96cb6f381565f68814657b2ac73f11609601d16d4de6c539a53bb358f"
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,4 +1,4 @@
gitlab_version="12.10.3" gitlab_version="13.0.0"
# sha256sum found here: https://packages.gitlab.com/gitlab # sha256sum found here: https://packages.gitlab.com/gitlab
@ -6,12 +6,12 @@ gitlab_x86_64_debian_version="$(lsb_release -sc)"
if [ "$gitlab_x86_64_debian_version" = "buster" ] if [ "$gitlab_x86_64_debian_version" = "buster" ]
then then
gitlab_x86_64_source_sha256="dcb8b3b770aa7645f6485d877915e4075da214185f631560df270cfe6de89f0d" gitlab_x86_64_source_sha256="4322ea81b30118a1616765abf34bf6ed9442675bac91d027babfc31d97938fe9"
else else
gitlab_x86_64_source_sha256="f25c1b15a64eb74209185074363f58cc9082102210c7ef7434a6c82f39b1ffb6" gitlab_x86_64_source_sha256="71bf1a95739f78131eb23e016d663e18954758d00a8960ec811067287e5bd797"
fi fi
gitlab_arm_source_sha256="898bd6492f04846113babe7db95b82dfcf1cf6974fe63482231d8a723e2928fb" gitlab_arm_source_sha256="bb98a9a282c3c712abc4f5f45d761e949a0347afd9288cfd24ce7529182de30e"
gitlab_filename="gitlab-ce-${gitlab_version}.deb" gitlab_filename="gitlab-ce-${gitlab_version}.deb"