1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/FastAPI_ynh.git synced 2024-09-03 18:36:00 +02:00
fastapi_ynh/scripts/config

75 lines
2.6 KiB
Text
Raw Normal View History

2023-11-28 13:20:48 +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
#=================================================
install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
2023-12-04 06:59:26 +01:00
data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
2023-11-28 13:20:48 +01:00
#=================================================
2023-12-05 11:27:14 +01:00
# SPECIFIC SETTERS FOR TOML SHORT KEYS
2023-11-28 13:20:48 +01:00
#=================================================
#=================================================
# GENERIC FINALIZATION
#=================================================
2023-12-05 11:27:14 +01:00
ynh_app_config_apply() {
_ynh_app_config_apply
#TODO : add password question to configuration panel
password=""
# Set new password
if [ ! "$password" == "" ]
then
ynh_print_info --message="Changing password for user ${app}"
chpasswd <<< "${app}:${password}"
fi
2023-12-08 13:47:47 +01:00
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
2023-12-05 11:27:14 +01:00
# Symbolic link to main app folder
if [ ! "$main_folder" == "FastAPIAppFolder" ]
then
ynh_print_info --message="Deleting $data_dir/FastAPIAppFolder"
rm -rf "$data_dir/FastAPIAppFolder"
ynh_print_info --message="Creating symbolic link to folder ${main_folder}"
ln -s "$data_dir/$main_folder" "$data_dir/FastAPIAppFolder"
fi
2023-12-08 13:47:47 +01:00
if [ ! "$requirements_path" == "" ]
2023-12-05 11:27:14 +01:00
then
ynh_print_info --message="Installing python custom requirements"
# Enable python virtual environnement
source $install_dir/venv/bin/activate
# Install user's custom requirements
2023-12-08 13:47:47 +01:00
pip install -r $data_dir/$requirements_path
2023-12-05 11:27:14 +01:00
fi
2023-12-08 13:47:47 +01:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
2023-12-05 11:27:14 +01:00
}
2023-11-28 13:20:48 +01:00
ynh_app_config_run $1