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:
parent
a68bb52b76
commit
89ebc9b076
7 changed files with 185 additions and 344 deletions
|
@ -1 +0,0 @@
|
||||||
333eccfc7bae5ff5a55a4de6e373ab9ffb0ba273
|
|
|
@ -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"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,31 +1,25 @@
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
# Exit on command errors and treat unset variables as an error
|
||||||
set -e
|
set -eu
|
||||||
# causes the shell to exit if you try to use an uninitialised variable
|
|
||||||
set -u
|
|
||||||
|
|
||||||
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
|
# Source YunoHost helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# retrieve arguments
|
# retrieve arguments
|
||||||
if [ $ynh_version = "2.4" ]; then
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
else
|
|
||||||
app=bozon
|
|
||||||
fi
|
|
||||||
save_path=$1
|
|
||||||
domain=$(sudo yunohost app setting $app domain)
|
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
parent_path=/var/www
|
parent_path=/var/www
|
||||||
final_path=$parent_path/$app
|
final_path="$parent_path"/"$app"
|
||||||
data_path=/home/yunohost.app/$app
|
data_path=/home/yunohost.app/"$app"
|
||||||
|
|
||||||
# backup sources & data
|
# backup sources & data
|
||||||
sudo cp -R $final_path/. $save_path/www/
|
ynh_backup "$final_path" "www"
|
||||||
sudo cp -R $data_path/. $save_path/datas/
|
ynh_backup "$data_path" "data"
|
||||||
|
|
||||||
# backup php-fpm, Nginx and YunoHost parameters
|
# backup Nginx and php-fpm
|
||||||
sudo cp -a /etc/yunohost/apps/$app/. $save_path/yunohost/
|
mkdir ./conf
|
||||||
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf $save_path/nginx.conf
|
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "conf/nginx.conf"
|
||||||
sudo cp -a /etc/php5/fpm/pool.d/$app.conf $save_path/php-fpm.conf
|
ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "conf/php-fpm.conf"
|
||||||
|
|
200
scripts/install
200
scripts/install
|
@ -1,168 +1,116 @@
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
# Exit on command errors and treat unset variables as an error
|
||||||
set -e
|
set -eu
|
||||||
# causes the shell to exit if you try to use an uninitialised variable
|
|
||||||
set -u
|
|
||||||
|
|
||||||
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
|
# Source YunoHost helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# retrieve arguments
|
# retrieve arguments
|
||||||
if [ $ynh_version = "2.4" ]; then
|
app=bozon
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
domain=$1
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
path=${2%/}
|
||||||
path=$YNH_APP_ARG_PATH
|
is_public=$3
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
language=$4
|
||||||
language=$YNH_APP_ARG_LANGUAGE
|
filesize=$5
|
||||||
filesize=$YNH_APP_ARG_FILESIZE
|
admin=$6
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
password=$7
|
||||||
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
|
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
parent_path=/var/www
|
parent_path=/var/www
|
||||||
final_path=$parent_path/$app
|
final_path="$parent_path"/"$app"
|
||||||
data_path=/home/yunohost.app/$app
|
data_path=/home/yunohost.app/"$app"
|
||||||
|
|
||||||
# remove trailing slash
|
|
||||||
[ "$path" != "/" ] && path=${path%/}
|
|
||||||
|
|
||||||
# check domain/path availability
|
# check domain/path availability
|
||||||
sudo yunohost app checkurl $domain$path -a $app
|
sudo yunohost app checkurl "${domain}${path}" -a "$app" || ynh_die "The path ${domain}${path} is not available for app installation."
|
||||||
if [[ ! $? -eq 0 ]]; then
|
|
||||||
touch /force_stop
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check that admin user is an existing account
|
# check that admin user is an existing account
|
||||||
sudo yunohost user list --json | grep -q "\"username\": \"$admin\""
|
ynh_user_exists "$admin" || ynh_die "The chosen admin user does not exist."
|
||||||
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
|
|
||||||
|
|
||||||
# add required packages
|
# 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
|
# copy files to final folder and set permissions
|
||||||
sudo find $final_path -type f -name ".htaccess" | xargs sudo rm
|
sudo find "$final_path" -type f -name ".htaccess" | xargs sudo rm
|
||||||
sudo chown -R root: $final_path
|
sudo chown -R root: "$final_path"
|
||||||
sudo find $final_path -type f | xargs sudo chmod 644
|
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 d | xargs sudo chmod 755
|
||||||
|
|
||||||
# configure config file
|
# 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
|
# create data folders
|
||||||
sudo mkdir -p $final_path/private
|
sudo mkdir -p "$final_path"/private
|
||||||
sudo mkdir -p $data_path/uploads
|
sudo mkdir -p "$data_path"/uploads
|
||||||
sudo ln -s $data_path/uploads $final_path/uploads
|
sudo ln -s "$data_path"/uploads "$final_path"/uploads
|
||||||
sudo mkdir -p $data_path/thumbs
|
sudo mkdir -p "$data_path"/thumbs
|
||||||
sudo ln -s $data_path/thumbs $final_path/thumbs
|
sudo ln -s "$data_path"/thumbs "$final_path"/thumbs
|
||||||
sudo chown -R www-data: $final_path/private
|
sudo chown -R www-data: "$final_path"/private
|
||||||
sudo chown -R www-data: $data_path/uploads
|
sudo chown -R www-data: "$data_path"/uploads
|
||||||
sudo chown -R www-data: $data_path/thumbs
|
sudo chown -R www-data: "$data_path"/thumbs
|
||||||
|
|
||||||
# configure nginx settings
|
# configure nginx settings
|
||||||
## path
|
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf
|
sed -i "s@YNH_EXAMPLE_PATH@${path}@g" ../conf/nginx.conf
|
||||||
sudo sed -i "s@YNH_EXAMPLE_ALIAS@$final_path@g" ../conf/nginx.conf
|
sed -i "s@YNH_EXAMPLE_ALIAS@${final_path}@g" ../conf/nginx.conf
|
||||||
sudo sed -i "s@YNH_EXAMPLE_APP@${app}@g" ../conf/nginx.conf
|
sed -i "s@YNH_EXAMPLE_APP@${app}@g" ../conf/nginx.conf
|
||||||
## file upload size limit
|
sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/nginx.conf
|
||||||
sudo sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/nginx.conf
|
sudo cp ../conf/nginx.conf "$nginx_conf"
|
||||||
## copy final
|
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
||||||
|
|
||||||
# copy and set php-fpm configuration
|
# 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_APP@${app}@g" ../conf/php-fpm.conf
|
||||||
sed -i "s@YNH_EXAMPLE_ALIAS@${final_path}@g" ../conf/php-fpm.conf
|
sed -i "s@YNH_EXAMPLE_ALIAS@${final_path}@g" ../conf/php-fpm.conf
|
||||||
## file upload size limit
|
sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/php-fpm.conf
|
||||||
sudo sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/php-fpm.conf
|
sed -i "s@YNH_POST_SIZE@${postsize}@g" ../conf/php-fpm.conf
|
||||||
postsize=${filesize%?}.1${filesize: -1}
|
|
||||||
sudo sed -i "s@YNH_POST_SIZE@${postsize}@g" ../conf/php-fpm.conf
|
|
||||||
## copy final and set permissions
|
## copy final and set permissions
|
||||||
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
|
||||||
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
|
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
|
||||||
sudo chown root: $phpfpm_conf
|
sudo chown root: "$phpfpm_conf"
|
||||||
sudo chmod 644 $phpfpm_conf
|
sudo chmod 644 "$phpfpm_conf"
|
||||||
|
|
||||||
# create the superadmin
|
# restart services
|
||||||
## set temporary public access
|
sudo service php5-fpm restart || true
|
||||||
sudo yunohost app setting $app unprotected_uris -v "/"
|
sudo service nginx reload || true
|
||||||
## start app
|
|
||||||
sudo service nginx reload
|
# set temporary public access
|
||||||
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
## fill the superadmin creation form
|
|
||||||
curl_path=$([ "$path" == "/" ] || echo $path)
|
# fill the superadmin creation form
|
||||||
curl -k -X POST \
|
curl_path=$([ "$path" == "/" ] || echo "$path")
|
||||||
|
curl https://"$domain""$curl_path"/ > /dev/null 2>&1
|
||||||
|
curl -X POST \
|
||||||
--data-urlencode creation="1" \
|
--data-urlencode creation="1" \
|
||||||
--data-urlencode login="$admin" \
|
--data-urlencode login="$admin" \
|
||||||
--data-urlencode pass="$password" \
|
--data-urlencode pass="$password" \
|
||||||
--data-urlencode confirm="$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 app is private, remove url to SSOWat conf from skipped_uris
|
||||||
if [ "$is_public" = "No" ];
|
if [ "$is_public" = "No" ];
|
||||||
then
|
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)
|
# 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')
|
domainluaregex=$(echo "$domain" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
|
||||||
pathluaregex=$(echo "$path" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
|
pathluaregex=$(echo "$path" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
|
||||||
# redirect to SSOwat login in
|
regexList="${domainluaregex}${pathluaregex}/index.php%?f=.+$","${domainluaregex}${pathluaregex}/index.php%?zipfolder=.+$","${domainluaregex}${pathluaregex}/private/temp/.+%.zip$","${domainluaregex}${pathluaregex}/core/js/.*$","${domainluaregex}${pathluaregex}/templates/.*$"
|
||||||
sudo yunohost app setting $app unprotected_uris -d
|
ynh_app_setting_set "$app" unprotected_regex "$regexList"
|
||||||
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/.*$"
|
sudo yunohost app ssowatconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# restart services
|
|
||||||
sudo service php5-fpm restart || true
|
|
||||||
sudo service nginx restart || true
|
|
||||||
sudo yunohost app ssowatconf
|
|
||||||
|
|
|
@ -1,42 +1,33 @@
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
# Exit on command errors and treat unset variables as an error
|
||||||
set -e
|
set -eu
|
||||||
# causes the shell to exit if you try to use an uninitialised variable
|
|
||||||
set -u
|
|
||||||
|
|
||||||
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
|
# Source YunoHost helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#retrieve arguments
|
#retrieve arguments
|
||||||
if [ $ynh_version = "2.4" ]; then
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
domain=$(ynh_app_setting_get "${app}" domain)
|
||||||
# Source app helpers
|
|
||||||
. /usr/share/yunohost/helpers
|
|
||||||
else
|
|
||||||
app=bozon
|
|
||||||
fi
|
|
||||||
domain=$(sudo yunohost app setting $app domain)
|
|
||||||
|
|
||||||
if [ -e "/var/www/$app" ]; then
|
if [ -e "/var/www/${app}" ]; then
|
||||||
echo "Delete app"
|
echo "Delete app"
|
||||||
sudo rm -rf /var/www/$app
|
sudo rm -rf /var/www/${app}
|
||||||
fi
|
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"
|
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
|
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"
|
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
|
fi
|
||||||
if [ -e "/home/yunohost.app/$app" ]; then
|
if [ -e "/home/yunohost.app/${app}" ]; then
|
||||||
echo "Delete datas"
|
echo "Delete datas"
|
||||||
sudo rm -rf /home/yunohost.app/$app
|
sudo rm -rf /home/yunohost.app/${app}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restart services
|
# Restart services
|
||||||
sudo service php5-fpm restart || true
|
sudo service php5-fpm restart || true
|
||||||
sudo service nginx restart || true
|
sudo service nginx reload || true
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
echo -e "\e[0m"
|
|
||||||
|
|
|
@ -1,45 +1,62 @@
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
# Exit on command errors and treat unset variables as an error
|
||||||
set -e
|
set -eu
|
||||||
# causes the shell to exit if you try to use an uninitialised variable
|
|
||||||
set -u
|
|
||||||
|
|
||||||
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
|
# Source YunoHost helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#retrieve arguments
|
#retrieve arguments
|
||||||
if [ $ynh_version = "2.4" ]; then
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
else
|
|
||||||
app=bozon
|
|
||||||
fi
|
|
||||||
save_path=$1
|
|
||||||
domain=$(sudo yunohost app setting $app domain)
|
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
app=bozon
|
|
||||||
parent_path=/var/www
|
parent_path=/var/www
|
||||||
final_path=$parent_path/$app
|
final_path="$parent_path"/"$app"
|
||||||
data_path=/home/yunohost.app/$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
|
# restore sources & data
|
||||||
sudo mv $save_path/www/. $final_path/
|
sudo cp -a ./www "$final_path"
|
||||||
sudo mv $save_path/datas/. $data_path/
|
sudo mkdir -p "$data_path"
|
||||||
|
sudo cp -a ./data/. "$data_path"
|
||||||
|
|
||||||
# restore permissions
|
# restore permissions
|
||||||
sudo chown -R root: $final_path
|
sudo chown -R root: "$final_path"
|
||||||
sudo find $final_path -type f | xargs sudo chmod 644
|
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 d | xargs sudo chmod 755
|
||||||
sudo chown -R www-data: $final_path/private
|
sudo chown -R www-data: "$final_path"/private
|
||||||
sudo chown -R www-data: $data_path/uploads
|
sudo chown -R www-data: "$data_path"/uploads
|
||||||
sudo chown -R www-data: $data_path/thumbs
|
sudo chown -R www-data: "$data_path"/thumbs
|
||||||
|
|
||||||
# restore php-fpm, Nginx and YunoHost parameters
|
# restore Nginx & php-fpm
|
||||||
sudo cp -a $save_path/yunohost/. /etc/yunohost/apps/$app/
|
sudo cp -a ./conf/nginx.conf "$nginx_conf"
|
||||||
sudo cp -a $save_path/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
sudo cp -a ./conf/php-fpm.conf "$phpfpm_conf"
|
||||||
sudo cp -a $save_path/php-fpm.conf /etc/php5/fpm/pool.d/$app.conf
|
|
||||||
|
|
||||||
# Restart services
|
# Restart services
|
||||||
sudo service php5-fpm restart || true
|
sudo service php5-fpm restart || true
|
||||||
sudo service nginx restart || true
|
sudo service nginx restart || true
|
||||||
sudo yunohost app ssowatconf
|
|
||||||
|
|
|
@ -1,84 +1,66 @@
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
# Exit on command errors and treat unset variables as an error
|
||||||
set -e
|
set -eu
|
||||||
# causes the shell to exit if you try to use an uninitialised variable
|
|
||||||
set -u
|
|
||||||
|
|
||||||
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
|
# Source YunoHost helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# retrieve arguments
|
# retrieve arguments
|
||||||
if [ $ynh_version = "2.4" ]; then
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
else
|
path=$(ynh_app_setting_get "$app" path)
|
||||||
app=bozon
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||||
fi
|
filesize=$(ynh_app_setting_get "$app" filesize)
|
||||||
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
|
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
parent_path=/var/www
|
parent_path=/var/www
|
||||||
data_path=/home/yunohost.app/$app
|
data_path=/home/yunohost.app/"$app"
|
||||||
final_path=$parent_path/$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
|
# download upstream_version version of bozon
|
||||||
stable=$(cat ../BoZoN-stable)
|
upstream_version=$(cat ../conf/upstream_version)
|
||||||
|
wget -nc --quiet https://github.com/broncowdd/BoZoN/archive/"$upstream_version".zip -P /tmp
|
||||||
# save app settings
|
sudo unzip -oq /tmp/"$upstream_version".zip -d /tmp
|
||||||
sudo yunohost app setting $app version -v "$stable"
|
sudo rsync -avz --exclude="config.php" --exclude=".htaccess" /tmp/BoZoN-"$upstream_version"/* "$final_path"
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# configure nginx settings
|
# configure nginx settings
|
||||||
## path
|
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
folder_path=${path%/}
|
sed -i "s@YNH_EXAMPLE_PATH@${path}@g" ../conf/nginx.conf
|
||||||
sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf
|
sed -i "s@YNH_EXAMPLE_ALIAS@${final_path}@g" ../conf/nginx.conf
|
||||||
sudo sed -i "s@YNH_EXAMPLE_ALIAS@$final_path@g" ../conf/nginx.conf
|
sed -i "s@YNH_EXAMPLE_APP@${app}@g" ../conf/nginx.conf
|
||||||
sudo sed -i "s@YNH_EXAMPLE_APP@${app}@g" ../conf/nginx.conf
|
sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/nginx.conf
|
||||||
## file upload size limit
|
sudo cp ../conf/nginx.conf "$nginx_conf"
|
||||||
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
|
|
||||||
|
|
||||||
# copy and set php-fpm configuration
|
# 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_APP@${app}@g" ../conf/php-fpm.conf
|
||||||
sed -i "s@YNH_EXAMPLE_ALIAS@${final_path}@g" ../conf/php-fpm.conf
|
sed -i "s@YNH_EXAMPLE_ALIAS@${final_path}@g" ../conf/php-fpm.conf
|
||||||
## file upload size limit
|
sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/php-fpm.conf
|
||||||
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
|
sudo sed -i "s@YNH_POST_SIZE@${postsize}@g" ../conf/php-fpm.conf
|
||||||
## copy final and set permissions
|
## copy final and set permissions
|
||||||
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
|
||||||
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
|
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
|
||||||
sudo chown root: $phpfpm_conf
|
sudo chown root: "$phpfpm_conf"
|
||||||
sudo chmod 644 $phpfpm_conf
|
sudo chmod 644 "$phpfpm_conf"
|
||||||
|
|
||||||
# if app is private, remove url to SSOWat conf from skipped_uris
|
# if app is private, remove url to SSOWat conf from skipped_uris
|
||||||
if [ "$is_public" = "No" ];
|
if [ "$is_public" = "No" ];
|
||||||
then
|
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)
|
# 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')
|
domainluaregex=$(echo "$domain" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
|
||||||
pathluaregex=$(echo "$path" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
|
pathluaregex=$(echo "$path" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
|
||||||
# redirect to SSOwat login in
|
regexList="${domainluaregex}${pathluaregex}/index.php%?f=.+$","${domainluaregex}${pathluaregex}/index.php%?zipfolder=.+$","${domainluaregex}${pathluaregex}/private/temp/.+%.zip$","${domainluaregex}${pathluaregex}/core/js/.*$","${domainluaregex}${pathluaregex}/templates/.*$"
|
||||||
sudo yunohost app setting $app unprotected_uris -d
|
ynh_app_setting_set "$app" unprotected_regex "$regexList"
|
||||||
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/.*$"
|
sudo yunohost app ssowatconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restart services
|
# Restart services
|
||||||
sudo service php5-fpm restart || true
|
sudo service php5-fpm restart || true
|
||||||
sudo service nginx restart || true
|
sudo service nginx reload || true
|
||||||
sudo yunohost app ssowatconf
|
|
||||||
|
|
Loading…
Reference in a new issue