1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/petrolette_ynh.git synced 2024-09-03 19:56:26 +02:00

add config panel

This commit is contained in:
oiseauroch 2022-11-20 18:43:49 +01:00
parent 8261c57c58
commit 25b52bfeeb
3 changed files with 65 additions and 1 deletions

14
config_panel.toml Normal file
View file

@ -0,0 +1,14 @@
version = "1.0"
[main]
services = ["__APP__"]
[main.customization]
[main.customization.instanceType]
ask = "Mono user instance"
type = "boolean"
help = "if this instance is mono user, the feed list will be the same for all users"
bind = "instance_type()"

View file

@ -6,7 +6,7 @@
"en": "The news reader that doesn't know you",
"fr": "La page d'actu qui ne sait rien de toi"
},
"version": "1.6.0~ynh1",
"version": "1.6.0~ynh2",
"url": "https://framagit.org/yphil/petrolette",
"upstream": {
"license": "AGPL-3.0-only",

50
scripts/config Normal file
View file

@ -0,0 +1,50 @@
#!/bin/bash
# In simple cases, you don't need a config script.
# With a simple config_panel.toml, you can write in the app settings, in the
# upstream config file or replace complete files (logo ...) and restart services.
# The config scripts allows you to go further, to handle specific cases
# (validation of several interdependent fields, specific getter/setter for a value,
# display dynamic informations or choices, pre-loading of config type .cube... ).
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
final_path=$(ynh_app_setting_get $app final_path)
get__instance_type() {
if [ -f "$final_path/petrolette.config.json" ]
then
echo 1
else
echo 0
fi
}
set__instance_type() {
if [ "$instanceType" -eq 1 ]
then
echo '{ "instanceType" : "monoUser" }' > "$final_path/petrolette.config.json"
ynh_app_setting_set --app=$app --key=mono_user --value=1
else
rm "$final_path/petrolette.config.json"
ynh_app_setting_set --app=$app --key=mono_user --value=0
fi
}
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_app_config_run $1