diff --git a/scripts/backup b/scripts/backup index 8a35241..6f9007c 100755 --- a/scripts/backup +++ b/scripts/backup @@ -6,8 +6,8 @@ set -eu app=$YNH_APP_INSTANCE_NAME # Set app specific variables -dbname=$app -dbuser=$app +dbname=`sudo cat /var/www/$app/config/config.php |grep dbname|sed "s|.*=> '\(.*\)'.*|\1|g"` +dbuser=$dbname # Source app helpers source /usr/share/yunohost/helpers diff --git a/scripts/remove b/scripts/remove index e7b807c..c5cf494 100755 --- a/scripts/remove +++ b/scripts/remove @@ -5,8 +5,8 @@ source ./_common.sh # Set app specific variables app=$APPNAME -dbname=$app -dbuser=$app +dbname=`sudo cat /var/www/$app/config/config.php |grep dbname|sed "s|.*=> '\(.*\)'.*|\1|g"` +dbuser=$dbname # Source app helpers source /usr/share/yunohost/helpers diff --git a/scripts/restore b/scripts/restore index a88e502..e660c92 100755 --- a/scripts/restore +++ b/scripts/restore @@ -5,10 +5,6 @@ set -eu # Get multi-instances specific variables app=$YNH_APP_INSTANCE_NAME -# Set app specific variables -dbname=$app -dbuser=$app - # Source app helpers source /usr/share/yunohost/helpers @@ -57,6 +53,10 @@ sudo cp -a ./www "$DESTDIR" sudo mkdir -p "$DATADIR" sudo cp -a ./data/. "$DATADIR" +# Set app specific variables +dbname=`sudo cat /var/www/$app/config/config.php |grep dbname|sed "s|.*=> '\(.*\)'.*|\1|g"` +dbuser=$dbname + # Create and restore the database ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql diff --git a/scripts/upgrade b/scripts/upgrade index 526e0ee..adeb7a2 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -5,8 +5,8 @@ source ./_common.sh # Set app specific variables app=$APPNAME -dbname=$app -dbuser=$app +dbname=`sudo cat /var/www/$app/config/config.php |grep dbname|sed "s|.*=> '\(.*\)'.*|\1|g"` +dbuser=$dbname # Backup the current version of the app, restore it if the upgrade fails if sudo yunohost backup list | grep -q $app-before-upgrade > /dev/null 2>&1; then # Supprime l'ancienne archive seulement si elle existe