test_apps/permissions_app_ynh/scripts/install
Josué Tille 7b967f473d
Add more test for permission helper
- Add more test of helper 'ynh_permission_update'
- Add test of permission protection feature
2019-12-27 15:49:33 +01:00

36 lines
1.2 KiB
Bash

#!/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
is_public=$YNH_APP_ARG_IS_PUBLIC
ynh_app_setting_set --app $app --key admin_user --value $admin_user
# 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 --permission "admin" --url "/admin" --allowed "$admin_user" --protected true
ynh_permission_create --permission "dev" --url "/dev" --protected false
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring SSOwat..." --weight=1
# Make app public if necessary or protect it
[ $is_public -eq 0 ] || ynh_permission_update --permission "main" --add "visitors"