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

Cleans after itself in case the install fails.

Refs #1 and #4 (and hopefuly fixes them)
This commit is contained in:
Jocelyn Delande 2015-07-26 18:23:54 +02:00
parent 96b92b6ee6
commit 309e46013f

View file

@ -21,6 +21,27 @@ fi
# Remove trailing "/" for next commands
path=${path%/}
# Configure database
db_pwd=`sudo yunohost app initdb $db_user`
sudo yunohost app setting $app mysqlpwd -v $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
root_pwd=$(sudo cat /etc/yunohost/mysql)
mysql -u root -p$root_pwd -e "DROP DATABASE ihatemoney ; 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
exit 1
}
trap exit_properly ERR
# Save app settings
sudo yunohost app setting $app domain -v $domain
sudo yunohost app setting $app is_public -v "$is_public"
@ -55,10 +76,6 @@ sudo install -o root -g root -m 644 \
../conf/supervisord.conf /etc/supervisor/conf.d/ihatemoney.conf
sudo yunohost service add supervisor
# Configure database
db_pwd=`sudo yunohost app initdb $db_user`
sudo yunohost app setting $app mysqlpwd -v $db_pwd
# Configure ihatemoney
sed -i "s@MY_SECRET_KEY@$secret_key@" ../conf/settings.py
sed -i "s/MY_EMAIL/$mails_sender/" ../conf/settings.py