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

Add action and config

This commit is contained in:
Kayou 2019-04-11 01:12:07 +02:00
parent 5ea9683dbc
commit 60dac31d9e
No known key found for this signature in database
GPG key ID: 823A2CBE071D3126
5 changed files with 320 additions and 0 deletions

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
}
]
}
]

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": "boolean",
"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": "boolean",
"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": "boolean",
"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": "boolean",
"default": true
}
]
}
]
}
]
}

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"

86
scripts/config Normal file
View file

@ -0,0 +1,86 @@
#!/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)"
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)"
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)"
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)"
use_web_account="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_html}"
#=================================================
# 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
yunohost app action run $app public_private --args $is_public
# Change use_web_account
yunohost app action run $app web_account --args $use_web_account
# 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