2017-01-28 22:05:00 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
2018-03-24 01:16:50 +01:00
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
2020-03-31 17:43:53 +02:00
|
|
|
source _ynh_add_fpm_config
|
2017-01-28 22:05:00 +01:00
|
|
|
|
2018-03-24 01:16:50 +01:00
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
2017-01-28 22:05:00 +01:00
|
|
|
# Retrieve arguments
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
|
|
|
|
2017-03-17 22:51:37 +01:00
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
2018-03-24 01:36:34 +01:00
|
|
|
path_url=$YNH_APP_ARG_PATH
|
2017-03-17 22:51:37 +01:00
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
2017-01-28 22:05:00 +01:00
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
2018-03-24 01:16:50 +01:00
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
|
|
|
|
2020-03-31 17:43:53 +02:00
|
|
|
ynh_script_progression --message="Validating installation parameters..."
|
|
|
|
|
2018-03-24 01:16:50 +01:00
|
|
|
final_path=/var/www/$app
|
|
|
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
2017-02-11 20:26:05 +01:00
|
|
|
|
2018-03-24 01:16:50 +01:00
|
|
|
# Normalize the url path syntax
|
|
|
|
path_url=$(ynh_normalize_url_path $path_url)
|
2017-02-12 11:08:59 +01:00
|
|
|
|
2018-03-24 01:16:50 +01:00
|
|
|
# Check web path availability
|
|
|
|
ynh_webpath_available $domain $path_url
|
|
|
|
# Register (book) web path
|
|
|
|
ynh_webpath_register $app $domain $path_url
|
2017-02-11 19:50:47 +01:00
|
|
|
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
2018-03-24 17:11:59 +01:00
|
|
|
ynh_app_setting_set $app path_url $path_url
|
2017-06-26 17:14:28 +02:00
|
|
|
ynh_app_setting_set $app domain $domain
|
|
|
|
ynh_app_setting_set $app is_public $is_public
|
|
|
|
|
|
|
|
#=================================================
|
2017-01-28 23:11:24 +01:00
|
|
|
# Install dependency to convert tracks to a readable format for the browser
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
2020-03-31 17:43:53 +02:00
|
|
|
ynh_script_progression --message="Installing dependencies..." --weight=60
|
2017-01-28 23:11:24 +01:00
|
|
|
|
2020-03-31 17:43:53 +02:00
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
|
|
|
|
ynh_install_php --phpversion="$YNH_PHP_VERSION" --package="$extra_pkg_dependencies"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CREATE A MYSQL DATABASE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Creating a MySQL database..." --weight=2
|
|
|
|
|
|
|
|
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
|
|
|
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
|
|
|
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name
|
2017-01-29 16:06:11 +01:00
|
|
|
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
2018-03-24 01:16:50 +01:00
|
|
|
# CREATE DEDICATED USER
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
|
|
|
|
2018-03-24 01:16:50 +01:00
|
|
|
# Create a system user
|
|
|
|
ynh_system_user_create $app
|
2017-01-28 22:05:00 +01:00
|
|
|
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
2018-03-24 01:16:50 +01:00
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
|
|
|
|
2018-03-24 01:16:50 +01:00
|
|
|
ynh_app_setting_set $app final_path $final_path
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
|
|
ynh_setup_source "$final_path"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# Files owned by user app
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
sudo chown $app:$app $final_path -R
|
2017-01-28 22:05:00 +01:00
|
|
|
sudo chmod 755 $final_path -R
|
|
|
|
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
2018-03-24 01:16:50 +01:00
|
|
|
# NGINX CONFIGURATION
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
|
|
|
|
2018-03-24 01:16:50 +01:00
|
|
|
# Create a dedicated nginx config
|
2020-03-31 17:43:53 +02:00
|
|
|
ynh_add_nginx_config YNH_PHP_VERSION
|
2017-01-28 22:05:00 +01:00
|
|
|
|
2018-03-24 01:25:15 +01:00
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
2020-03-31 17:43:53 +02:00
|
|
|
ynh_script_progression --message="Configuring php-fpm..." --weight=2
|
2018-03-24 01:25:15 +01:00
|
|
|
|
|
|
|
# Create a dedicated php-fpm config
|
2020-03-31 17:43:53 +02:00
|
|
|
ynh_add_fpm_config --usage=medium --footprint=high
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STORE THE CHECKSUM OF THE CONFIG FILE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Calculate and store the config file checksum into the app settings
|
|
|
|
ynh_store_file_checksum --file="$final_path/config/config.php"
|
2018-03-24 01:25:15 +01:00
|
|
|
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
2018-03-24 01:16:50 +01:00
|
|
|
# SETUP SSOWAT
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
2020-03-31 17:43:53 +02:00
|
|
|
ynh_script_progression --message="Configuring SSOwat..."
|
|
|
|
|
2017-06-26 17:14:28 +02:00
|
|
|
|
2018-03-24 01:16:50 +01:00
|
|
|
if [ $is_public -eq 0 ]
|
|
|
|
then # Remove the public access
|
|
|
|
ynh_app_setting_delete $app skipped_uris
|
|
|
|
fi
|
|
|
|
# Make app public if necessary
|
|
|
|
if [ $is_public -eq 1 ]
|
2017-01-28 22:05:00 +01:00
|
|
|
then
|
2018-03-24 01:16:50 +01:00
|
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
|
|
ynh_app_setting_set $app unprotected_uris "/"
|
2017-01-28 22:05:00 +01:00
|
|
|
fi
|
|
|
|
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
2018-03-24 01:16:50 +01:00
|
|
|
# RELOAD NGINX
|
2017-06-26 17:14:28 +02:00
|
|
|
#=================================================
|
|
|
|
|
2020-03-31 17:43:53 +02:00
|
|
|
ynh_script_progression --message="Reloading nginx web server..."
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|