2015-04-06 17:46:57 +02:00
|
|
|
#!/bin/bash
|
2017-04-30 15:45:50 +02:00
|
|
|
|
2020-07-18 20:31:39 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2017-04-30 15:45:50 +02:00
|
|
|
|
2020-07-18 20:31:39 +02:00
|
|
|
source _common.sh
|
2017-04-30 15:45:50 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2015-04-06 17:46:57 +02:00
|
|
|
|
2020-07-18 20:31:39 +02:00
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_clean_setup () {
|
|
|
|
### Remove this function if there's nothing to clean before calling the remove script.
|
|
|
|
true
|
|
|
|
}
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
2017-04-30 15:45:50 +02:00
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
2020-07-18 20:31:39 +02:00
|
|
|
path_url=$YNH_APP_ARG_PATH
|
2017-04-30 15:45:50 +02:00
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2015-04-06 17:46:57 +02:00
|
|
|
|
2020-07-18 20:31:39 +02:00
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Validating installation parameters..." --time --weight=1
|
|
|
|
|
|
|
|
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
|
|
|
|
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
|
|
|
|
final_path=/var/www/$app
|
|
|
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
2017-04-30 15:45:50 +02:00
|
|
|
|
2020-07-18 20:31:39 +02:00
|
|
|
# Register (book) web path
|
|
|
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
2017-05-08 18:49:11 +02:00
|
|
|
|
2020-07-18 20:31:39 +02:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Storing installation settings..." --time --weight=1
|
2017-05-08 18:49:11 +02:00
|
|
|
|
2020-07-18 20:31:39 +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=is_public --value=$is_public
|
2017-05-08 18:49:11 +02:00
|
|
|
|
2020-07-18 20:31:39 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Setting up source files..." --time --weight=1
|
2017-05-08 19:25:22 +02:00
|
|
|
|
2020-07-18 20:31:39 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
|
|
ynh_setup_source --dest_dir="$final_path"
|
2015-04-06 17:46:57 +02:00
|
|
|
|
2020-07-18 20:31:39 +02:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring nginx web server..." --time --weight=1
|
2017-04-30 15:45:50 +02:00
|
|
|
|
2020-07-18 20:31:39 +02:00
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
2017-04-30 15:45:50 +02:00
|
|
|
|
2020-07-18 20:31:39 +02:00
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring system user..." --time --weight=1
|
2017-04-30 15:45:50 +02:00
|
|
|
|
2020-07-18 20:31:39 +02:00
|
|
|
# Create a system user
|
|
|
|
ynh_system_user_create --username=$app
|
2017-05-31 14:04:02 +02:00
|
|
|
|
2020-07-18 20:31:39 +02:00
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring php-fpm..." --time --weight=1
|
2017-05-08 17:18:41 +02:00
|
|
|
|
2020-07-18 20:31:39 +02:00
|
|
|
# Create a dedicated php-fpm config
|
|
|
|
ynh_add_fpm_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# SECURE FILES AND DIRECTORIES
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Set permissions to app files
|
|
|
|
chown -R $app: $final_path
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring SSOwat..." --time --weight=1
|
|
|
|
|
|
|
|
# Make app public if necessary
|
2017-05-08 17:18:41 +02:00
|
|
|
if [ $is_public -eq 1 ]
|
|
|
|
then
|
2020-07-18 20:31:39 +02:00
|
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
|
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
2015-04-06 17:46:57 +02:00
|
|
|
fi
|
|
|
|
|
2020-07-18 20:31:39 +02:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --time --last
|