2017-04-26 19:01:53 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC STARTING
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_abort_if_errors # Stop script if an error is detected
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Retrieve app id
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
# Retrieve arguments
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
path_url=$YNH_APP_ARG_PATH
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
|
|
#=================================================
|
|
|
|
|
2020-03-31 05:07:19 +02:00
|
|
|
final_path=/var/www/$app
|
|
|
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
|
|
|
|
|
|
|
# Register (book) web path
|
|
|
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
2017-04-26 19:01:53 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_app_setting_set $app domain "$domain"
|
|
|
|
ynh_app_setting_set $app path_url "$path_url"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_app_setting_set $app final_path "$final_path"
|
|
|
|
# Create tmp directory and fetch app inside
|
|
|
|
TMPDIR=$(mktemp -d)
|
|
|
|
extract_sources "$TMPDIR"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_system_user_create $app # Create a dedicated system user
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Install files and set permissions
|
2020-03-31 05:07:19 +02:00
|
|
|
mv "$TMPDIR" "$final_path"
|
2017-04-26 19:01:53 +02:00
|
|
|
|
|
|
|
# Set rights on directory
|
2020-03-31 05:07:19 +02:00
|
|
|
chown -R root: $final_path
|
|
|
|
chown -R $app: $final_path/cache
|
|
|
|
chmod 755 $final_path
|
2017-04-26 19:01:53 +02:00
|
|
|
|
|
|
|
# Enable every bridge
|
|
|
|
for i in $final_path/bridges/*.php ; do
|
2020-03-31 05:07:19 +02:00
|
|
|
echo $(basename $i) | sed "s|Bridge.php$||g" | tee -a $final_path/whitelist.txt
|
2017-04-26 19:01:53 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
2019-06-09 19:21:27 +02:00
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
2017-04-26 19:01:53 +02:00
|
|
|
|
|
|
|
# Copy and set php-fpm configuration
|
|
|
|
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
|
|
|
ynh_replace_string "{POOLNAME}" "${app}" "$PKGDIR/conf/php-fpm.conf"
|
|
|
|
ynh_replace_string "{DESTDIR}" "${final_path}" "$PKGDIR/conf/php-fpm.conf"
|
|
|
|
ynh_replace_string "{USER}" "${app}" "$PKGDIR/conf/php-fpm.conf"
|
2020-03-31 05:07:19 +02:00
|
|
|
cp $PKGDIR/conf/php-fpm.conf "$phpfpm_conf"
|
2017-04-26 19:01:53 +02:00
|
|
|
|
|
|
|
# Set SSOwat rules
|
|
|
|
ynh_app_setting_set "$app" skipped_uris "/"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2020-03-31 05:07:19 +02:00
|
|
|
systemctl restart php5-fpm
|
|
|
|
systemctl reload nginx
|