1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/collabora_ynh.git synced 2024-09-03 18:16:25 +02:00
collabora_ynh/scripts/install

144 lines
4.8 KiB
Text
Raw Normal View History

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
#=================================================
2019-08-04 23:00:10 +02:00
ynh_print_info --message="Validating installation parameters..."
2017-06-21 11:34:24 +02:00
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
#=================================================
2019-08-04 23:00:10 +02:00
ynh_print_info --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
#=================================================
2019-08-04 23:00:10 +02:00
ynh_print_info --message="Configuring firewall..."
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
2018-11-02 18:15:03 +01:00
#===============================================
# ADD COLLABORA REPOSITORY
#===============================================
2017-11-11 16:41:23 +01:00
2018-11-03 10:26:54 +01:00
ynh_install_app_dependencies apt-transport-https
2018-11-01 16:55:18 +01:00
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0C54D189F4BA284D
2018-11-02 18:15:03 +01:00
2018-11-03 10:26:54 +01:00
if [ "$(lsb_release --codename --short)" = "jessie" ]; then
echo 'deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian8 ./' | tee -a /etc/apt/sources.list.d/collabora.list
2018-11-01 16:55:18 +01:00
else
echo 'deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian9 ./' | tee -a /etc/apt/sources.list.d/collabora.list
2018-11-01 16:55:18 +01:00
fi
2019-08-04 23:00:10 +02:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_print_info --message="Installing dependencies..."
2018-11-02 18:15:03 +01:00
ynh_package_update
2019-08-04 23:00:10 +02:00
ynh_install_app_dependencies $pkg_dependencies
2017-06-25 09:05:13 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
2019-08-04 23:00:10 +02:00
ynh_print_info --message="Configuring nginx web server..."
2017-06-25 09:05:13 +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
#=================================================
2019-08-04 23:00:10 +02:00
# SPECIFIC SETUP
2017-11-11 16:35:49 +01:00
#=================================================
# MODIFY A CONFIG FILE
#=================================================
2019-08-04 23:00:10 +02:00
config="/etc/loolwsd/loolwsd.xml"
cp -f ../conf/loolwsd.xml $config
ynh_replace_string --match_string="__NEXTCLOUDDOMAIN__" --replace_string="$nextcloud_domain" --target_file="$config"
ynh_replace_string --match_string="__PASSWORD__" --replace_string="$password" --target_file="$config"
2018-11-02 18:15:03 +01:00
2017-06-25 09:05:13 +02:00
#=================================================
2018-11-02 18:15:03 +01:00
# STORE THE CONFIG FILE CHECKSUM
2017-06-25 09:05:13 +02:00
#=================================================
2018-11-02 18:15:03 +01:00
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "/etc/loolwsd/loolwsd.xml"
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
#=================================================
2019-08-04 23:00:10 +02:00
ynh_print_info --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
ynh_systemd_action --service_name="loolwsd" --action="start" --log_path="systemd" --line_match="Started LibreOffice Online WebSocket Daemon"
2018-11-02 18:15:03 +01:00
#=================================================
# SETUP SSOWAT
#=================================================
2019-08-04 23:00:10 +02:00
ynh_print_info --message="Configuring SSOwat..."
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.
ynh_app_setting_set $app unprotected_uris "/"
2017-06-21 11:34:24 +02:00
2019-08-04 23:00:10 +02:00
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info --message="Reloading nginx web server..."
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
2017-08-22 19:27:56 +02:00
2019-08-04 23:00:10 +02:00
ynh_print_info --message="Installation of $app completed"