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:
parent
96b92b6ee6
commit
309e46013f
1 changed files with 21 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue