2017-04-26 19:01:53 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
set -eu
|
|
|
|
#=================================================
|
|
|
|
# GENERIC STARTING
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
# Set app specific variables
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
# Check destination directory
|
|
|
|
DESTDIR="/var/www/$app"
|
|
|
|
[[ ! -d $DESTDIR ]] && ynh_die \
|
|
|
|
"The destination directory '$DESTDIR' does not exist.\
|
|
|
|
The app is not correctly installed, you should remove it first."
|
|
|
|
|
|
|
|
# Retrieve arguments
|
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
|
|
path_url=$(ynh_app_setting_get "$app" path_url)
|
|
|
|
path_url=$(ynh_normalize_url_path $path_url)
|
|
|
|
final_path=$(ynh_app_setting_get "$app" final_path)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
2017-12-03 18:15:11 +01:00
|
|
|
ynh_backup_before_upgrade # Backup the current version of the app
|
2017-04-26 19:01:53 +02:00
|
|
|
ynh_clean_setup () {
|
2017-12-03 18:15:11 +01:00
|
|
|
ynh_restore_upgradebackup # restore it if the upgrade fails
|
2017-04-26 19:01:53 +02:00
|
|
|
}
|
2017-12-03 18:15:11 +01:00
|
|
|
ynh_abort_if_errors # Active trap to stop script execution if an error occurs
|
2017-04-26 19:01:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Create tmp directory and fetch app inside
|
|
|
|
TMPDIR=$(ynh_mkdir_tmp)
|
|
|
|
extract_sources "$TMPDIR"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_system_user_create $app # Create dedicated user if not existing
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
|
|
|
|
2017-08-04 23:22:29 +02:00
|
|
|
# Remove last version (we don't keep whitelist)
|
|
|
|
ynh_secure_remove "$final_path"
|
|
|
|
|
2017-04-26 19:01:53 +02:00
|
|
|
# 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
|