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

51 lines
1.5 KiB
Text
Raw Normal View History

2022-11-20 18:43:49 +01:00
#!/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