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

trap et maj ynh 2.4

This commit is contained in:
Maniack Crudelis 2016-05-20 00:03:02 +02:00
parent cd56095936
commit 3aaf9bc15a
7 changed files with 195 additions and 44 deletions

View file

@ -2,6 +2,9 @@
"name": "Radicale",
"id": "radicale",
"packaging_format": 1,
"requirements": {
"yunohost": ">= 2.4"
},
"description": {
"en": "CalDAV (calendar) and CardDAV (contact) synchronization server",
"fr": "Serveur de synchronisation CalDAV et CardDAV"

68
manifest2.2.json Normal file
View file

@ -0,0 +1,68 @@
{
"name": "Radicale",
"id": "radicale",
"packaging_format": 1,
"description": {
"en": "CalDAV (calendar) and CardDAV (contact) synchronization server",
"fr": "Serveur de synchronisation CalDAV et CardDAV"
},
"version": "1.1.1",
"url": "http://radicale.org",
"licence": "free",
"maintainer": {
"name": "beudbeud",
"email": "beudbeud@beudibox.fr"
},
"multi_instance": "false",
"services": [
"nginx",
"php5-fpm"
],
"arguments": {
"install" : [
{
"name": "domain",
"ask": {
"en": "Choose a domain for Radicale",
"fr": "Choisissez un domaine pour Radicale"
},
"example": "domain.org"
},
{
"name": "path",
"ask": {
"en": "Choose a path for Radicale",
"fr": "Choisissez un chemin pour Radicale"
},
"example": "/radicale",
"default": "/radicale"
},
{
"name": "admin",
"ask": {
"en": "Choose the administrator (must be an existing YunoHost user)",
"fr": "Choisissez un administrateur (doit être un utilisateur YunoHost)"
},
"example": "john"
},
{
"name": "infcloud",
"ask": {
"en": "Install InfCloud web interface?",
"fr": "Installer l'interface web InfCloud?"
},
"choices": ["Yes", "No"],
"default": "Yes"
},
{
"name": "language",
"ask": {
"en": "Choose your interface language",
"fr": "Choisissez la langue de l'interface"
},
"choices" : ["Czech", "Danish", "German", "English/US", "Spanish", "French", "Italian", "Japan", "Hungarian", "Dutch", "Slovak", "Turkish", "Russian", "Ukrainian", "Chinese"],
"default" : "English/US"
}
]
}
}

View file

@ -1,7 +1,12 @@
#!/bin/bash
# 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
else
app=radicale
fi
final_path=$(sudo yunohost app setting $app final_path)
domain=$(sudo yunohost app setting $app domain)
infcloud=$(sudo yunohost app setting $app infcloud)

View file

@ -1,24 +1,62 @@
#!/bin/bash
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
# Retrieve arguments
if [ $ynh_version = "2.4" ]
then
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
infcloud=$YNH_APP_ARG_INFCLOUD
language=$YNH_APP_ARG_LANGUAGE
app=$YNH_APP_INSTANCE_NAME
# Source app helpers
. /usr/share/yunohost/helpers
else
domain=$1
path=$2
admin=$3
infcloud=$4
language=$5
app=radicale
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
# 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 +64,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
@ -140,7 +178,7 @@ sudo chown radicale: -R /opt/yunohost/$app
# Set permissions to radicale directory
sudo chown -R radicale: $final_path
sudo mkdir /var/log/$app
sudo mkdir -p /var/log/$app
sudo touch /var/log/$app/$app.log
sudo chown radicale -R /var/log/$app
# Droit par défaut des dossiers de collections utilisateurs, tels qu'ils sont créés par radicale.

View file

@ -1,50 +1,78 @@
#!/bin/bash
app=radicale
# 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=radicale
fi
domain=$(sudo yunohost app setting $app domain)
infcloud=$(sudo yunohost app setting $app infcloud)
# Suppression des dossiers de l'application
sudo rm -Rf /opt/yunohost/$app
sudo rm -Rf /var/www/$app/
sudo rm -Rf /etc/$app/
if [ -e "/var/www/$app/" ]; then # Delete final_path
echo "Delete app dir"
sudo rm -r "/var/www/$app/"
fi
if [ -e "/opt/yunohost/$app" ]; then
echo "Delete virtualenv"
sudo rm -r "/opt/yunohost/$app"
fi
if [ -e "/etc/$app/" ]; then
echo "Delete radicale config"
sudo rm -r "/etc/$app/"
fi
# Suppression de la configuration uwsgi
# Stoppe le service uwsgi
sudo service uwsgi stop
# Suppression de la configuration uwsgi
sudo rm -f /etc/uwsgi/apps-enabled/radicale.ini
sudo rm -f /etc/uwsgi/apps-available/radicale.ini
# Et du service dans Yunohost
sudo yunohost service remove uwsgi
if [ -e "/etc/uwsgi/apps-available/radicale.ini" ]; then
echo "Delete uwsgi config"
sudo rm "/etc/uwsgi/apps-available/radicale.ini"
fi
if [ -e "/etc/uwsgi/apps-enabled/radicale.ini" ]; then
echo "Delete uwsgi config"
sudo rm "/etc/uwsgi/apps-enabled/radicale.ini"
fi
if grep -q "^radicale:" /etc/passwd # Test l'existence de l'utilisateur
then
sudo userdel radicale
fi
# Redémarre le service uwsgi
sudo service uwsgi start
# Suppression de la configuration nginx
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
if [ "$infcloud" = "1" ]
then
# 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 de php5-fpm
sudo service php5-fpm reload
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 de logrotate
sudo rm /etc/logrotate.d/$app
# Suppression de la configuration du pool php-fpm
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
# Recharge la configuration Nginx
sudo service nginx reload
# Suppression de la configuration de logrotate
if [ -e "/etc/logrotate.d/$app" ]; then
echo "Delete logrotate config"
sudo rm -r "/etc/logrotate.d/$app"
fi
# Retire le hook sur la création de nouveaux utilisateurs
sudo yunohost hook remove radicale
# Régénère la configuration de SSOwat
sudo yunohost app ssowatconf
# Supprime l'utilisateur radicale
sudo userdel radicale
# Retire le hook sur la création de nouveaux utilisateurs
sudo yunohost hook remove radicale
echo -e "\e[0m" # Restore normal color

View file

@ -1,7 +1,12 @@
#!/bin/bash
# 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
else
app=radicale
fi
final_path=$(sudo yunohost app setting $app final_path)
domain=$(sudo yunohost app setting $app domain)
infcloud=$(sudo yunohost app setting $app infcloud)

View file

@ -1,8 +1,12 @@
#!/bin/bash
app=radicale
# Get app settings
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=radicale
fi
domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path)
admin=$(sudo yunohost app setting $app admin)