2017-01-28 22:50:08 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-03-24 01:27:49 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
2017-01-29 16:25:11 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2018-03-24 01:27:49 +01:00
|
|
|
#=================================================
|
2020-04-02 16:34:46 +02:00
|
|
|
# MANAGE SCRIPT FAILURE
|
2018-03-24 01:27:49 +01:00
|
|
|
#=================================================
|
|
|
|
|
2020-04-02 16:34:46 +02:00
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
2020-03-31 17:43:53 +02:00
|
|
|
|
2020-04-02 16:34:46 +02:00
|
|
|
#=================================================
|
|
|
|
# Retrieve arguments
|
|
|
|
#=================================================
|
2018-03-24 01:27:49 +01:00
|
|
|
|
2020-04-02 16:34:46 +02:00
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
path_url=$YNH_APP_ARG_PATH
|
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2018-03-24 01:27:49 +01:00
|
|
|
|
|
|
|
#=================================================
|
2020-04-02 16:34:46 +02:00
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
2018-03-24 01:27:49 +01:00
|
|
|
#=================================================
|
|
|
|
|
2020-04-02 16:34:46 +02:00
|
|
|
final_path=/var/www/$app
|
|
|
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
|
|
|
|
|
|
|
# Normalize the url path syntax
|
|
|
|
path_url=$(ynh_normalize_url_path $path_url)
|
|
|
|
|
|
|
|
# Check web path availability
|
|
|
|
ynh_webpath_available $domain $path_url
|
|
|
|
# Register (book) web path
|
|
|
|
ynh_webpath_register $app $domain $path_url
|
2018-03-24 01:27:49 +01:00
|
|
|
|
2020-03-31 20:50:30 +02:00
|
|
|
#=================================================
|
2020-04-02 16:34:46 +02:00
|
|
|
# STORE SETTINGS FROM MANIFEST
|
2020-03-31 20:50:30 +02:00
|
|
|
#=================================================
|
|
|
|
|
2020-04-02 16:34:46 +02:00
|
|
|
ynh_app_setting_set $app path_url $path_url
|
|
|
|
ynh_app_setting_set $app domain $domain
|
|
|
|
ynh_app_setting_set $app is_public $is_public
|
2020-03-31 20:50:30 +02:00
|
|
|
|
2018-03-24 01:27:49 +01:00
|
|
|
#=================================================
|
2020-04-02 16:34:46 +02:00
|
|
|
# Install dependency to convert tracks to a readable format for the browser
|
2018-03-24 01:27:49 +01:00
|
|
|
#=================================================
|
|
|
|
|
2020-04-02 16:34:46 +02:00
|
|
|
if [ "$(lsb_release --codename --short)" != "jessie" ]
|
|
|
|
then
|
2020-04-02 17:28:53 +02:00
|
|
|
ynh_install_app_dependencies php-sqlite3
|
2020-04-02 16:34:46 +02:00
|
|
|
else
|
|
|
|
ynh_install_app_dependencies php5-sqlite
|
|
|
|
fi
|
2018-03-24 01:27:49 +01:00
|
|
|
|
|
|
|
#=================================================
|
2020-04-02 16:34:46 +02:00
|
|
|
# CREATE DEDICATED USER
|
2018-03-24 01:27:49 +01:00
|
|
|
#=================================================
|
|
|
|
|
2020-04-02 16:34:46 +02:00
|
|
|
# Create a system user
|
|
|
|
ynh_system_user_create $app
|
2018-03-24 01:27:49 +01:00
|
|
|
|
|
|
|
#=================================================
|
2020-04-02 16:34:46 +02:00
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
2018-03-24 01:27:49 +01:00
|
|
|
#=================================================
|
|
|
|
|
2020-04-02 16:34:46 +02: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"
|
2017-01-28 22:50:08 +01:00
|
|
|
|
2020-03-31 20:50:30 +02:00
|
|
|
#=================================================
|
2020-04-02 16:34:46 +02:00
|
|
|
# Files owned by user app
|
2020-03-31 20:50:30 +02:00
|
|
|
#=================================================
|
|
|
|
|
2020-04-02 16:34:46 +02:00
|
|
|
sudo chown $app:$app $final_path -R
|
|
|
|
sudo chmod 755 $final_path -R
|
2020-03-31 20:50:30 +02:00
|
|
|
|
|
|
|
#=================================================
|
2020-04-02 16:34:46 +02:00
|
|
|
# NGINX CONFIGURATION
|
2020-03-31 20:50:30 +02:00
|
|
|
#=================================================
|
|
|
|
|
2020-04-02 16:34:46 +02:00
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
2020-03-31 20:50:30 +02:00
|
|
|
|
2018-03-24 01:27:49 +01:00
|
|
|
#=================================================
|
2020-04-02 16:34:46 +02:00
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Create a dedicated php-fpm config
|
|
|
|
ynh_add_fpm_config
|
|
|
|
|
2018-03-24 01:27:49 +01:00
|
|
|
#=================================================
|
2020-04-02 16:34:46 +02:00
|
|
|
# SETUP SSOWAT
|
2018-03-24 01:27:49 +01:00
|
|
|
#=================================================
|
2017-01-28 22:50:08 +01:00
|
|
|
|
2020-04-02 16:34:46 +02: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 ]
|
|
|
|
then
|
|
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
|
|
ynh_app_setting_set $app unprotected_uris "/"
|
|
|
|
fi
|
2020-03-31 17:43:53 +02:00
|
|
|
|
|
|
|
#=================================================
|
2020-04-02 16:34:46 +02:00
|
|
|
# RELOAD NGINX
|
2020-03-31 17:43:53 +02:00
|
|
|
#=================================================
|
|
|
|
|
2020-04-02 16:34:46 +02:00
|
|
|
systemctl reload nginx
|