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:
parent
51d462af36
commit
321d6cb2d9
5 changed files with 8 additions and 27 deletions
|
@ -1,9 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
|
||||||
|
|
||||||
# Source YunoHost helpers
|
# Source YunoHost helpers
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Get multi-instances specific variables
|
# Get multi-instances specific variables
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
|
||||||
|
|
||||||
# Source YunoHost helpers
|
# Source YunoHost helpers
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
@ -25,29 +24,15 @@ db_user=ihatemoney
|
||||||
secret_key=`openssl rand -base64 32`
|
secret_key=`openssl rand -base64 32`
|
||||||
mails_sender="no-reply@${domain}"
|
mails_sender="no-reply@${domain}"
|
||||||
|
|
||||||
|
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
ynh_webpath_register $app $domain $path
|
ynh_webpath_register $app $domain $path
|
||||||
|
|
||||||
# Configure database
|
# Configure database
|
||||||
ynh_mysql_create_db "$db_name" "$db_user" "$db_pwd"
|
ynh_mysql_create_db "$db_name" "$db_user" "$db_pwd"
|
||||||
ynh_app_setting_set $app mysqlpwd $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
|
# Save app settings
|
||||||
ynh_app_setting_set $app domain $domain
|
ynh_app_setting_set $app domain $domain
|
||||||
ynh_app_setting_set $app is_public "$is_public"
|
ynh_app_setting_set $app is_public "$is_public"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -u
|
|
||||||
|
|
||||||
# Source YunoHost helpers
|
# Source YunoHost helpers
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
|
||||||
|
|
||||||
# Source app helpers
|
# Source app helpers
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
@ -26,6 +25,7 @@ fi
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
|
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
ynh_webpath_register $app $domain $path
|
ynh_webpath_register $app $domain $path
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
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 local utils
|
||||||
source _common.sh
|
source _common.sh
|
||||||
|
|
||||||
function exit_properly () {
|
ynh_clean_setup () {
|
||||||
set +e
|
|
||||||
# Revert to the old venv
|
|
||||||
if [ -e /opt/yunohost/ihatemoney/venv-old ]
|
if [ -e /opt/yunohost/ihatemoney/venv-old ]
|
||||||
then
|
then
|
||||||
sudo mv /opt/yunohost/ihatemoney/venv{-old,}
|
sudo mv /opt/yunohost/ihatemoney/venv{-old,}
|
||||||
fi
|
fi
|
||||||
ynh_die "Upgrade script failed, aborted and rolled back the installation"
|
|
||||||
}
|
}
|
||||||
trap exit_properly ERR
|
|
||||||
|
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
|
||||||
#----------------------------PRE-UPGRADE MIGRATIONS-----------------------
|
#----------------------------PRE-UPGRADE MIGRATIONS-----------------------
|
||||||
|
|
Loading…
Reference in a new issue