From 003ff5534128bc15273eca0b04d8a03eb33cfbbf Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 27 Dec 2023 23:30:00 +0100 Subject: [PATCH] WIP gitlab pages --- conf/gitlab.rb | 15 ++++++++++----- manifest.toml | 10 ++++++++++ scripts/install | 13 ++++++++++++- scripts/remove | 2 ++ scripts/restore | 2 +- scripts/upgrade | 2 +- upgrade-versions.sh | 19 ++++++++++++------- 7 files changed, 48 insertions(+), 15 deletions(-) diff --git a/conf/gitlab.rb b/conf/gitlab.rb index f254655..2f353d3 100644 --- a/conf/gitlab.rb +++ b/conf/gitlab.rb @@ -1892,8 +1892,8 @@ nginx['listen_https'] = false ################################################################################ ##! Define to enable GitLab Pages -# pages_external_url "http://pages.example.com/" -# gitlab_pages['enable'] = false +pages_external_url "https://__PAGES_URL__/" +gitlab_pages['enable'] = __PAGES_ENABLE__ ##! Configure to expose GitLab Pages on external IP address, serving the HTTP # gitlab_pages['external_http'] = [] @@ -1939,7 +1939,7 @@ nginx['listen_https'] = false # gitlab_pages['sentry_environment'] = 'production' ##! Listen for requests forwarded by reverse proxy -# gitlab_pages['listen_proxy'] = "localhost:8090" +gitlab_pages['listen_proxy'] = "localhost:__PORT_PAGES__" # gitlab_pages['redirect_http'] = true # gitlab_pages['use_http2'] = true @@ -2070,7 +2070,7 @@ nginx['listen_https'] = false # } # Experimental - Enable namespace in path -# gitlab_pages['namespace_in_path'] = false +gitlab_pages['namespace_in_path'] = true ################################################################################ ## GitLab Pages NGINX @@ -2083,7 +2083,12 @@ nginx['listen_https'] = false # `pages_nginx['some_setting']` and should be set separately. # Below you can find settings that are exclusive to "GitLab Pages NGINX" -# pages_nginx['enable'] = true +pages_nginx['enable'] = true + +pages_nginx['listen_https'] = false +pages_nginx['listen_http'] = true +pages_nginx['listen_port'] = __PORT_NGINX_PAGES__ +pages_nginx['listen_addresses'] = ['127.0.0.1'] # gitlab_rails['pages_path'] = "/var/opt/gitlab/gitlab-rails/shared/pages" diff --git a/manifest.toml b/manifest.toml index 2dce68c..8e9cb42 100644 --- a/manifest.toml +++ b/manifest.toml @@ -53,6 +53,14 @@ ram.runtime = "2000M" type = "boolean" default = false + [install.pages_enable] + type = "boolean" + default = false + + [install.pages_url] + type = "domain" + optional = true + [resources] # [resources.sources] # [resources.sources.main] @@ -77,6 +85,8 @@ ram.runtime = "2000M" main.default = 8080 puma.default = 8081 sidekiq.default = 8082 + pages.default = 8083 + nginx_pages.default = 8084 [resources.apt] packages = "openssh-server" diff --git a/scripts/install b/scripts/install index 3207bcb..cfeebad 100644 --- a/scripts/install +++ b/scripts/install @@ -33,6 +33,14 @@ fi # Could be an option? client_max_body_size="250m" +# Remove https and http from page_url +# sets extended pattern matching options in the bash shell +shopt -s extglob +pages_url=${pages_url#http?(s)://} +shopt -u extglob +# Remove trailing / +pages_url=${pages_url%/} + #================================================= # STORE SETTINGS FROM MANIFEST #================================================= @@ -121,6 +129,9 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config client_max_body_size +# TODO: Get the app id, to be able to remove the right app in the remove scrip +yunohost app install redirect --label gitlab-pages --args "domain=$pages_url&path=/&redirect_type=public_proxy&redirect_path=http://127.0.0.1:$port_nginx_pages" + #================================================= # SPECIFIC SETUP #================================================= @@ -154,7 +165,7 @@ usermod -a -G "ssh.app" "git" # 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/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" +yunohost service add "gitlab-runsvdir" --log "/var/log/$app/alertmanager/current" "/var/log/$app/gitaly/current" "/var/log/$app/gitlab-exporter/current" "/var/log/$app/gitlab-kas/current" "/var/log/$app/gitlab-pages/current" "/var/log/$app/gitlab-rails/api_json.log" "/var/log/$app/gitlab-rails/application.log" "/var/log/$app/gitlab-rails/application_json.log" "/var/log/$app/gitlab-rails/audit_json.log" "/var/log/$app/gitlab-rails/auth.log" "/var/log/$app/gitlab-rails/database_load_balancing.log" "/var/log/$app/gitlab-rails/exceptions_json.log" "/var/log/$app/gitlab-rails/graphql_json.log" "/var/log/$app/gitlab-rails/grpc.log" "/var/log/$app/gitlab-rails/importer.log" "/var/log/$app/gitlab-rails/production.log" "/var/log/$app/gitlab-rails/production_json.log" "/var/log/$app/gitlab-rails/service_measurement.log" "/var/log/$app/gitlab-rails/sidekiq.log" "/var/log/$app/gitlab-rails/sidekiq_client.log" "/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/nginx/gitlab_pages_access.log" "/var/log/$app/nginx/gitlab_pages_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/puma/current" "/var/log/$app/puma/puma_stdout.log" "/var/log/$app/puma/puma_stderr.log" "/var/log/$app/redis/current" "/var/log/$app/redis-exporter/current" "/var/log/$app/sidekiq/current" #================================================= # RELOAD NGINX diff --git a/scripts/remove b/scripts/remove index 0ec93c2..ad59081 100644 --- a/scripts/remove +++ b/scripts/remove @@ -51,6 +51,8 @@ ynh_script_progression --message="Removing NGINX web server configuration" --wei # Remove the dedicated NGINX config ynh_remove_nginx_config +yunohost app remove redirect + #================================================= # SPECIFIC REMOVE #================================================= diff --git a/scripts/restore b/scripts/restore index cb9b69e..cc69317 100644 --- a/scripts/restore +++ b/scripts/restore @@ -97,7 +97,7 @@ fi # 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/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" +yunohost service add "gitlab-runsvdir" --log "/var/log/$app/alertmanager/current" "/var/log/$app/gitaly/current" "/var/log/$app/gitlab-exporter/current" "/var/log/$app/gitlab-kas/current" "/var/log/$app/gitlab-pages/current" "/var/log/$app/gitlab-rails/api_json.log" "/var/log/$app/gitlab-rails/application.log" "/var/log/$app/gitlab-rails/application_json.log" "/var/log/$app/gitlab-rails/audit_json.log" "/var/log/$app/gitlab-rails/auth.log" "/var/log/$app/gitlab-rails/database_load_balancing.log" "/var/log/$app/gitlab-rails/exceptions_json.log" "/var/log/$app/gitlab-rails/graphql_json.log" "/var/log/$app/gitlab-rails/grpc.log" "/var/log/$app/gitlab-rails/importer.log" "/var/log/$app/gitlab-rails/production.log" "/var/log/$app/gitlab-rails/production_json.log" "/var/log/$app/gitlab-rails/service_measurement.log" "/var/log/$app/gitlab-rails/sidekiq.log" "/var/log/$app/gitlab-rails/sidekiq_client.log" "/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/nginx/gitlab_pages_access.log" "/var/log/$app/nginx/gitlab_pages_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/puma/current" "/var/log/$app/puma/puma_stdout.log" "/var/log/$app/puma/puma_stderr.log" "/var/log/$app/redis/current" "/var/log/$app/redis-exporter/current" "/var/log/$app/sidekiq/current" #================================================= # WAITING GITLAB diff --git a/scripts/upgrade b/scripts/upgrade index c87e646..4405293 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -304,7 +304,7 @@ fi # 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/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" +yunohost service add "gitlab-runsvdir" --log "/var/log/$app/alertmanager/current" "/var/log/$app/gitaly/current" "/var/log/$app/gitlab-exporter/current" "/var/log/$app/gitlab-kas/current" "/var/log/$app/gitlab-pages/current" "/var/log/$app/gitlab-rails/api_json.log" "/var/log/$app/gitlab-rails/application.log" "/var/log/$app/gitlab-rails/application_json.log" "/var/log/$app/gitlab-rails/audit_json.log" "/var/log/$app/gitlab-rails/auth.log" "/var/log/$app/gitlab-rails/database_load_balancing.log" "/var/log/$app/gitlab-rails/exceptions_json.log" "/var/log/$app/gitlab-rails/graphql_json.log" "/var/log/$app/gitlab-rails/grpc.log" "/var/log/$app/gitlab-rails/importer.log" "/var/log/$app/gitlab-rails/production.log" "/var/log/$app/gitlab-rails/production_json.log" "/var/log/$app/gitlab-rails/service_measurement.log" "/var/log/$app/gitlab-rails/sidekiq.log" "/var/log/$app/gitlab-rails/sidekiq_client.log" "/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/nginx/gitlab_pages_access.log" "/var/log/$app/nginx/gitlab_pages_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/puma/current" "/var/log/$app/puma/puma_stdout.log" "/var/log/$app/puma/puma_stderr.log" "/var/log/$app/redis/current" "/var/log/$app/redis-exporter/current" "/var/log/$app/sidekiq/current" #================================================= # WAITING GITLAB diff --git a/upgrade-versions.sh b/upgrade-versions.sh index 9829b4d..462c1da 100755 --- a/upgrade-versions.sh +++ b/upgrade-versions.sh @@ -125,19 +125,24 @@ EOS" 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 + 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\['port'\] = .*/puma['port'] = __PORT_PUMA__/" $conf_file + sed -i "s/^# puma\['port'\] = .*/puma['port'] = __PORT_PUMA__/" $conf_file # Change sidekiq settings - sed -i "s/# sidekiq\['listen_port'\] = .*/sidekiq['listen_port'] = __PORT_SIDEKIQ__/" $conf_file + sed -i "s/^# sidekiq\['listen_port'\] = .*/sidekiq['listen_port'] = __PORT_SIDEKIQ__/" $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 + 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 # Change modify kernel parameters settings - sed -i "s/# package\['modify_kernel_parameters'\] = .*/package['modify_kernel_parameters'] = __MODIFY_KERNEL_PARAMETERS__/" $conf_file + sed -i "s/^# package\['modify_kernel_parameters'\] = .*/package['modify_kernel_parameters'] = __MODIFY_KERNEL_PARAMETERS__/" $conf_file + + # Change the gitlab page settings + sed -i "s/^# pages_external_url \".*\"/pages_external_url \"__PAGES_URL__\"/" $conf_file + sed -i "s/^# gitlab_pages\['enable'\] = .*/gitlab_pages\['enable'\] = __PAGES_ENABLE__/" $conf_file + sed -i "s/^# gitlab_pages\['namespace_in_path'\] = .*/gitlab_pages\['namespace_in_path'\] = true/" $conf_file fi