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
|
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
|
|
|
#=================================================
|
|
|
|
|
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
|
|
|
#=================================================
|
2017-01-28 23:11:24 +01:00
|
|
|
|
2018-03-24 01:16:50 +01:00
|
|
|
ynh_install_app_dependencies php5-sqlite
|
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
|
|
|
|
ynh_add_nginx_config
|
2017-01-28 22:05:00 +01:00
|
|
|
|
2018-03-24 01:25:15 +01:00
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Create a dedicated php-fpm config
|
|
|
|
ynh_add_fpm_config
|
|
|
|
|
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
|
|
|
#=================================================
|
|
|
|
|
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
|
|
|
#=================================================
|
|
|
|
|
2018-03-24 01:16:50 +01:00
|
|
|
systemctl reload nginx
|