1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lutim_ynh.git synced 2024-09-03 19:36:24 +02:00

trap et maj ynh 2.4

This commit is contained in:
Maniack Crudelis 2016-05-20 00:01:21 +02:00
parent 56be152f63
commit 675a1235db
7 changed files with 185 additions and 33 deletions

View file

@ -2,6 +2,9 @@
"name": "Lutim",
"id": "lutim",
"packaging_format": 1,
"requirements": {
"yunohost": ">= 2.4"
},
"description": {
"en": "Self hosting images and sharing anonymous application",
"fr": "Application d'hébergement et de partage d'images anonyme"

67
manifest2.2.json Normal file
View file

@ -0,0 +1,67 @@
{
"name": "Lutim",
"id": "lutim",
"packaging_format": 1,
"description": {
"en": "Self hosting images and sharing anonymous application",
"fr": "Application d'hébergement et de partage d'images anonyme"
},
"version": "0.6 dev",
"url": "https://lut.im",
"licence": "free",
"maintainer": {
"name": "Maniack Crudelis et matlink",
"email": "maniackc_dev@crudelis.fr matlink@matlink.fr"
},
"multi_instance": "false",
"services": [
"nginx"
],
"arguments": {
"install" : [
{
"name": "domain",
"ask": {
"en": "Choose a domain for Lutim",
"fr": "Choisissez un domaine pour Lutim"
},
"example": "domain.org"
},
{
"name": "path",
"ask": {
"en": "Choose a path for Lutim",
"fr": "Choisissez un chemin pour Lutim"
},
"example": "/lutim",
"default": "/lutim"
},
{
"name": "admin",
"ask": {
"en": "Choose the Lutim administrator (must be an existing YunoHost user)",
"fr": "Choisissez un administrateur Lutim (doit être un utilisateur YunoHost)"
},
"example": "john"
},
{
"name": "is_public",
"ask": {
"en": "Uploading images is it public?",
"fr": "L'upload des images est-il public ?"
},
"choices": ["Yes", "No"],
"default": "No"
},
{
"name": "always_encrypt",
"ask": {
"en": "Force the encryption of images?",
"fr": "Forcer le chiffrement des images ?"
},
"choices": ["Yes", "No"],
"default": "Yes"
}
]
}
}

View file

@ -1,7 +1,12 @@
#!/bin/bash
# Récupère les infos de l'application.
app=lutim
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
else
app=lutim
fi
final_path=$(sudo yunohost app setting $app final_path)
domain=$(sudo yunohost app setting $app domain)
codename=$(sudo yunohost app setting $app codename)

View file

@ -1,24 +1,63 @@
#!/bin/bash
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
# Retrieve arguments
domain=$1
path=$2
admin=$3
is_public=$4
always_encrypt=$5
app=lutim
if [ $ynh_version = "2.4" ]
then
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
always_encrypt=$YNH_APP_ARG_ALWAYS_ENCRYPT
app=$YNH_APP_INSTANCE_NAME
# Source app helpers
. /usr/share/yunohost/helpers
else
domain=$1
path=$2
admin=$3
is_public=$4
always_encrypt=$5
app=lutim
fi
script_dir=$PWD
# 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 $script_dir/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 dossier de destination n'est pas déjà utilisé.
@ -26,7 +65,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

View file

@ -1,43 +1,71 @@
#!/bin/bash
app=lutim
# Récupère les infos de l'application.
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=lutim
fi
domain=$(sudo yunohost app setting $app domain)
codename=$(sudo yunohost app setting $app codename)
# Arrêt du service
sudo service lutim stop
if [ -e "/etc/init.d/lutim" ]; then
echo "Delete init.d script"
sudo service lutim stop
sudo rm "/etc/init.d/lutim"
sudo rm "/etc/default/lutim"
sudo update-rc.d -f lutim remove
fi
if [ -e "/etc/systemd/system/lutim.service" ]; then
echo "Delete systemd script"
sudo service lutim stop
sudo rm "/etc/systemd/system/lutim.service"
sudo systemctl disable lutim.service
fi
# Retire le service du monitoring de Yunohost.
sudo yunohost service remove lutim
if [ "$codename" = "wheezy" ]
then # Suppression des fichiers init
sudo rm -f /etc/default/lutim
sudo rm -f /etc/init.d/lutim
sudo update-rc.d -f lutim remove
else # Suppression des fichiers systemd
sudo systemctl disable lutim.service
sudo rm -f /etc/systemd/system/lutim.service
if sudo yunohost service status | grep -q lutim # Test l'existence du service dans Yunohost
then
echo "Remove lutim service"
sudo yunohost service remove lutim
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
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
# Retirer le cron
sudo rm -f /etc/cron.d/$app
if [ -e "/etc/cron.d/$app" ]; then
echo "Delete cron"
sudo rm "/etc/cron.d/$app"
fi
# Suppression des log
sudo rm -r /var/log/$app/
if [ -e "/var/log/$app/" ]; then
echo "Delete log"
sudo rm -r "/var/log/$app/"
fi
# Suppression de la configuration de logrotate
sudo rm /etc/logrotate.d/$app
if [ -e "/etc/logrotate.d/$app" ]; then
echo "Delete logrotate config"
sudo rm "/etc/logrotate.d/$app"
fi
# Recharge la configuration Nginx
sudo service nginx reload
# Régénère la configuration de SSOwat
sudo yunohost app ssowatconf
echo -e "\e[0m" # Restore normal color

View file

@ -1,7 +1,12 @@
#!/bin/bash
# Récupère les infos de l'application.
app=lutim
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
else
app=lutim
fi
final_path=$(sudo yunohost app setting $app final_path)
domain=$(sudo yunohost app setting $app domain)
codename=$(sudo yunohost app setting $app codename)

View file

@ -1,7 +1,12 @@
#!/bin/bash
# Récupère les infos de l'application.
app=lutim
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
else
app=lutim
fi
domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path)
is_public=$(sudo yunohost app setting $app is_public)