1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lutim_ynh.git synced 2024-09-03 19:36:24 +02:00
lutim_ynh/scripts/actions/reset_default_config
2018-09-30 11:52:12 +02:00

60 lines
2 KiB
Bash
Executable file

#!/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}
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
port=$(ynh_app_setting_get $app port)
always_encrypt=$(ynh_app_setting_get $app always_encrypt)
secret=$(ynh_app_setting_get $app 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
#=================================================
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$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 "__DOMAIN__" "$domain" "$config_file"
ynh_replace_string "__PATH__" "$path_url" "$config_file"
ynh_replace_string "__PORT__" "$port" "$config_file"
ynh_replace_string "__ENCRYPT__" "$always_encrypt" "$config_file"
ynh_replace_string "__SECRET__" "$secret" "$config_file"
fi
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$config_file"
# Wait for lutim to be fully started
ynh_check_starting --line_to_match="Manager.*started" --app_log="/var/log/$app/production.log" --timeout="120"