2018-09-30 11:52:12 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC STARTING
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source scripts/_common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
2020-01-02 18:40:15 +01:00
|
|
|
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)
|
2018-09-30 11:52:12 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# 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
|
|
|
|
#=================================================
|
2020-01-02 18:40:15 +01:00
|
|
|
ynh_script_progression --message="Resetting the config file $config_file..." --weight=9
|
2018-09-30 11:52:12 +02:00
|
|
|
|
|
|
|
# Verify the checksum and backup the file if it's different
|
2020-01-02 18:40:15 +01:00
|
|
|
ynh_backup_if_checksum_is_different --file="$config_file"
|
2018-09-30 11:52:12 +02:00
|
|
|
|
|
|
|
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
|
2020-01-02 18:40:15 +01:00
|
|
|
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"
|
2018-09-30 11:52:12 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Calculate and store the config file checksum into the app settings
|
2020-01-02 18:40:15 +01:00
|
|
|
ynh_store_file_checksum --file="$config_file"
|
2018-09-30 11:52:12 +02:00
|
|
|
|
2020-01-02 18:40:15 +01:00
|
|
|
ynh_script_progression --message="Restarting Lutim..." --weight=5
|
2019-01-30 16:19:40 +01:00
|
|
|
|
2018-09-30 11:52:12 +02:00
|
|
|
# Wait for lutim to be fully started
|
2019-01-13 19:10:28 +01:00
|
|
|
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
2019-01-30 16:19:40 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Execution completed" --last
|
|
|
|
|