1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/moncycle_ynh.git synced 2024-09-03 19:46:16 +02:00
moncycle_ynh/scripts/config
2024-02-22 13:46:08 +07:00

61 lines
2.1 KiB
Bash

#!/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__csv_sep(){
echo ""$(grep -oPi 'define\("CSV_SEP",[\s"]*\K[^\")]+' "$install_dir/config.php")""
}
set__csv_sep(){
sed -i "s/define(\"CSV_SEP\",.*);/define(\"CSV_SEP\", \"$csv_sep\");/" "$install_dir/config.php"
ynh_app_setting_set --app=$app --key=csv_sep --value="$csv_sep"
}
get__creation_compte(){
grep -oPi 'define\("CREATION_COMPTE",[\s"]*\K[^\")]+' "$install_dir/config.php"
}
set__creation_compte(){
sed -i "s/define(\"CREATION_COMPTE\",.*);/define(\"CREATION_COMPTE\", $creation_compte);/" "$install_dir/config.php"
ynh_app_setting_set --app=$app --key=creation_compte --value="$creation_compte"
}
get__connexion_compte(){
grep -oPi 'define\("CONNEXION_COMPTE",[\s"]*\K[^\")]+' "$install_dir/config.php"
}
set__connexion_compte(){
sed -i "s/define(\"CONNEXION_COMPTE\",.*);/define(\"CONNEXION_COMPTE\", $connexion_compte);/" "$install_dir/config.php"
ynh_app_setting_set --app=$app --key=connexion_compte --value="$connexion_compte"
}
get__statistics(){
echo "$(pushd "$install_dir/script" && /usr/bin/php8.3 --define apc.enable_cli=1 stat.php)"
}
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_app_config_run $1