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

trap et maj ynh 2.4

This commit is contained in:
ewilly 2016-05-23 21:40:55 +02:00
parent b6d9f89e5c
commit d1d000d8d9
7 changed files with 200 additions and 30 deletions

View file

@ -13,7 +13,7 @@
"email": "ewilly@neuf.fr"
},
"requirements": {
"yunohost": ">> 2.2.1.1"
"yunohost": ">= 2.4"
},
"multi_instance": "false",
"services": [
@ -42,7 +42,7 @@
"default": "/bozon"
},
{
"name": "public_site",
"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)"
@ -51,7 +51,7 @@
"default": "No"
},
{
"name": "default_lang",
"name": "language",
"ask": {
"en": "Default language",
"fr": "Langue par défaut"

90
manifest2.2.json Normal file
View file

@ -0,0 +1,90 @@
{
"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

@ -2,17 +2,25 @@
# 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
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
# 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)
# definie useful vars
app=bozon
parent_path=/var/www
final_path=$parent_path/$app
data_path=/home/yunohost.app/$app
#retrieve arguments
save_path=$1
domain=$(sudo yunohost app setting $app domain)
# backup sources & data
sudo cp -R $final_path/. $save_path/www/
sudo cp -R $data_path/. $save_path/datas/

View file

@ -5,17 +5,54 @@ set -e
# 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)
# retrieve arguments
domain=$1
path=$2
is_public=$3
default_lang=$4
filesize=$5
admin=$6
password=$7
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_admin=$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
app=bozon
parent_path=/var/www
final_path=$parent_path/$app
data_path=/home/yunohost.app/$app
@ -26,14 +63,14 @@ data_path=/home/yunohost.app/$app
# check domain/path availability
sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then
exit 1
touch /force_stop
fi
# 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"
exit 1
echo "Error : the chosen admin user does not exist"
touch /force_stop
fi
# retrieve stable version of bozon
@ -63,7 +100,7 @@ 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@default_language='en';@default_language='$default_lang';@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

View file

@ -5,15 +5,38 @@ set -e
# causes the shell to exit if you try to use an uninitialised variable
set -u
app=bozon
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
#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)
sudo rm -rf /var/www/$app
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
sudo rm -f /etc/php5/fpm/pool.d/$app.conf
sudo rm -rf /home/yunohost.app/$app
if [ -e "/var/www/$app" ]; then
echo "Delete app"
sudo rm -rf /var/www/$app
fi
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
fi
if [ -e "/etc/php5/fpm/pool.d/$app.conf" ]; then
echo "Delete fpm config"
sudo rm -f /etc/php5/fpm/pool.d/$app.conf
fi
if [ -e "/home/yunohost.app/$app" ]; then
echo "Delete datas"
sudo rm -rf /home/yunohost.app/$app
fi
# Restart services
sudo service php5-fpm restart || true
sudo service nginx restart || true
sudo yunohost app ssowatconf
echo -e "\e[0m"

View file

@ -5,16 +5,23 @@ set -e
# 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)
#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)
# definie useful vars
app=bozon
parent_path=/var/www
final_path=$parent_path/$app
data_path=/home/yunohost.app/$app
# retrieve arguments
save_path=$1
domain=$(sudo yunohost app setting $app domain)
# restore sources & data
sudo mv $save_path/www/. $final_path/
sudo mv $save_path/datas/. $data_path/

View file

@ -5,9 +5,14 @@ set -e
# causes the shell to exit if you try to use an uninitialised variable
set -u
app=bozon
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
# 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)