1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00

Use ynh helpers for error handling

Instead of doing it by hand.

Also we now rely on the fact ynh automatically runs uninstall script if the
install fails. So no more need for manual cleanup.
This commit is contained in:
Jocelyn Delalande 2018-11-25 18:38:33 +01:00
parent 51d462af36
commit 321d6cb2d9
5 changed files with 8 additions and 27 deletions

View file

@ -1,9 +1,10 @@
#!/bin/bash
set -eu
# Source YunoHost helpers
source /usr/share/yunohost/helpers
ynh_abort_if_errors
# Get multi-instances specific variables
app=$YNH_APP_INSTANCE_NAME

View file

@ -1,5 +1,4 @@
#!/bin/bash
set -eu
# Source YunoHost helpers
source /usr/share/yunohost/helpers
@ -25,29 +24,15 @@ db_user=ihatemoney
secret_key=`openssl rand -base64 32`
mails_sender="no-reply@${domain}"
ynh_abort_if_errors
ynh_webpath_register $app $domain $path
# Configure database
ynh_mysql_create_db "$db_name" "$db_user" "$db_pwd"
ynh_app_setting_set $app mysqlpwd $db_pwd
# Delete db, user dirs and conf if exit with an error
# inspired from https://github.com/Kloadut/owncloud_ynh/blob/master/scripts/install#L37
function exit_properly
{
set +e
ynh_mysql_drop_db $db_name
ynh_mysql_drop_user $db_user
sudo userdel ihatemoney
sudo rm -Rf /opt/yunohost/ihatemoney
sudo rm -Rf /etc/ihatemoney
sudo rm /etc/nginx/conf.d/$domain.d/ihatemoney.conf
sudo rm /etc/supervisor/conf.d/ihatemoney.conf
ynh_die "Install script failed, aborted and rolled back the installation"
}
trap exit_properly ERR
# Save app settings
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app is_public "$is_public"

View file

@ -1,5 +1,4 @@
#!/bin/bash
set -u
# Source YunoHost helpers
source /usr/share/yunohost/helpers

View file

@ -1,5 +1,4 @@
#!/bin/bash
set -eu
# Source app helpers
source /usr/share/yunohost/helpers
@ -26,6 +25,7 @@ fi
source _common.sh
ynh_abort_if_errors
ynh_webpath_register $app $domain $path

View file

@ -1,5 +1,4 @@
#!/bin/bash
set -eu
app=$YNH_APP_INSTANCE_NAME
@ -23,17 +22,14 @@ VENV_PY_VERSION=$(echo ${INSTALL_DIR}/venv/bin/python*.*|sed 's/.*python//')
# Source local utils
source _common.sh
function exit_properly () {
set +e
# Revert to the old venv
ynh_clean_setup () {
if [ -e /opt/yunohost/ihatemoney/venv-old ]
then
sudo mv /opt/yunohost/ihatemoney/venv{-old,}
fi
ynh_die "Upgrade script failed, aborted and rolled back the installation"
}
trap exit_properly ERR
ynh_abort_if_errors
#----------------------------PRE-UPGRADE MIGRATIONS-----------------------