2017-02-13 22:47:30 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
2017-10-23 12:38:35 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2017-02-13 22:47:30 +01:00
|
|
|
|
2017-10-23 12:38:35 +02:00
|
|
|
source _common.sh
|
2017-02-13 22:47:30 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2017-10-23 12:38:35 +02:00
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
2017-02-13 22:47:30 +01:00
|
|
|
|
2017-10-23 12:38:35 +02:00
|
|
|
ynh_abort_if_errors
|
2017-02-13 22:47:30 +01:00
|
|
|
|
2017-10-23 12:38:35 +02:00
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
2017-02-13 22:47:30 +01:00
|
|
|
|
2017-10-23 12:38:35 +02:00
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
path_url=$YNH_APP_ARG_PATH
|
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
2017-02-13 22:47:30 +01:00
|
|
|
|
2017-10-23 12:38:35 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2017-02-13 22:47:30 +01:00
|
|
|
|
2017-10-23 12:38:35 +02:00
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
final_path=/var/www/$app
|
|
|
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
|
|
|
|
|
|
|
path_url=$(ynh_normalize_url_path $path_url)
|
|
|
|
ynh_webpath_available $domain $path_url
|
|
|
|
ynh_webpath_register $app $domain $path_url
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_app_setting_set $app domain $domain
|
|
|
|
ynh_app_setting_set $app path $path_url
|
|
|
|
ynh_app_setting_set $app is_public $is_public
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2017-02-13 22:47:30 +01:00
|
|
|
|
|
|
|
final_path=/var/www/$app
|
2017-02-16 23:34:23 +01:00
|
|
|
sudo mkdir -p /var/www/$app
|
2017-02-16 23:26:05 +01:00
|
|
|
extract_source
|
2017-02-13 22:47:30 +01:00
|
|
|
|
2017-10-23 12:38:35 +02:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
2017-10-23 12:44:46 +02:00
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_add_fpm_config
|
|
|
|
|
2017-10-23 12:38:35 +02:00
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_system_user_create $app
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SECURE FILES AND DIRECTORIES
|
|
|
|
#=================================================
|
2017-02-13 22:47:30 +01:00
|
|
|
|
2017-10-23 12:38:35 +02:00
|
|
|
# Set permissions to app files
|
|
|
|
chown -R $app:www-data $final_path
|
|
|
|
chmod 775 $final_path -R
|
2017-02-13 22:47:30 +01:00
|
|
|
|
2017-10-23 12:38:35 +02:00
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ $is_public -eq 0 ]
|
|
|
|
then
|
|
|
|
ynh_app_setting_delete $app skipped_uris
|
|
|
|
fi
|
|
|
|
if [ $is_public -eq 1 ]
|
2017-02-13 22:47:30 +01:00
|
|
|
then
|
2017-10-23 12:38:35 +02:00
|
|
|
ynh_app_setting_set $app unprotected_uris "/"
|
2017-02-13 22:47:30 +01:00
|
|
|
fi
|
|
|
|
|
2017-10-23 12:38:35 +02:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
systemctl reload nginx
|