mirror of
https://github.com/YunoHost-Apps/etherpad_mypads_ynh.git
synced 2024-09-03 18:36:09 +02:00
96 lines
3.4 KiB
Bash
Executable file
96 lines
3.4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC STARTING
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source scripts/_common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# MANAGE SCRIPT FAILURE
|
|
#=================================================
|
|
|
|
# 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)
|
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
|
export=$(ynh_app_setting_get --app=$app --key=export)
|
|
language=$(ynh_app_setting_get --app=$app --key=language)
|
|
mypads=$(ynh_app_setting_get --app=$app --key=mypads)
|
|
useldap=$(ynh_app_setting_get --app=$app --key=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
|
|
#=================================================
|
|
ynh_script_progression --message="Resetting the config file $config_file..." --weight=3
|
|
|
|
# Verify the checksum and backup the file if it's different
|
|
ynh_backup_if_checksum_is_different --file="$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 --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/settings.json"
|
|
if [ "$export" = "abiword" ]
|
|
then
|
|
# Get abiword binary path
|
|
abiword_path=`which abiword`
|
|
# Set the path of abiword into etherpad config
|
|
ynh_replace_string --match_string="\"abiword\" : null" --replace_string="\"abiword\" : \"$abiword_path\"" --target_file="$final_path/settings.json"
|
|
elif [ "$export" = "libreoffice" ]
|
|
then
|
|
# Get soffice binary path
|
|
soffice_path=`which soffice`
|
|
# Set the path of soffice into etherpad config
|
|
ynh_replace_string --match_string="\"soffice\" : null" --replace_string="\"soffice\" : \"$soffice_path\"" --target_file="$final_path/settings.json"
|
|
fi
|
|
ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/settings.json"
|
|
|
|
# Use ldap for mypads
|
|
if [ $mypads -eq 1 ] && [ $useldap -eq 1 ]
|
|
then
|
|
ynh_replace_string --match_string="//noldap\(.*\)" --replace_string="\1 //useldap" --target_file="$final_path/settings.json"
|
|
fi
|
|
fi
|
|
|
|
# Calculate and store the config file checksum into the app settings
|
|
ynh_store_file_checksum --file="$config_file"
|
|
|
|
#=================================================
|
|
# CHECK ETHERPAD STARTING
|
|
#=================================================
|
|
ynh_script_progression --message="Restarting Etherpad..." --weight=9
|
|
|
|
# Wait for etherpad to be fully started
|
|
ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|