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/add_remove_libreoffice
2020-09-05 19:29:58 +02:00

113 lines
3.3 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
#=================================================
# CHECK IF ARGUMENTS ARE CORRECT
#=================================================
#=================================================
# CHECK IF AN ACTION HAS TO BE DONE
#=================================================
# Check the dependencies of the meta packages of etherpad_mypads with apt-cache
if apt-cache depends ${app//_/-}-ynh-deps | grep --quiet libreoffice-writer
then
# libreoffice is already a dependence of etherpad_mypads.
# libreoffice should be removed.
libreoffice=0
action1=removed
action2=Removing
else
# libreoffice isn't a dependence of etherpad_mypads.
# libreoffice should be installed.
libreoffice=1
action1=installed
action2=Installing
fi
ynh_print_info --message="LibreOffice will be $action1."
if apt-cache depends ${app//_/-}-ynh-deps | grep --quiet abiword
then
# abiword is already a dependence of etherpad_mypads.
# Keep it
abiword=1
else
# abiword isn't a dependence of etherpad_mypads.
# Do not add it
abiword=0
fi
#=================================================
# SPECIFIC ACTION
#=================================================
# INSTALL OR REMOVE LIBREOFFICE
#=================================================
ynh_script_progression --message="$action2 LibreOffice..." --weight=3
# Load common variables, and especially libreoffice dependencies.
source scripts/_variables
dependencies=""
if [ $libreoffice -eq 1 ]
then
# Add libreoffice dependencies if libreoffice has to be installed
dependencies="$dependencies $libreoffice_app_dependencies"
fi
if [ $abiword -eq 1 ]
then
# Add abiword dependencies if abiword is already installed to keep it as a dependence.
dependencies="$dependencies $abiword_app_depencencies"
fi
# Rebuild the meta package and install the new dependencies
( cd scripts # Move to scripts directory to allow the helper to find the manifest where it expects to find it.
ynh_install_app_dependencies $dependencies)
# Remove all unused dependencies
ynh_package_autopurge
#=================================================
# SET THE DEFAULT EXPORT APP
#=================================================
if [ $libreoffice -eq 1 ]
then
# Set libreoffice as default export app
yunohost app config apply $app -a "YNH_CONFIG_MAIN_EXPORT_EXPORT=libreoffice"
elif [ $abiword -eq 1 ]
then
# Set abiword as default export app
yunohost app config apply $app -a "YNH_CONFIG_MAIN_EXPORT_EXPORT=abiword"
else
# Remove any export app
yunohost app config apply $app -a "YNH_CONFIG_MAIN_EXPORT_EXPORT=none"
fi
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Execution completed" --last