2017-06-21 11:34:24 +02:00
#!/bin/bash
2018-11-02 18:15:03 +01:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
2019-08-04 23:00:10 +02:00
ynh_clean_check_starting
2018-11-02 18:15:03 +01:00
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
2017-06-21 11:34:24 +02:00
domain=$YNH_APP_ARG_DOMAIN
2019-08-04 23:00:10 +02:00
path_url="/"
2017-11-11 16:35:49 +01:00
password=$YNH_APP_ARG_PASSWORD
2019-08-04 23:00:10 +02:00
nextcloud_domain=$YNH_APP_ARG_NEXTCLOUD_DOMAIN
2018-11-03 10:16:37 +01:00
app=$YNH_APP_INSTANCE_NAME
2018-11-02 18:15:03 +01:00
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
2020-12-18 22:44:52 +01:00
ynh_script_progression --message="Validating installation parameters..."
2017-06-21 11:34:24 +02:00
2021-03-15 18:24:34 +01:00
if dpkg-architecture --is armhf
then
ynh_die --message="Sorry, this app can not be installed on an ARM architecture"
fi
2018-11-02 18:15:03 +01:00
# Register (book) web path
2019-08-04 23:00:10 +02:00
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
2017-06-21 11:34:24 +02:00
2018-11-02 18:15:03 +01:00
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
2020-12-18 22:44:52 +01:00
ynh_script_progression --message="Storing installation settings..."
2018-11-02 18:15:03 +01:00
2019-08-04 23:00:10 +02:00
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=password --value=$password
ynh_app_setting_set --app=$app --key=nextcloud_domain --value=$nextcloud_domain
2018-11-02 18:15:03 +01:00
2019-08-04 23:00:10 +02:00
#=================================================
# STANDARD MODIFICATIONS
2018-11-02 18:15:03 +01:00
#=================================================
# FIND AND OPEN A PORT
#=================================================
2021-01-09 22:44:51 +01:00
ynh_script_progression --message="Finding an available port..."
2017-06-21 11:34:24 +02:00
2018-02-05 19:09:21 +01:00
# Find a free port
2019-08-04 23:00:10 +02:00
port=$(ynh_find_port --port=9980)
ynh_app_setting_set --app=$app --key=port --value=$port
2017-06-21 11:34:24 +02:00
2021-01-09 23:59:37 +01:00
#=================================================
# CONFIGURE ONLYOFFICE
#=================================================
# Turns out we need to create/copy this file BEFORE the actual .deb install,
# otherwise stupid collabora will expect to find a certificate file in its own
# config directory which of course doesn't exists and we want to disable SSL
# because we're in a reverse proxy context...
mkdir -p /etc/loolwsd
2021-06-25 23:33:37 +02:00
ynh_add_config --template="../conf/loolwsd.xml" --destination="/etc/loolwsd/loolwsd.xml"
2021-01-09 23:59:37 +01:00
2019-08-04 23:00:10 +02:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2020-12-18 22:44:52 +01:00
ynh_script_progression --message="Installing dependencies..."
2019-08-04 23:00:10 +02:00
2021-01-02 19:34:07 +01:00
DEBIAN_VERSION_NUMBER=$(cat /etc/debian_version | head -n 1 | cut -f1 -d .)
2020-07-01 18:16:38 +02:00
ynh_install_extra_app_dependencies --repo="deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian${DEBIAN_VERSION_NUMBER} ./ " --package="$pkg_dependencies" --key="https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x0C54D189F4BA284D"
2017-06-25 09:05:13 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
2020-12-18 22:44:52 +01:00
ynh_script_progression --message="Configuring NGINX web server..."
2017-06-25 09:05:13 +02:00
2020-09-22 16:57:16 +02:00
# Create a dedicated NGINX config
2017-08-22 19:27:56 +02:00
ynh_add_nginx_config
2017-06-25 09:05:13 +02:00
2018-11-02 18:15:03 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
2019-08-04 23:00:10 +02:00
# START SYSTEMD SERVICE
2018-11-02 18:15:03 +01:00
#=================================================
2020-12-18 22:44:52 +01:00
ynh_script_progression --message="Starting a systemd service..."
2018-11-02 18:15:03 +01:00
2019-08-04 23:00:10 +02:00
# Start a systemd service
2021-01-09 23:59:37 +01:00
# NB. : we need a stupid *re*start because the service is in fact already started during the damn package install ... so it won't find a recent "Ready to accept connection" match ...
ynh_systemd_action --service_name="loolwsd" --action="restart" --log_path="systemd" --line_match="Ready to accept connections"
2018-11-02 18:15:03 +01:00
#=================================================
# SETUP SSOWAT
#=================================================
2021-02-04 12:44:49 +01:00
ynh_script_progression --message="Configuring permissions..."
2018-11-02 18:15:03 +01:00
2019-08-04 23:00:10 +02:00
# Make app public
2018-11-02 18:15:03 +01:00
# unprotected_uris allows SSO credentials to be passed anyway.
2021-02-04 12:44:49 +01:00
ynh_permission_update --permission="main" --add="visitors" --show_tile="false"
2017-06-21 11:34:24 +02:00
2019-08-04 23:00:10 +02:00
#=================================================
# RELOAD NGINX
#=================================================
2020-12-18 22:44:52 +01:00
ynh_script_progression --message="Reloading NGINX web server..."
2019-08-04 23:00:10 +02:00
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
2017-08-22 19:27:56 +02:00
2020-12-18 22:44:52 +01:00
ynh_script_progression --message="Installation of $app completed"