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

Merge pull request #42 from YunoHost-Apps/testing

Testing
This commit is contained in:
Kayou 2019-04-13 12:42:52 +02:00 committed by GitHub
commit 68f5a27e6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 2439 additions and 32 deletions

View file

@ -10,7 +10,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to
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:** 11.9.4
**Shipped version:** 11.9.8
## Screenshots

46
actions.json Normal file
View file

@ -0,0 +1,46 @@
[
{
"id": "public_private",
"name": "Move to public or private",
"command": "/bin/bash scripts/actions/public_private",
"user": "root",
"accepted_return_codes": [
0
],
"description": {
"en": "Change the public access of the app."
},
"arguments": [
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public app ?"
},
"default": true
}
]
},
{
"id": "web_account",
"name": "External users",
"command": "/bin/bash scripts/actions/web_account",
"user": "root",
"accepted_return_codes": [
0
],
"description": {
"en": "Allow user to be created without yunohost account."
},
"arguments": [
{
"name": "use_web_account",
"type": "boolean",
"ask": {
"en": "Authorized external user creation ?"
},
"default": true
}
]
}
]

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,10 @@
location __PATH__/ {
proxy_pass http://localhost:__PORT__;
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__;

57
config_panel.json Normal file
View file

@ -0,0 +1,57 @@
{
"name": "GitLab configuration panel",
"version": "0.1",
"panel": [
{
"name": "GitLab configuration",
"id": "main",
"sections": [
{
"name": "Public access",
"id": "is_public",
"options": [
{
"name": "Is it a public app ?",
"id": "is_public",
"type": "bool",
"default": true
}
]
},
{
"name": "Overwriting config files",
"id": "overwrite_files",
"options": [
{
"name": "Overwrite the nginx config file ?",
"help": "If the file is overwritten, a backup will be created.",
"id": "overwrite_nginx",
"type": "bool",
"default": true
},
{
"name": "Overwrite the gitlab.rb config file ?",
"help": "If the file is overwritten, a backup will be created.",
"id": "overwrite_gitlab_config",
"type": "bool",
"default": true
}
]
},
{
"name": "External users",
"id": "users",
"options": [
{
"name": "Authorized external user creation ?",
"help": "Allow user to be created without yunohost account.",
"id": "use_web_account",
"type": "bool",
"default": true
}
]
}
]
}
]
}

View file

@ -2,7 +2,7 @@
"name": "Gitlab",
"id": "gitlab",
"packaging_format": 1,
"version": "11.9.4~ynh1",
"version": "11.9.8~ynh1",
"description": {
"en": "GitLab is a Git-repository manager.",
"fr": "GitLab est un gestionnaire de dépôts Git."

View file

@ -14,6 +14,24 @@ IS_PACKAGE_CHECK () {
return $(env | grep -c container=lxc)
}
#=================================================
# BOOLEAN CONVERTER
#=================================================
bool_to_01 () {
local var="$1"
[ "$var" = "true" ] && var=1
[ "$var" = "false" ] && var=0
echo "$var"
}
bool_to_true_false () {
local var="$1"
[ "$var" = "1" ] && var=true
[ "$var" = "0" ] && var=false
echo "$var"
}
#=================================================
# WAIT
#=================================================

View file

@ -0,0 +1,74 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
# Get is_public
is_public=${YNH_ACTION_IS_PUBLIC}
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
#=================================================
# CHECK IF ARGUMENTS ARE CORRECT
#=================================================
#=================================================
# CHECK IF AN ACTION HAS TO BE DONE
#=================================================
is_public_old=$(ynh_app_setting_get $app is_public)
if [ $is_public -eq $is_public_old ]
then
ynh_die "is_public is already set as $is_public." 0
fi
#=================================================
# SPECIFIC ACTION
#=================================================
# MOVE TO PUBLIC OR PRIVATE
#=================================================
if [ $is_public -eq 0 ]; then
public_private="private"
else
public_private="public"
fi
ynh_print_info --message="Moving the application to $public_private..."
# Make app public if necessary
if [ $is_public -eq 0 ]; then
ynh_app_setting_delete $app unprotected_uris
else
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set $app unprotected_uris "/"
fi
ynh_print_info --message="Reconfiguring SSOwat..."
# Regen ssowat configuration
yunohost app ssowatconf
# Update the config of the app
ynh_app_setting_set $app is_public $is_public
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info --message="Reloading nginx web server..."
ynh_systemd_action --action=reload --service_name=nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Execution completed"

View file

@ -0,0 +1,57 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
# Get use_web_account
use_web_account=${YNH_ACTION_USE_WEB_ACCOUNT}
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
#=================================================
# CHECK IF ARGUMENTS ARE CORRECT
#=================================================
#=================================================
# CHECK IF AN ACTION HAS TO BE DONE
#=================================================
use_web_account_old=$(ynh_app_setting_get $app use_web_account)
if [ $use_web_account -eq $use_web_account_old ]
then
ynh_die "use_web_account is already set as $use_web_account." 0
fi
#=================================================
# SPECIFIC ACTION
#=================================================
# SET USER CREATION POLICY
#=================================================
if [ $use_web_account -eq 0 ]; then
web_account="Enable"
else
web_account="Disable"
fi
ynh_print_info --message="$web_account web user creation..."
echo "ApplicationSetting.last.update_attributes(password_authentication_enabled_for_web: $use_web_account, signup_enabled: $use_web_account)" | gitlab-rails console
# Update the config of the app
ynh_app_setting_set $app use_web_account $use_web_account
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Execution completed"

View file

@ -31,6 +31,7 @@ final_path=$(ynh_app_setting_get $app final_path)
config_path=$(ynh_app_setting_get $app config_path)
port=$(ynh_app_setting_get "$app" web_port)
portUnicorn=$(ynh_app_setting_get "$app" unicorn_port)
portSidekiq=$(ynh_app_setting_get "$app" sidekiq_port)
unicorn_worker_processes=$(ynh_app_setting_get "$app" unicorn_worker_processes)
client_max_body_size=$(ynh_app_setting_get "$app" client_max_body_size)
@ -106,15 +107,18 @@ ynh_backup_if_checksum_is_different "$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+")
domain="$new_domain"
path_url="$new_path"
ynh_replace_string "__GENERATED_EXTERNAL_URL__" "https://$domain${path_url%/}" "$config_path/gitlab.rb"
ynh_replace_string "__PORT__" "$port" "$config_path/gitlab.rb"
ynh_replace_string "__PORTUNICORN__" "$portUnicorn" "$config_path/gitlab.rb"
ynh_replace_string "__UNICORN_PORT__" "$portUnicorn" "$config_path/gitlab.rb"
ynh_replace_string "__UNICORN_WORKER_PROCESSES__" "$unicorn_worker_processes" "$config_path/gitlab.rb"
ynh_replace_string "__CLIENT_MAX_BODY_SIZE__" "$client_max_body_size" "$config_path/gitlab.rb"
ynh_replace_string "__SSH_PORT__" "$ssh_port" "$config_path/gitlab.rb"
ynh_replace_string "__SIDEKIQ_PORT__" "$portSidekiq" "$config_path/gitlab.rb"
ynh_store_file_checksum "$config_path/gitlab.rb"

100
scripts/config Normal file
View file

@ -0,0 +1,100 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
#=================================================
# LOAD VALUES
#=================================================
# Load the real value from the app config or elsewhere.
# Then get the value from the form.
# If the form has a value for a variable, take the value from the form,
# Otherwise, keep the value from the app config.
# is_public
old_is_public="$(ynh_app_setting_get $app is_public)"
old_is_public=$(bool_to_true_false $old_is_public)
is_public="${YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC:-$old_is_public}"
# Overwrite nginx configuration
old_overwrite_nginx="$(ynh_app_setting_get $app overwrite_nginx)"
old_overwrite_nginx=$(bool_to_true_false $old_overwrite_nginx)
overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}"
# Overwrite gitlab.rb configuration
old_overwrite_gitlab_config="$(ynh_app_setting_get $app overwrite_gitlab_config)"
old_overwrite_gitlab_config=$(bool_to_true_false $old_overwrite_gitlab_config)
overwrite_gitlab_config="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_GITLAB_CONFIG:-$old_overwrite_gitlab_config}"
# use_web_account
old_use_web_account="$(ynh_app_setting_get $app use_web_account)"
old_use_web_account=$(bool_to_true_false $old_use_web_account)
use_web_account="${YNH_CONFIG_MAIN_USERS_USE_WEB_ACCOUNT:-$old_use_web_account}"
#=================================================
# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND
#=================================================
show_config() {
# here you are supposed to read some config file/database/other then print the values
# echo "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
echo "YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC=$is_public"
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_GITLAB_CONFIG=$overwrite_gitlab_config"
echo "YNH_CONFIG_MAIN_USERS_USE_WEB_ACCOUNT=$use_web_account"
}
#=================================================
# MODIFY THE CONFIGURATION
#=================================================
apply_config() {
# Change public accessibility
if [ "$is_public" = "true" ]
then
yunohost app action run $app public_private --args is_public=1
else
yunohost app action run $app public_private --args is_public=0
fi
# Change use_web_account
if [ "$use_web_account" = "true" ]
then
yunohost app action run $app web_account --args use_web_account=1
else
yunohost app action run $app web_account --args use_web_account=0
fi
# Set overwrite_nginx
ynh_app_setting_set $app overwrite_nginx "$overwrite_nginx"
# Set overwrite_gitlab_config
ynh_app_setting_set $app overwrite_gitlab_config "$overwrite_gitlab_config"
}
#=================================================
# GENERIC FINALIZATION
#=================================================
# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT
#=================================================
case $1 in
show) show_config;;
apply) apply_config;;
esac

View file

@ -89,22 +89,24 @@ ynh_app_setting_set $app architecture $architecture
ynh_app_setting_set $app unicorn_worker_processes $unicorn_worker_processes
ynh_app_setting_set $app client_max_body_size $client_max_body_size
ynh_app_setting_set $app overwrite_nginx "1"
ynh_app_setting_set $app overwrite_gitlab_config "1"
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
# FIND A PORT
#=================================================
ynh_print_info "Configuring firewall..."
ynh_print_info "Find internal port..."
# Find free ports
port=$(ynh_find_port 8080)
portUnicorn=$(ynh_find_port $(($port + 1)))
portSidekiq=$(ynh_find_port $(($portUnicorn + 1)))
# Open these port
yunohost firewall allow --no-upnp TCP $port 2>&1
yunohost firewall allow --no-upnp TCP $portUnicorn 2>&1
ynh_app_setting_set $app web_port $port
ynh_app_setting_set $app unicorn_port $portUnicorn
ynh_app_setting_set $app sidekiq_port $portSidekiq
#=================================================
# INSTALL DEPENDENCIES
@ -121,12 +123,15 @@ ynh_print_info "Preconfigure gitlab..."
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 "__GENERATED_EXTERNAL_URL__" "https://$domain${path_url%/}" "$config_path/gitlab.rb"
ynh_replace_string "__PORT__" "$port" "$config_path/gitlab.rb"
ynh_replace_string "__PORTUNICORN__" "$portUnicorn" "$config_path/gitlab.rb"
ynh_replace_string "__UNICORN_PORT__" "$portUnicorn" "$config_path/gitlab.rb"
ynh_replace_string "__UNICORN_WORKER_PROCESSES__" "$unicorn_worker_processes" "$config_path/gitlab.rb"
ynh_replace_string "__CLIENT_MAX_BODY_SIZE__" "$client_max_body_size" "$config_path/gitlab.rb"
ynh_replace_string "__SSH_PORT__" "$ssh_port" "$config_path/gitlab.rb"
ynh_replace_string "__SIDEKIQ_PORT__" "$portSidekiq" "$config_path/gitlab.rb"
#=================================================
# STORE THE CONFIG FILE CHECKSUM

View file

@ -77,6 +77,7 @@ ynh_remove_nginx_config
# CLOSE A PORT
#=================================================
# These ports are no longer open but were in previous versions
if yunohost firewall list | grep -q "\- $port$"; then
ynh_print_info "Closing port $port"
ynh_exec_warn_less yunohost firewall disallow TCP $port

View file

@ -27,9 +27,12 @@ final_path=$(ynh_app_setting_get $app final_path)
config_path=$(ynh_app_setting_get $app config_path)
port=$(ynh_app_setting_get "$app" web_port)
portUnicorn=$(ynh_app_setting_get "$app" unicorn_port)
portSidekiq=$(ynh_app_setting_get "$app" sidekiq_port)
architecture=$(ynh_app_setting_get "$app" architecture)
unicorn_worker_processes=$(ynh_app_setting_get "$app" unicorn_worker_processes)
client_max_body_size=$(ynh_app_setting_get "$app" client_max_body_size)
overwrite_nginx=$(ynh_app_setting_get "$app" overwrite_nginx)
overwrite_gitlab_config=$(ynh_app_setting_get "$app" overwrite_gitlab_config)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
@ -71,6 +74,12 @@ if [ -z "$unicorn_worker_processes" ]; then
ynh_app_setting_set $app unicorn_worker_processes $unicorn_worker_processes
fi
if [ -z "$portSidekiq" ]; then
portSidekiq=$(ynh_find_port $(($portUnicorn + 1)))
ynh_app_setting_set $app sidekiq_port $portSidekiq
fi
# If architecture doesn't exist, create it
if [ -z "$architecture" ]; then
# Detect the system architecture
@ -92,6 +101,18 @@ if [ -z "$client_max_body_size" ]; then
client_max_body_size="250m"
fi
# If overwrite_nginx doesn't exist, create it
if [ -z "$overwrite_nginx" ]; then
overwrite_nginx=1
ynh_app_setting_set $app overwrite_nginx $overwrite_nginx
fi
# If overwrite_gitlab_config doesn't exist, create it
if [ -z "$overwrite_gitlab_config" ]; then
overwrite_gitlab_config=1
ynh_app_setting_set $app overwrite_gitlab_config $overwrite_gitlab_config
fi
# If domain doesn't exist, retrieve it
if [ -z "$domain" ]; then
domain=$(grep "external_url" "/etc/gitlab/gitlab.rb" | cut -d'/' -f3) # retrieve $domain from conf file
@ -162,6 +183,10 @@ ynh_install_app_dependencies $pkg_dependencies
#=================================================
# PRECONFIGURE GITLAB
#=================================================
# Overwrite the gitlab.rb configuration only if it's allowed
if [ $overwrite_gitlab_config -eq 1 ]
then
ynh_print_info "Preconfigure gitlab..."
ynh_backup_if_checksum_is_different "$config_path/gitlab.rb"
@ -169,14 +194,18 @@ ynh_backup_if_checksum_is_different "$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 "__GENERATED_EXTERNAL_URL__" "https://$domain${path_url%/}" "$config_path/gitlab.rb"
ynh_replace_string "__PORT__" "$port" "$config_path/gitlab.rb"
ynh_replace_string "__PORTUNICORN__" "$portUnicorn" "$config_path/gitlab.rb"
ynh_replace_string "__UNICORN_PORT__" "$portUnicorn" "$config_path/gitlab.rb"
ynh_replace_string "__UNICORN_WORKER_PROCESSES__" "$unicorn_worker_processes" "$config_path/gitlab.rb"
ynh_replace_string "__CLIENT_MAX_BODY_SIZE__" "$client_max_body_size" "$config_path/gitlab.rb"
ynh_replace_string "__SSH_PORT__" "$ssh_port" "$config_path/gitlab.rb"
ynh_replace_string "__SIDEKIQ_PORT__" "$portSidekiq" "$config_path/gitlab.rb"
ynh_store_file_checksum "$config_path/gitlab.rb"
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -214,10 +243,14 @@ fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Configuring nginx web server..."
# Overwrite the nginx configuration only if it's allowed
if [ $overwrite_nginx -eq 1 ]
then
ynh_print_info "Configuring nginx web server..."
# Create a dedicated nginx config
ynh_add_nginx_config client_max_body_size
fi
#=================================================
# GENERIC FINALIZATION

View file

@ -0,0 +1,7 @@
gitlab_version="11.9.4"
gitlab_x86_64_source_sha256="20963cd803b116d041795f50c607ddf837e7226bc46025997348fe1c2e5e35ca"
gitlab_arm_source_sha256="dba6f34b23ba74765b03ce9521b16a5e951e6bd6d1f2fdcce692a58f43a4c48b"
gitlab_filename="gitlab-ce-${gitlab_version}.deb"

View file

@ -1,7 +1,7 @@
gitlab_version="11.9.4"
gitlab_version="11.9.8"
gitlab_x86_64_source_sha256="20963cd803b116d041795f50c607ddf837e7226bc46025997348fe1c2e5e35ca"
gitlab_x86_64_source_sha256="bb81616deeb92a4abf129373a4e6c9d246b37ad1ea707328efeec2fc0a07fc2a"
gitlab_arm_source_sha256="dba6f34b23ba74765b03ce9521b16a5e951e6bd6d1f2fdcce692a58f43a4c48b"
gitlab_arm_source_sha256="1810be6f6780a700624343b976eace277ac6aefce51ec4341f549f7642be620f"
gitlab_filename="gitlab-ce-${gitlab_version}.deb"