mirror of
https://github.com/YunoHost-Apps/bozon_ynh.git
synced 2024-09-03 18:16:09 +02:00
16ef7053e6
* Correct restore script `ynh_package_install_from_equivs` * Change in each script `#! /bin/bash` with `#!/bin/bash` * Correct `pathluaregex` in case of a installation on root
66 lines
2.8 KiB
Bash
66 lines
2.8 KiB
Bash
#!/bin/bash
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
set -eu
|
|
|
|
# Source YunoHost helpers
|
|
source /usr/share/yunohost/helpers
|
|
|
|
# retrieve arguments
|
|
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)
|
|
|
|
# definie useful vars
|
|
parent_path=/var/www
|
|
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
|
|
|
|
# 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"
|
|
|
|
# configure nginx settings
|
|
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"
|
|
|
|
# copy and set php-fpm configuration
|
|
postsize=${filesize%?}.1${filesize: -1}
|
|
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
|
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
|
|
sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/php-fpm.conf
|
|
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"
|
|
sudo chown root: "$phpfpm_conf"
|
|
sudo chmod 644 "$phpfpm_conf"
|
|
|
|
# if app is private, remove url to SSOWat conf from skipped_uris
|
|
if [ "$is_public" = "No" ];
|
|
then
|
|
ynh_app_setting_delete "$app" unprotected_uris
|
|
# 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')
|
|
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
|
|
fi
|
|
|
|
# Restart services
|
|
sudo service php5-fpm restart || true
|
|
sudo service nginx reload || true
|