mirror of
https://github.com/YunoHost-Apps/gitlab_ynh.git
synced 2024-09-03 18:36:35 +02:00
Use new permission system
This commit is contained in:
parent
3e14ddf52a
commit
872e308bc2
7 changed files with 4 additions and 125 deletions
22
actions.json
22
actions.json
|
@ -1,26 +1,4 @@
|
|||
[
|
||||
{
|
||||
"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",
|
||||
|
|
|
@ -6,20 +6,6 @@
|
|||
"name": "GitLab configuration",
|
||||
"id": "main",
|
||||
"sections": [
|
||||
{
|
||||
"name": "Public access",
|
||||
"id": "is_public",
|
||||
"options": [
|
||||
{
|
||||
"name": "is_public",
|
||||
"ask": {
|
||||
"en": "Is it a public app ?"
|
||||
},
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Overwriting config files",
|
||||
"id": "overwrite_files",
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"email": "pierre@kayou.io"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.6.0"
|
||||
"yunohost": ">= 3.7.0"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
#!/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=$app --key=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_script_progression --message=--message="Moving the application to $public_private..." --weight=1
|
||||
|
||||
# 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=$app --key=unprotected_uris --value="/"
|
||||
fi
|
||||
|
||||
ynh_script_progression --message=--message="Reconfiguring SSOwat..." --weight=1
|
||||
# Regen ssowat configuration
|
||||
yunohost app ssowatconf
|
||||
|
||||
# Update the config of the app
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message=--message="Reloading nginx web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Execution completed" --last
|
|
@ -25,10 +25,6 @@ app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
|||
# 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=$app --key=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=$app --key=overwrite_nginx)"
|
||||
overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}"
|
||||
|
@ -70,8 +66,6 @@ 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"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC=$is_public"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_USERS_USE_WEB_ACCOUNT=$use_web_account"
|
||||
|
@ -98,9 +92,6 @@ show_config() {
|
|||
#=================================================
|
||||
|
||||
apply_config() {
|
||||
# Change public accessibility
|
||||
yunohost app action run $app public_private --args is_public=$is_public
|
||||
|
||||
# Change use_web_account
|
||||
yunohost app action run $app web_account --args use_web_account=$use_web_account
|
||||
|
||||
|
|
|
@ -253,8 +253,7 @@ ynh_script_progression --message="Configuring SSOwat..." --weight=1
|
|||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]; then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||
ynh_permission_update --permission "main" --remove "all_users" --add "visitors"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -356,10 +356,9 @@ yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/applica
|
|||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
|
||||
# If app is public, add url to SSOWat conf as skipped_uris
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]; then
|
||||
# See install script
|
||||
ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/"
|
||||
ynh_permission_update --permission "main" --remove "all_users" --add "visitors"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue