2017-01-08 12:17:57 +01:00
|
|
|
#!/bin/bash
|
2016-03-23 19:30:43 +01:00
|
|
|
|
2016-10-13 06:51:38 +02:00
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
set -eu
|
2016-04-04 22:35:43 +02:00
|
|
|
|
2016-10-13 06:51:38 +02:00
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
2016-04-26 20:37:18 +02:00
|
|
|
|
2016-04-26 20:17:50 +02:00
|
|
|
# retrieve arguments
|
2016-10-13 06:51:38 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
|
|
path=$(ynh_app_setting_get "$app" path)
|
|
|
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
|
|
|
filesize=$(ynh_app_setting_get "$app" filesize)
|
2016-04-26 20:17:50 +02:00
|
|
|
|
|
|
|
# definie useful vars
|
2016-04-04 20:01:54 +02:00
|
|
|
parent_path=/var/www
|
2016-10-13 06:51:38 +02:00
|
|
|
data_path=/home/yunohost.app/"$app"
|
|
|
|
final_path=$parent_path/"$app"
|
|
|
|
if [ -z "$filesize" ]
|
|
|
|
then # in old script filesize was not saved as an setting
|
|
|
|
filesize=$(cat /etc/nginx/conf.d/"$domain".d/"$app".conf | grep -Po 'client_max_body_size \K.*(?=;)')
|
|
|
|
ynh_app_setting_set "$app" filesize "$filesize"
|
|
|
|
fi
|
2016-04-26 20:39:15 +02:00
|
|
|
|
2016-10-13 06:51:38 +02:00
|
|
|
# download upstream_version version of bozon
|
|
|
|
upstream_version=$(cat ../conf/upstream_version)
|
|
|
|
wget -nc --quiet https://github.com/broncowdd/BoZoN/archive/"$upstream_version".zip -P /tmp
|
|
|
|
sudo unzip -oq /tmp/"$upstream_version".zip -d /tmp
|
|
|
|
sudo rsync -avz --exclude="config.php" --exclude=".htaccess" /tmp/BoZoN-"$upstream_version"/* "$final_path"
|
2016-04-26 20:17:50 +02:00
|
|
|
|
|
|
|
# configure nginx settings
|
2016-10-13 06:51:38 +02:00
|
|
|
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
|
|
|
sed -i "s@YNH_EXAMPLE_PATH@${path}@g" ../conf/nginx.conf
|
|
|
|
sed -i "s@YNH_EXAMPLE_ALIAS@${final_path}@g" ../conf/nginx.conf
|
|
|
|
sed -i "s@YNH_EXAMPLE_APP@${app}@g" ../conf/nginx.conf
|
|
|
|
sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/nginx.conf
|
|
|
|
sudo cp ../conf/nginx.conf "$nginx_conf"
|
2016-03-23 19:30:43 +01:00
|
|
|
|
2016-05-23 20:59:08 +02:00
|
|
|
# copy and set php-fpm configuration
|
2016-10-13 06:51:38 +02:00
|
|
|
postsize=${filesize%?}.1${filesize: -1}
|
|
|
|
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
2016-05-23 20:59:08 +02:00
|
|
|
sed -i "s@YNH_EXAMPLE_APP@${app}@g" ../conf/php-fpm.conf
|
|
|
|
sed -i "s@YNH_EXAMPLE_ALIAS@${final_path}@g" ../conf/php-fpm.conf
|
2016-10-13 06:51:38 +02:00
|
|
|
sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/php-fpm.conf
|
2016-05-23 20:59:08 +02:00
|
|
|
sudo sed -i "s@YNH_POST_SIZE@${postsize}@g" ../conf/php-fpm.conf
|
|
|
|
## copy final and set permissions
|
|
|
|
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
|
2016-10-13 06:51:38 +02:00
|
|
|
sudo chown root: "$phpfpm_conf"
|
|
|
|
sudo chmod 644 "$phpfpm_conf"
|
2016-05-23 20:59:08 +02:00
|
|
|
|
2016-04-26 20:17:50 +02:00
|
|
|
# if app is private, remove url to SSOWat conf from skipped_uris
|
|
|
|
if [ "$is_public" = "No" ];
|
|
|
|
then
|
2016-10-13 06:51:38 +02:00
|
|
|
ynh_app_setting_delete "$app" unprotected_uris
|
2016-04-26 20:17:50 +02:00
|
|
|
# escape magic chars in vars (lua magic chars are ().%+-*?[^$ according to https://www.lua.org/pil/20.2.html)
|
|
|
|
domainluaregex=$(echo "$domain" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
|
|
|
|
pathluaregex=$(echo "$path" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
|
2016-10-13 06:51:38 +02:00
|
|
|
regexList="${domainluaregex}${pathluaregex}/index.php%?f=.+$","${domainluaregex}${pathluaregex}/index.php%?zipfolder=.+$","${domainluaregex}${pathluaregex}/private/temp/.+%.zip$","${domainluaregex}${pathluaregex}/core/js/.*$","${domainluaregex}${pathluaregex}/templates/.*$"
|
|
|
|
ynh_app_setting_set "$app" unprotected_regex "$regexList"
|
|
|
|
sudo yunohost app ssowatconf
|
2016-04-26 20:17:50 +02:00
|
|
|
fi
|
2016-03-23 19:30:43 +01:00
|
|
|
|
|
|
|
# Restart services
|
2016-05-23 20:59:08 +02:00
|
|
|
sudo service php5-fpm restart || true
|
2016-10-13 06:51:38 +02:00
|
|
|
sudo service nginx reload || true
|