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

72 lines
2.5 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)
port=$(ynh_app_setting_get $app port)
export=$(ynh_app_setting_get $app export)
language=$(ynh_app_setting_get $app language)
mypads=$(ynh_app_setting_get $app mypads)
useldap=$(ynh_app_setting_get $app useldap)
#=================================================
# SORT OUT THE CONFIG FILE TO HANDLE
#=================================================
file="$1"
if [ "$file" = "settings.json" ]; then
config_file="$final_path/settings.json"
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" = "settings.json" ]
then
# Get the default file and overwrite the current config
cp /etc/yunohost/apps/$app/conf/settings.json "$config_file"
# Recreate the default config
ynh_replace_string "__PORT__" "$port" "$final_path/settings.json"
if [ "$export" = "abiword" ]
then
abiword_path=`which abiword` # Get abiword binary path
ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad
elif [ "$export" = "libreoffice" ]
then
soffice_path=`which soffice` # Get soffice binary path
ynh_replace_string "\"soffice\" : null" "\"soffice\" : \"$soffice_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad
fi
ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json"
# Use ldap for mypads
if [ $mypads -eq 1 ] && [ $useldap -eq 1 ]
then
ynh_replace_string "//noldap\(.*\)" "\1 //useldap" "$final_path/settings.json"
fi
fi
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$config_file"
# Wait for etherpad to be fully started
ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/etherpad.log" "120"