Create app to check the permissions

This commit is contained in:
Josué Tille 2018-12-30 15:58:45 +01:00
parent d876bbcfb2
commit 65fff6b2c6
No known key found for this signature in database
GPG key ID: D5E068C6DFA8681D
5 changed files with 109 additions and 0 deletions

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,46 @@
{
"name": "Permissions Test",
"id": "permissions_app",
"description": {
"en": "Dummy app to test permissions"
},
"license": "GPL-3+",
"license": "Apache-2.0",
"maintainer": {
"name": "Josué Tille",
"email": "josue@tille.ch"
},
"requirements": {
"yunohost": ">> 3.3.0"
},
"multi_instance": false,
"arguments": {
"install" : [
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain for permissions_app"
},
"example": "domain.org"
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for permissions_app"
},
"example": "/permissions_app",
"default": "/permissions_app"
},
{
"name": "admin",
"type": "user",
"ask": {
"en": "Chose a admin"
},
"example": "johndoe"
}
]
}
}

View file

@ -0,0 +1,24 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Stop script if errors
ynh_abort_if_errors
# Retrive arguments
app=$YNH_APP_INSTANCE_NAME
old_domain=$YNH_APP_OLD_DOMAIN
old_path_url=$(ynh_normalize_url_path ${YNH_APP_OLD_PATH})
domain=$YNH_APP_NEW_DOMAIN
path_url=$(ynh_normalize_url_path ${YNH_APP_NEW_PATH})
ynh_permission_del_path --app $app --permission "admin" --url "$old_domain$old_path_url/admin"
ynh_permission_del_path --app $app --permission "dev" --url "$old_domain$old_path_url/dev"
ynh_permission_add_path --app $app --permission "admin" --url "$domain$path_url/admin"
ynh_permission_add_path --app $app --permission "dev" --url "$domain$path_url/dev"

View file

@ -0,0 +1,27 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Stop script if errors
ynh_abort_if_errors
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN
path_url=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
admin_user=$YNH_APP_ARG_ADMIN
# Check domain/path availability
ynh_webpath_available $domain $path_url || ynh_die "$domain$path_url is not available, please use an other domain or path."
ynh_webpath_register $app $domain $path_url
ynh_permission_create --app $app --permission "admin" --defaultdisallow --url "$domain$path_url/admin"
yunohost user permission add $app -p "admin" -u $admin_user
ynh_permission_create --app $app --permission "dev"
ynh_permission_add_path --app $app --permission "dev" --url "$domain$path_url/dev"

View file

@ -0,0 +1,11 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Stop script if errors
ynh_abort_if_errors