1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/bozon_ynh.git synced 2024-09-03 18:16:09 +02:00

Update to BoZon 2.16

This commit is contained in:
ewilly 2016-10-13 06:51:38 +02:00
parent a68bb52b76
commit 89ebc9b076
7 changed files with 185 additions and 344 deletions

View file

@ -1 +0,0 @@
333eccfc7bae5ff5a55a4de6e373ab9ffb0ba273

View file

@ -1,90 +0,0 @@
{
"name": "BoZoN",
"id": "bozon",
"packaging_format": 1,
"description": {
"en": "Minimalist Drag & drop file sharing app",
"fr": "Application minimaliste de partage de fichiers"
},
"url": "http://bozon.pw",
"license": "free",
"maintainer": {
"name": "ewilly",
"email": "ewilly@neuf.fr"
},
"requirements": {
"yunohost": ">> 2.2.1.1"
},
"multi_instance": "false",
"services": [
"nginx",
"php5-fpm"
],
"arguments": {
"install" : [
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain for BoZoN",
"fr": "Choisissez un domaine pour BoZoN"
},
"example": "domain.org"
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for BoZoN",
"fr": "Choisissez un chemin pour BoZoN"
},
"example": "/bozon",
"default": "/bozon"
},
{
"name": "is_public",
"ask": {
"en": "Should this application be public ? (if not, sharing file with unregistered users still work)",
"fr": "Est-ce que cette application doit être visible publiquement ? (dans le cas contraire, le partage de fichiers avec des utilisateurs externes fonctionnera tout de même)"
},
"choices": ["Yes", "No"],
"default": "No"
},
{
"name": "language",
"ask": {
"en": "Default language",
"fr": "Langue par défaut"
},
"choices": ["de","en","es","fr"],
"default": "en"
},
{
"name": "filesize",
"ask": {
"en": "Define the file upload size limit",
"fr": "Définissez la taille limite de téléchargement"
},
"default": "2G"
},
{
"name": "admin",
"type": "user",
"ask": {
"en": "Choose an admin user for BoZoN",
"fr": "Choisissez un administrateur pour BoZoN"
},
"example": "homer"
},
{
"name": "password",
"type": "password",
"ask": {
"en": "Choose an admin password for BoZoN",
"fr": "Choisissez un mot de passe administrateur pour BoZoN"
},
"example": "super_secret_password"
}
]
}
}

View file

@ -1,31 +1,25 @@
#! /bin/bash
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
set -e
# causes the shell to exit if you try to use an uninitialised variable
set -u
# Exit on command errors and treat unset variables as an error
set -eu
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# retrieve arguments
if [ $ynh_version = "2.4" ]; then
app=$YNH_APP_INSTANCE_NAME
else
app=bozon
fi
save_path=$1
domain=$(sudo yunohost app setting $app domain)
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
# definie useful vars
parent_path=/var/www
final_path=$parent_path/$app
data_path=/home/yunohost.app/$app
final_path="$parent_path"/"$app"
data_path=/home/yunohost.app/"$app"
# backup sources & data
sudo cp -R $final_path/. $save_path/www/
sudo cp -R $data_path/. $save_path/datas/
ynh_backup "$final_path" "www"
ynh_backup "$data_path" "data"
# backup php-fpm, Nginx and YunoHost parameters
sudo cp -a /etc/yunohost/apps/$app/. $save_path/yunohost/
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf $save_path/nginx.conf
sudo cp -a /etc/php5/fpm/pool.d/$app.conf $save_path/php-fpm.conf
# backup Nginx and php-fpm
mkdir ./conf
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "conf/nginx.conf"
ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "conf/php-fpm.conf"

View file

@ -1,168 +1,116 @@
#! /bin/bash
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
set -e
# causes the shell to exit if you try to use an uninitialised variable
set -u
# Exit on command errors and treat unset variables as an error
set -eu
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# retrieve arguments
if [ $ynh_version = "2.4" ]; then
app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
language=$YNH_APP_ARG_LANGUAGE
filesize=$YNH_APP_ARG_FILESIZE
admin=$YNH_APP_ARG_ADMIN
password=$YNH_APP_ARG_PASSWORD
# Source app helpers
. /usr/share/yunohost/helpers
else
app=bozon
domain=$1
path=$2
is_public=$3
language=$4
filesize=$5
admin=$6
password=$7
fi
# Delete files and db if exit with an error
EXIT_PROPERLY () {
trap '' ERR
echo -e "\e[91m \e[1m" # Shell in light red bold
echo -e "!!\n $app install's script has encountered an error. Installation was cancelled.\n!!"
if [ $ynh_version = "2.2" ]; then
/bin/bash ./remove # Appel le script remove. En 2.2, ce comportement n'est pas automatique.
fi
exit 1
}
TRAP_ON () { # Activate signal capture
trap EXIT_PROPERLY ERR # Capturing exit signals on error
}
TRAP_OFF () { # Ignoring signal capture until TRAP_ON
# Pour une raison que j'ignore, la fonction TRAP_ON fonctionne très bien.
# Mais pas la fonction TRAP_OFF...
# Utiliser directement `trap '' ERR` dans le code pour l'utiliser, à la place de la fonction.
trap '' ERR # Ignoring exit signals
}
TRAP_ON
app=bozon
domain=$1
path=${2%/}
is_public=$3
language=$4
filesize=$5
admin=$6
password=$7
# definie useful vars
parent_path=/var/www
final_path=$parent_path/$app
data_path=/home/yunohost.app/$app
# remove trailing slash
[ "$path" != "/" ] && path=${path%/}
final_path="$parent_path"/"$app"
data_path=/home/yunohost.app/"$app"
# check domain/path availability
sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then
touch /force_stop
fi
sudo yunohost app checkurl "${domain}${path}" -a "$app" || ynh_die "The path ${domain}${path} is not available for app installation."
# check that admin user is an existing account
sudo yunohost user list --json | grep -q "\"username\": \"$admin\""
if [[ ! $? -eq 0 ]]; then
echo "Error : the chosen admin user does not exist"
touch /force_stop
fi
# retrieve stable version of bozon
stable=$(cat ../BoZoN-stable)
# save app settings
sudo yunohost app setting $app admin_user -v "$admin"
sudo yunohost app setting $app is_public -v "$is_public"
sudo yunohost app setting $app domain -v "$domain"
sudo yunohost app setting $app path -v "$path"
sudo yunohost app setting $app version -v "$stable"
sudo yunohost app setting $app filesize -v "$filesize"
# download stable version of bozon
sudo wget https://github.com/broncowdd/BoZoN/archive/$stable.zip -O $parent_path/bozon-$stable.zip
sudo unzip $parent_path/bozon-$stable.zip -d $parent_path/
sudo rm $parent_path/bozon-$stable.zip
sudo mv $parent_path/BoZoN-* $parent_path/$app
ynh_user_exists "$admin" || ynh_die "The chosen admin user does not exist."
# add required packages
sudo apt-get install php5-curl php5-gd
ynh_package_is_installed "php5-curl" || ynh_package_install "php5-curl"
ynh_package_is_installed "php5-gd" || ynh_package_install "php5-gd"
# retrieve upstream_version version of bozon
upstream_version=$(cat ../conf/upstream_version)
# save app settings
ynh_app_setting_set "$app" admin_user "$admin"
ynh_app_setting_set "$app" is_public "$is_public"
ynh_app_setting_set "$app" domain "$domain"
ynh_app_setting_set "$app" path "$path"
ynh_app_setting_set "$app" filesize "$filesize"
# download upstream_version version of bozon
wget -nc --quiet https://github.com/broncowdd/BoZoN/archive/"$upstream_version".zip -P /tmp
sudo unzip -oq /tmp/"$upstream_version".zip -d /tmp
sudo mv /tmp/BoZoN-"$upstream_version" "$parent_path"/"$app"
# copy files to final folder and set permissions
sudo find $final_path -type f -name ".htaccess" | xargs sudo rm
sudo chown -R root: $final_path
sudo find $final_path -type f | xargs sudo chmod 644
sudo find $final_path -type d | xargs sudo chmod 755
sudo find "$final_path" -type f -name ".htaccess" | xargs sudo rm
sudo chown -R root: "$final_path"
sudo find "$final_path" -type f | xargs sudo chmod 644
sudo find "$final_path" -type d | xargs sudo chmod 755
# configure config file
sudo sed -i "s@languageuage='en';@languageuage='$language';@g" $final_path/config.php
sudo sed -i "s@languageuage='en';@languageuage='${language}';@g" "$final_path"/config.php
# create data folders
sudo mkdir -p $final_path/private
sudo mkdir -p $data_path/uploads
sudo ln -s $data_path/uploads $final_path/uploads
sudo mkdir -p $data_path/thumbs
sudo ln -s $data_path/thumbs $final_path/thumbs
sudo chown -R www-data: $final_path/private
sudo chown -R www-data: $data_path/uploads
sudo chown -R www-data: $data_path/thumbs
sudo mkdir -p "$final_path"/private
sudo mkdir -p "$data_path"/uploads
sudo ln -s "$data_path"/uploads "$final_path"/uploads
sudo mkdir -p "$data_path"/thumbs
sudo ln -s "$data_path"/thumbs "$final_path"/thumbs
sudo chown -R www-data: "$final_path"/private
sudo chown -R www-data: "$data_path"/uploads
sudo chown -R www-data: "$data_path"/thumbs
# configure nginx settings
## path
sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf
sudo sed -i "s@YNH_EXAMPLE_ALIAS@$final_path@g" ../conf/nginx.conf
sudo sed -i "s@YNH_EXAMPLE_APP@${app}@g" ../conf/nginx.conf
## file upload size limit
sudo sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/nginx.conf
## copy final
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
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
## path
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
## file upload size limit
sudo sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/php-fpm.conf
postsize=${filesize%?}.1${filesize: -1}
sudo sed -i "s@YNH_POST_SIZE@${postsize}@g" ../conf/php-fpm.conf
sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/php-fpm.conf
sed -i "s@YNH_POST_SIZE@${postsize}@g" ../conf/php-fpm.conf
## copy final and set permissions
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
sudo chown root: $phpfpm_conf
sudo chmod 644 $phpfpm_conf
sudo chown root: "$phpfpm_conf"
sudo chmod 644 "$phpfpm_conf"
# create the superadmin
## set temporary public access
sudo yunohost app setting $app unprotected_uris -v "/"
## start app
sudo service nginx reload
# restart services
sudo service php5-fpm restart || true
sudo service nginx reload || true
# set temporary public access
ynh_app_setting_set "$app" unprotected_uris "/"
sudo yunohost app ssowatconf
## fill the superadmin creation form
curl_path=$([ "$path" == "/" ] || echo $path)
curl -k -X POST \
# fill the superadmin creation form
curl_path=$([ "$path" == "/" ] || echo "$path")
curl https://"$domain""$curl_path"/ > /dev/null 2>&1
curl -X POST \
--data-urlencode creation="1" \
--data-urlencode login="$admin" \
--data-urlencode pass="$password" \
--data-urlencode confirm="$password" \
https://$domain$curl_path/index.php?p=admin > /dev/null 2>&1
https://"$domain""$curl_path"/index.php?p=login > /dev/null 2>&1
# 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')
# redirect to SSOwat login in
sudo yunohost app setting $app unprotected_uris -d
sudo yunohost app setting $app unprotected_regex -v "$domainluaregex$pathluaregex/index.php%?f=.+$","$domainluaregex$pathluaregex/index.php%?zipfolder=.+$","$domainluaregex$pathluaregex/private/temp/.+%.zip$","$domainluaregex$pathluaregex/core/js/.*$","$domainluaregex$pathluaregex/templates/.*$"
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 restart || true
sudo yunohost app ssowatconf

View file

@ -1,42 +1,33 @@
#! /bin/bash
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
set -e
# causes the shell to exit if you try to use an uninitialised variable
set -u
# Exit on command errors and treat unset variables as an error
set -eu
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
# Source YunoHost helpers
source /usr/share/yunohost/helpers
#retrieve arguments
if [ $ynh_version = "2.4" ]; then
app=$YNH_APP_INSTANCE_NAME
# Source app helpers
. /usr/share/yunohost/helpers
else
app=bozon
fi
domain=$(sudo yunohost app setting $app domain)
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "${app}" domain)
if [ -e "/var/www/$app" ]; then
if [ -e "/var/www/${app}" ]; then
echo "Delete app"
sudo rm -rf /var/www/$app
sudo rm -rf /var/www/${app}
fi
if [ -e "/etc/nginx/conf.d/$domain.d/$app.conf" ]; then
if [ -e "/etc/nginx/conf.d/${domain}.d/${app}.conf" ]; then
echo "Delete Nginx config"
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
sudo rm -f /etc/nginx/conf.d/${domain}.d/${app}.conf
fi
if [ -e "/etc/php5/fpm/pool.d/$app.conf" ]; then
if [ -e "/etc/php5/fpm/pool.d/${app}.conf" ]; then
echo "Delete fpm config"
sudo rm -f /etc/php5/fpm/pool.d/$app.conf
sudo rm -f /etc/php5/fpm/pool.d/${app}.conf
fi
if [ -e "/home/yunohost.app/$app" ]; then
if [ -e "/home/yunohost.app/${app}" ]; then
echo "Delete datas"
sudo rm -rf /home/yunohost.app/$app
sudo rm -rf /home/yunohost.app/${app}
fi
# Restart services
sudo service php5-fpm restart || true
sudo service nginx restart || true
sudo service nginx reload || true
sudo yunohost app ssowatconf
echo -e "\e[0m"

View file

@ -1,45 +1,62 @@
#! /bin/bash
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
set -e
# causes the shell to exit if you try to use an uninitialised variable
set -u
# Exit on command errors and treat unset variables as an error
set -eu
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
# Source YunoHost helpers
source /usr/share/yunohost/helpers
#retrieve arguments
if [ $ynh_version = "2.4" ]; then
app=$YNH_APP_INSTANCE_NAME
else
app=bozon
fi
save_path=$1
domain=$(sudo yunohost app setting $app domain)
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
# definie useful vars
app=bozon
parent_path=/var/www
final_path=$parent_path/$app
data_path=/home/yunohost.app/$app
final_path="$parent_path"/"$app"
data_path=/home/yunohost.app/"$app"
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
# check domain/path availability with app helper
sudo yunohost app checkurl $domain$path -a $app \
|| ynh_die "The path ${domain}${path} is not available for app installation."
# check directories availability
[[ -d $final_path ]] && ynh_die \
"The path '${final_path}' already exists.
You should safely delete it before restoring this app."
[[ -d $data_path ]] && ynh_die \
"The path '${data_path}' already exists.
You should safely delete it before restoring this app."
# check configuration files
[[ -f $nginx_conf ]] && ynh_die \
"The NGINX configuration already exists at '${nginx_conf}'.
You should safely delete it before restoring this app."
[[ -f $phpfpm_conf ]] && ynh_die \
"The PHP FPM configuration already exists at '${phpfpm_conf}'.
You should safely delete it before restoring this app."
# add required packages
ynh_package_install_from_equivs ../conf/${app}-deps.control || ynh_die "Unable to install dependencies"
# restore sources & data
sudo mv $save_path/www/. $final_path/
sudo mv $save_path/datas/. $data_path/
sudo cp -a ./www "$final_path"
sudo mkdir -p "$data_path"
sudo cp -a ./data/. "$data_path"
# restore permissions
sudo chown -R root: $final_path
sudo find $final_path -type f | xargs sudo chmod 644
sudo find $final_path -type d | xargs sudo chmod 755
sudo chown -R www-data: $final_path/private
sudo chown -R www-data: $data_path/uploads
sudo chown -R www-data: $data_path/thumbs
sudo chown -R root: "$final_path"
sudo find "$final_path" -type f | xargs sudo chmod 644
sudo find "$final_path" -type d | xargs sudo chmod 755
sudo chown -R www-data: "$final_path"/private
sudo chown -R www-data: "$data_path"/uploads
sudo chown -R www-data: "$data_path"/thumbs
# restore php-fpm, Nginx and YunoHost parameters
sudo cp -a $save_path/yunohost/. /etc/yunohost/apps/$app/
sudo cp -a $save_path/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
sudo cp -a $save_path/php-fpm.conf /etc/php5/fpm/pool.d/$app.conf
# restore Nginx & php-fpm
sudo cp -a ./conf/nginx.conf "$nginx_conf"
sudo cp -a ./conf/php-fpm.conf "$phpfpm_conf"
# Restart services
sudo service php5-fpm restart || true
sudo service nginx restart || true
sudo yunohost app ssowatconf

View file

@ -1,84 +1,66 @@
#! /bin/bash
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
set -e
# causes the shell to exit if you try to use an uninitialised variable
set -u
# Exit on command errors and treat unset variables as an error
set -eu
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# retrieve arguments
if [ $ynh_version = "2.4" ]; then
app=$YNH_APP_INSTANCE_NAME
else
app=bozon
fi
path=$(sudo yunohost app setting $app path)
stable=$(sudo yunohost app setting $app version)
is_public=$(sudo yunohost app setting $app is_public)
filesize=$(sudo yunohost app setting $app filesize)
domain=$(sudo yunohost app setting $app domain)
if [ "${#filesize}" -eq 0 ]
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.*(?=;)')
sudo yunohost app setting $app filesize -v "$filesize"
fi
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
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
# retrieve stable version of bozon
stable=$(cat ../BoZoN-stable)
# save app settings
sudo yunohost app setting $app version -v "$stable"
# download stable version of bozon
sudo wget https://github.com/broncowdd/BoZoN/archive/$stable.zip -O $parent_path/bozon-$stable.zip
sudo unzip $parent_path/bozon-$stable.zip -d $parent_path/
sudo rm $parent_path/bozon-$stable.zip
sudo rsync -avz --exclude="config.php" --exclude=".htaccess" $parent_path/BoZoN-$stable/* $final_path
sudo rm -R $parent_path/BoZoN-$stable
# 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
## path
folder_path=${path%/}
sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf
sudo sed -i "s@YNH_EXAMPLE_ALIAS@$final_path@g" ../conf/nginx.conf
sudo sed -i "s@YNH_EXAMPLE_APP@${app}@g" ../conf/nginx.conf
## file upload size limit
sudo sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/nginx.conf
## copy final
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
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
## path
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
## file upload size limit
sudo sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/php-fpm.conf
postsize=${filesize%?}.1${filesize: -1}
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
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
sudo chown root: $phpfpm_conf
sudo chmod 644 $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')
# redirect to SSOwat login in
sudo yunohost app setting $app unprotected_uris -d
sudo yunohost app setting $app unprotected_regex -v "$domainluaregex$pathluaregex/index.php%?f=.+$","$domainluaregex$pathluaregex/index.php%?zipfolder=.+$","$domainluaregex$pathluaregex/private/temp/.+%.zip$","$domainluaregex$pathluaregex/core/js/.*$","$domainluaregex$pathluaregex/templates/.*$"
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 restart || true
sudo yunohost app ssowatconf
sudo service nginx reload || true