mirror of
https://github.com/YunoHost-Apps/lutim_ynh.git
synced 2024-09-03 19:36:24 +02:00
84 lines
3.1 KiB
Bash
Executable file
84 lines
3.1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC STARTING
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source scripts/_common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# MANAGE SCRIPT FAILURE
|
|
#=================================================
|
|
|
|
ynh_clean_setup () {
|
|
# Clean installation remaining that are not handle by the remove script.
|
|
ynh_clean_check_starting
|
|
}
|
|
# Exit if an error occurs during the execution of the script
|
|
ynh_abort_if_errors
|
|
|
|
#=================================================
|
|
# RETRIEVE ARGUMENTS
|
|
#=================================================
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
|
always_encrypt=$(ynh_app_setting_get --app=$app --key=always_encrypt)
|
|
secret=$(ynh_app_setting_get --app=$app --key=secret)
|
|
|
|
#=================================================
|
|
# SORT OUT THE CONFIG FILE TO HANDLE
|
|
#=================================================
|
|
|
|
file="$1"
|
|
|
|
if [ "$file" = "lutim.conf" ]; then
|
|
config_file="$final_path/lutim.conf"
|
|
fi
|
|
|
|
#=================================================
|
|
# SPECIFIC ACTION
|
|
#=================================================
|
|
# RESET THE CONFIG FILE
|
|
#=================================================
|
|
ynh_script_progression --message="Resetting the config file $config_file..." --weight=9
|
|
|
|
# Verify the checksum and backup the file if it's different
|
|
ynh_backup_if_checksum_is_different --file="$config_file"
|
|
|
|
if [ "$file" = "lutim.conf" ]
|
|
then
|
|
# Get the default file and overwrite the current config
|
|
cp /etc/yunohost/apps/$app/conf/lutim.conf.template "$config_file"
|
|
|
|
# Recreate the default config
|
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config_file"
|
|
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config_file"
|
|
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file"
|
|
ynh_replace_string --match_string="__ENCRYPT__" --replace_string="$always_encrypt" --target_file="$config_file"
|
|
ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config_file"
|
|
# Set the number of process for Lutim to twice the number of CPU core.
|
|
ynh_replace_string --match_string="__WORKERS__" --replace_string="$(( $(nproc) * 2 ))" --target_file="$final_path/lutim.conf"
|
|
fi
|
|
|
|
# Calculate and store the config file checksum into the app settings
|
|
ynh_store_file_checksum --file="$config_file"
|
|
|
|
ynh_script_progression --message="Restarting Lutim..." --weight=5
|
|
|
|
# Wait for lutim to be fully started
|
|
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Execution completed" --last
|
|
|