mirror of
https://github.com/YunoHost-Apps/leed_ynh.git
synced 2024-09-03 19:26:32 +02:00
trap et maj ynh 2.4
This commit is contained in:
parent
6dbebfab25
commit
3cfaaaa5d3
7 changed files with 219 additions and 33 deletions
|
@ -2,6 +2,9 @@
|
|||
"name": "Leed",
|
||||
"id": "leed",
|
||||
"packaging_format": 1,
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.4"
|
||||
},
|
||||
"description": {
|
||||
"en": "Leed is a minimalistic RSS feed aggregator which allows quick and non-intrusive reading of feeds.",
|
||||
"fr": "Leed est un agrégateur RSS minimaliste qui permet la consultation de flux RSS de manière rapide et non intrusive."
|
||||
|
|
87
manifest2.2.json
Normal file
87
manifest2.2.json
Normal file
|
@ -0,0 +1,87 @@
|
|||
{
|
||||
"name": "Leed",
|
||||
"id": "leed",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Leed is a minimalistic RSS feed aggregator which allows quick and non-intrusive reading of feeds.",
|
||||
"fr": "Leed est un agrégateur RSS minimaliste qui permet la consultation de flux RSS de manière rapide et non intrusive."
|
||||
},
|
||||
"version": "1.6",
|
||||
"url": "http://leed.idleman.fr/",
|
||||
"licence": "free",
|
||||
"maintainer": {
|
||||
"name": "Maniack Crudelis",
|
||||
"email": "maniackc_dev@crudelis.fr"
|
||||
},
|
||||
"multi_instance": "true",
|
||||
"services": [
|
||||
"nginx",
|
||||
"php5-fpm",
|
||||
"mysql"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for Leed",
|
||||
"fr": "Choisissez un domaine pour Leed"
|
||||
},
|
||||
"example": "domain.org"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for Leed",
|
||||
"fr": "Choisissez un chemin pour Leed"
|
||||
},
|
||||
"example": "/leed",
|
||||
"default": "/leed"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"ask": {
|
||||
"en": "Choose the Leed administrator (must be an existing YunoHost user)",
|
||||
"fr": "Choisissez un administrateur Leed (doit être un utilisateur YunoHost)"
|
||||
},
|
||||
"example": "john"
|
||||
},
|
||||
{
|
||||
"name": "password",
|
||||
"type": "password",
|
||||
"ask": {
|
||||
"en": "Set the administrator password Leed",
|
||||
"fr": "Définissez le mot de passe administrateur de Leed"
|
||||
},
|
||||
"example": "Choose a password"
|
||||
},
|
||||
{
|
||||
"name": "language",
|
||||
"ask": {
|
||||
"en": "Choose your agregator's language",
|
||||
"fr": "Choisissez la langue de votre agrégateur"
|
||||
},
|
||||
"choices" : ["en", "fr", "es"],
|
||||
"default" : "en"
|
||||
},
|
||||
{
|
||||
"name": "market",
|
||||
"ask": {
|
||||
"en": "Do you want to activate the Leed Market?",
|
||||
"fr": "Voulez-vous activer le Leed Market ?"
|
||||
},
|
||||
"choices": ["Yes", "No"],
|
||||
"default": "No"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"ask": {
|
||||
"en": "Is it a public website ?",
|
||||
"fr": "Est-ce un site public ?"
|
||||
},
|
||||
"choices": ["Yes", "No"],
|
||||
"default": "No"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,7 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Récupère les infos de l'application.
|
||||
app=leed
|
||||
version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
|
||||
if [ $version = "2.4" ]; then
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
else
|
||||
app=leed
|
||||
fi
|
||||
final_path=$(sudo yunohost app setting $app final_path)
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
|
||||
|
|
|
@ -1,32 +1,78 @@
|
|||
#!/bin/bash
|
||||
|
||||
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
|
||||
# Retrieve arguments
|
||||
domain=$1
|
||||
path=$2
|
||||
admin=$3
|
||||
user_pwd=$4
|
||||
language=$5
|
||||
market=$6
|
||||
is_public=$7
|
||||
app=leed
|
||||
if [ $ynh_version = "2.4" ]
|
||||
then
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path=$YNH_APP_ARG_PATH
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
user_pwd=$YNH_APP_ARG_PASSWORD
|
||||
language=$YNH_APP_ARG_LANGUAGE
|
||||
market=$YNH_APP_ARG_MARKET
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
else
|
||||
domain=$1
|
||||
path=$2
|
||||
admin=$3
|
||||
user_pwd=$4
|
||||
language=$5
|
||||
market=$6
|
||||
is_public=$7
|
||||
app=leed
|
||||
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!!"
|
||||
|
||||
echo -e "\e[22m" # Remove bold
|
||||
|
||||
# Clean hosts
|
||||
sudo sed -i '/#leed/d' /etc/hosts
|
||||
|
||||
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
|
||||
|
||||
|
||||
# Vérifie la validité de l'user admin
|
||||
sudo yunohost user list --json | grep -q "\"username\": \"$admin\""
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
echo "Wrong admin"
|
||||
exit 1
|
||||
touch /force_stop
|
||||
fi
|
||||
|
||||
# Vérifie la disponibilité du path et du domaine.
|
||||
sudo yunohost app checkurl $domain$path -a $app
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
exit 1
|
||||
touch /force_stop
|
||||
fi
|
||||
|
||||
# Vérifie que le mot de passe n'est pas vide.
|
||||
if [[ -z $user_pwd ]]; then
|
||||
echo "Mot de passe incorrect"
|
||||
exit 1
|
||||
touch /force_stop
|
||||
fi
|
||||
|
||||
# Vérifie que le dossier de destination n'est pas déjà utilisé.
|
||||
|
@ -34,7 +80,7 @@ final_path=/var/www/$app
|
|||
if [ -e "$final_path" ]
|
||||
then
|
||||
echo "This path already contains a folder"
|
||||
exit 1
|
||||
touch /force_stop
|
||||
fi
|
||||
|
||||
# Vérifie la présence du / en début de path
|
||||
|
@ -49,11 +95,15 @@ sudo yunohost app setting $app language -v $language
|
|||
sudo yunohost app setting $app domain -v $domain
|
||||
|
||||
# Génère un mot de passe aléatoire.
|
||||
db_pwd=$(cat /dev/urandom | head -n20 | tr -c -d 'A-Za-z0-9' | head -c20)
|
||||
db_pwd=$(head -n20 /dev/urandom | tr -c -d 'A-Za-z0-9' | head -c20)
|
||||
# Utilise '$app' comme nom d'utilisateur et de base de donnée
|
||||
db_user=$app
|
||||
# Initialise la base de donnée et stocke le mot de passe mysql.
|
||||
sudo yunohost app initdb $db_user -p $db_pwd
|
||||
if [ $ynh_version = "2.4" ]; then
|
||||
ynh_mysql_create_db $db_user $db_user $db_pwd
|
||||
else
|
||||
sudo yunohost app initdb $db_user -p $db_pwd
|
||||
fi
|
||||
sudo yunohost app setting $app mysqlpwd -v $db_pwd
|
||||
|
||||
|
||||
|
|
|
@ -1,30 +1,62 @@
|
|||
#!/bin/bash
|
||||
|
||||
app=leed
|
||||
|
||||
# Récupère les infos de l'application.
|
||||
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
||||
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
|
||||
if [ $ynh_version = "2.4" ]; then
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
else
|
||||
app=leed
|
||||
MYSQL_ROOT_PWD_FILE="/etc/yunohost/mysql"
|
||||
fi
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
|
||||
# Suppression de la base de donnée et de l'utilisateur associé.
|
||||
# Utilise '$app' comme nom d'utilisateur et de base de donnée
|
||||
db_user=$app
|
||||
mysql -u root -p$root_pwd -e "DROP DATABASE $db_user ; DROP USER $db_user@localhost ;"
|
||||
if mysqlshow -u root -p$(sudo cat $MYSQL_ROOT_PWD_FILE) | grep -q "^| $db_user"; then
|
||||
echo "Delete db"
|
||||
if [ $ynh_version = "2.4" ]; then
|
||||
ynh_mysql_drop_db $db_user
|
||||
ynh_mysql_drop_user $db_user
|
||||
else
|
||||
mysql -u root -p$(sudo cat $MYSQL_ROOT_PWD_FILE) -e "DROP DATABASE $db_user ; DROP USER $db_user@localhost ;"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Suppression du dossier de l'application
|
||||
sudo rm -rf /var/www/$app
|
||||
if [ -e "/var/www/$app" ]; then # Delete final_path
|
||||
echo "Delete app dir"
|
||||
sudo rm -r "/var/www/$app"
|
||||
fi
|
||||
|
||||
# Suppression de la configuration nginx
|
||||
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
|
||||
# Retirer le cron
|
||||
sudo rm -f /etc/cron.d/$app
|
||||
if [ -e "/etc/nginx/conf.d/$domain.d/$app.conf" ]; then # Delete nginx config
|
||||
echo "Delete nginx config"
|
||||
sudo rm "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
sudo service nginx reload
|
||||
fi
|
||||
|
||||
# Suppression de la configuration du pool php-fpm
|
||||
sudo rm -f /etc/php5/fpm/pool.d/$app.conf
|
||||
sudo rm -f /etc/php5/fpm/conf.d/20-$app.ini
|
||||
|
||||
# Recharge la configuration Nginx et php5-fpm
|
||||
sudo service nginx reload
|
||||
if [ -e "/etc/php5/fpm/pool.d/$app.conf" ]; then # Delete fpm config
|
||||
echo "Delete fpm config"
|
||||
sudo rm "/etc/php5/fpm/pool.d/$app.conf"
|
||||
fi
|
||||
if [ -e "/etc/php5/fpm/conf.d/20-$app.ini" ]; then # Delete php config
|
||||
echo "Delete php config"
|
||||
sudo rm "/etc/php5/fpm/conf.d/20-$app.ini"
|
||||
fi
|
||||
sudo service php5-fpm reload
|
||||
|
||||
# Retirer le cron
|
||||
if [ -e "/etc/cron.d/$app" ]; then
|
||||
echo "Delete cron"
|
||||
sudo rm "/etc/cron.d/$app"
|
||||
fi
|
||||
|
||||
# Régénère la configuration de SSOwat
|
||||
sudo yunohost app ssowatconf
|
||||
|
||||
echo -e "\e[0m" # Restore normal color
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Récupère les infos de l'application.
|
||||
app=leed
|
||||
version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
|
||||
if [ $version = "2.4" ]; then
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
else
|
||||
app=leed
|
||||
fi
|
||||
final_path=$(sudo yunohost app setting $app final_path)
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Récupère les infos de l'application.
|
||||
app=app_name
|
||||
version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
|
||||
if [ $version = "2.4" ]; then
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
else
|
||||
app=leed
|
||||
fi
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
path=$(sudo yunohost app setting $app path)
|
||||
admin=$(sudo yunohost app setting $app admin)
|
||||
|
@ -72,8 +77,7 @@ else # Si l'app est publique
|
|||
sudo yunohost app setting $app unprotected_uris -v "/"
|
||||
fi
|
||||
|
||||
# Recharge la configuration Nginx et php5-fpm
|
||||
# Recharge la configuration Nginx
|
||||
sudo service nginx reload
|
||||
# sudo service php5-fpm reload
|
||||
# Régénère la configuration de SSOwat
|
||||
sudo yunohost app ssowatconf
|
||||
|
|
Loading…
Reference in a new issue