mirror of
https://github.com/YunoHost-Apps/snserver_ynh.git
synced 2024-09-03 20:26:22 +02:00
Add config-panel feature
This commit is contained in:
parent
4ad8116a0b
commit
dcc52cea2d
6 changed files with 92 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
Standard Notes - Syncing Server was successfully __TYPE__.
|
||||
Please configure the Standard Notes web app or mobile app to use this syninc server: https://__DOMAIN____PATH_URL__/
|
||||
__ACTION__
|
||||
__CONFIG_PANEL__
|
||||
__EXTENSIONS__
|
||||
|
|
14
config_panel.toml
Normal file
14
config_panel.toml
Normal file
|
@ -0,0 +1,14 @@
|
|||
version = "1.0"
|
||||
name = "SNServer configuration panel"
|
||||
|
||||
[main]
|
||||
name = "SNserver configuration"
|
||||
|
||||
[main.access_domain]
|
||||
name = "Access Domain"
|
||||
|
||||
[main.access_domain.access_domain]
|
||||
ask = "Which web app can access the Standart Notes Extensions?"
|
||||
type = "string"
|
||||
default = ""
|
||||
help = "Please enter the domain without the path of a Standart Notes Web App, which should have access to the Standard Notes Extensions.<br>Example: domain.tld, notes.domain.tld"
|
|
@ -180,6 +180,7 @@ admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)
|
|||
message_extensions="To install extensions open this page: https://$domain$path_url/extensions/\n\
|
||||
You changed the url of the syncing server. All extensions installed from here must be reinstalled by the users."
|
||||
action="You can find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__"
|
||||
config_panel="You can find some specific configurations for this app by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__"
|
||||
|
||||
ynh_replace_string --match_string="__TYPE__" --replace_string="changed the url" --target_file="../conf/message"
|
||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/message"
|
||||
|
@ -192,6 +193,7 @@ else
|
|||
ynh_replace_string --match_string="__EXTENSIONS__" --replace_string="" --target_file="../conf/message"
|
||||
fi
|
||||
ynh_replace_string --match_string="__ACTION__" --replace_string="$action" --target_file="../conf/message"
|
||||
ynh_replace_string --match_string="__CONFIG_PANEL__" --replace_string="$config_panel" --target_file="../conf/message"
|
||||
|
||||
ynh_send_readme_to_admin --app_message="../conf/message" --type='upgrade'
|
||||
|
||||
|
|
67
scripts/config
Executable file
67
scripts/config
Executable file
|
@ -0,0 +1,67 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source ./_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Stop script if errors
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
access_domain=$(ynh_app_setting_get --app=$app --key=access_domain)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
|
||||
#=================================================
|
||||
# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND
|
||||
#=================================================
|
||||
|
||||
show_config() {
|
||||
if [ ! -z $access_domain ]
|
||||
then
|
||||
ynh_return "YNH_CONFIG_MAIN_ACCESS_DOMAIN_ACCESS_DOMAIN=$access_domain"
|
||||
else
|
||||
ynh_return "YNH_CONFIG_MAIN_ACCESS_DOMAIN_ACCESS_DOMAIN=$domain"
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# MODIFY THE CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
apply_config() {
|
||||
access_domain=${YNH_CONFIG_MAIN_ACCESS_DOMAIN_ACCESS_DOMAIN:-$access_domain}
|
||||
ynh_print_info "1: $access_domain"
|
||||
ynh_app_setting_set --app=$app --key=access_domain --value=$access_domain
|
||||
|
||||
access_domain=$(ynh_app_setting_get --app=$app --key=access_domain)
|
||||
ynh_print_info "2: $access_domain"
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$domain.d/$app.conf
|
||||
ynh_delete_file_checksum --file=$nginx_conf_path
|
||||
ynh_replace_string \
|
||||
--match_string='more_set_headers "X-Frame-Options: allow-from .*";' \
|
||||
--replace_string='more_set_headers "X-Frame-Options: allow-from '$access_domain'";' \
|
||||
--target_file=$nginx_conf_path
|
||||
ynh_store_file_checksum --file=$nginx_conf_path
|
||||
|
||||
systemctl reload nginx
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT
|
||||
#=================================================
|
||||
case $1 in
|
||||
show) show_config;;
|
||||
apply) apply_config;;
|
||||
esac
|
|
@ -34,6 +34,10 @@ then
|
|||
access_domain=$domain
|
||||
else
|
||||
access_domain=$YNH_APP_ARG_ACCESS_DOMAIN
|
||||
if [ -z $access_domain ]
|
||||
then
|
||||
access_domain=$domain
|
||||
fi
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -294,6 +298,7 @@ You can configure this app by using the config-panel"
|
|||
|
||||
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
|
||||
action="You can find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__"
|
||||
config_panel="You can find some specific configurations for this app by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__"
|
||||
|
||||
ynh_replace_string --match_string="__TYPE__" --replace_string="installed" --target_file="../conf/message"
|
||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/message"
|
||||
|
@ -306,6 +311,7 @@ else
|
|||
ynh_replace_string --match_string="__EXTENSIONS__" --replace_string="$message_no_extensions" --target_file="../conf/message"
|
||||
fi
|
||||
ynh_replace_string --match_string="__ACTION__" --replace_string="$action" --target_file="../conf/message"
|
||||
ynh_replace_string --match_string="__CONFIG_PANEL__" --replace_string="$config_panel" --target_file="../conf/message"
|
||||
|
||||
ynh_send_readme_to_admin --app_message="../conf/message" --type='install'
|
||||
|
||||
|
|
|
@ -341,6 +341,7 @@ You can configure this app by using the config-panel"
|
|||
|
||||
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
|
||||
action="You can find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__"
|
||||
config_panel="You can find some specific configurations for this app by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__"
|
||||
|
||||
ynh_replace_string --match_string="__TYPE__" --replace_string="installed" --target_file="../conf/message"
|
||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/message"
|
||||
|
@ -353,6 +354,7 @@ else
|
|||
ynh_replace_string --match_string="__EXTENSIONS__" --replace_string="$message_no_extensions" --target_file="../conf/message"
|
||||
fi
|
||||
ynh_replace_string --match_string="__ACTION__" --replace_string="$action" --target_file="../conf/message"
|
||||
ynh_replace_string --match_string="__CONFIG_PANEL__" --replace_string="$config_panel" --target_file="../conf/message"
|
||||
|
||||
ynh_send_readme_to_admin --app_message="../conf/message" --type='upgrade'
|
||||
|
||||
|
|
Loading…
Reference in a new issue