|
@@ -83,9 +83,6 @@ if [ -f $COMPLETION_FILE ]; then
|
83
|
83
|
ADMIN_USERNAME=$(get_completion_param "Admin user")
|
84
|
84
|
fi
|
85
|
85
|
|
86
|
|
-# MariaDB password
|
87
|
|
-DATABASE_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
|
88
|
|
-
|
89
|
86
|
function check_backup_exists {
|
90
|
87
|
if [ ! -d $USB_MOUNT/backup ]; then
|
91
|
88
|
echo $"No backup directory found on the USB drive."
|
|
@@ -209,13 +206,17 @@ function restore_mariadb {
|
209
|
206
|
keep_database_running
|
210
|
207
|
temp_restore_dir=/root/tempmariadb
|
211
|
208
|
restore_directory_from_usb $temp_restore_dir mariadb
|
212
|
|
- echo $'Obtaining MariaDB password'
|
213
|
|
- db_pass=$(${PROJECT_NAME}-pass -u root -a mariadb)
|
|
209
|
+
|
|
210
|
+ store_original_mariadb_password
|
|
211
|
+
|
|
212
|
+ echo $'Obtaining original MariaDB password'
|
|
213
|
+ db_pass=$(cat /root/.mariadboriginal)
|
214
|
214
|
if [ ${#db_pass} -gt 0 ]; then
|
215
|
215
|
echo $"Restore the MariaDB user table"
|
216
|
|
- mysqlsuccess=$(mysql -u root --password="$DATABASE_PASSWORD" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
|
|
216
|
+ mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
|
217
|
217
|
if [ ! "$?" = "0" ]; then
|
218
|
218
|
echo $"Try again using the password obtained from backup"
|
|
219
|
+ db_pass=$(${PROJECT_NAME}-pass -u root -a mariadb)
|
219
|
220
|
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
|
220
|
221
|
fi
|
221
|
222
|
if [ ! "$?" = "0" ]; then
|
|
@@ -226,9 +227,9 @@ function restore_mariadb {
|
226
|
227
|
fi
|
227
|
228
|
echo $"Restarting database"
|
228
|
229
|
systemctl restart mariadb
|
229
|
|
- echo $"Change the MariaDB password to the backup version"
|
230
|
|
- DATABASE_PASSWORD="$db_pass"
|
231
|
|
- ${PROJECT_NAME}-pass -u root -a mariadb -p "$DATABASE_PASSWORD"
|
|
230
|
+ echo $"Ensure MariaDB handles authentication"
|
|
231
|
+ MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
|
|
232
|
+ mariadb_fix_authentication
|
232
|
233
|
fi
|
233
|
234
|
rm -rf $temp_restore_dir
|
234
|
235
|
fi
|
|
@@ -248,6 +249,15 @@ function restore_letsencrypt {
|
248
|
249
|
fi
|
249
|
250
|
}
|
250
|
251
|
|
|
252
|
+function store_original_mariadb_password {
|
|
253
|
+ if [ ! -f /root/.mariadboriginal ]; then
|
|
254
|
+ echo $'Storing original mariadb password'
|
|
255
|
+ ORIGINAL_MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
|
|
256
|
+ # We can store this in plaintext because it will soon be of historical interest only
|
|
257
|
+ echo -n "$ORIGINAL_MARIADB_PASSWORD" > /root/.mariadboriginal
|
|
258
|
+ fi
|
|
259
|
+}
|
|
260
|
+
|
251
|
261
|
function restore_passwordstore {
|
252
|
262
|
if [[ $RESTORE_APP != 'all' ]]; then
|
253
|
263
|
if [[ $RESTORE_APP != 'passwords' ]]; then
|
|
@@ -255,6 +265,7 @@ function restore_passwordstore {
|
255
|
265
|
fi
|
256
|
266
|
fi
|
257
|
267
|
if [ -d $USB_MOUNT/backup/passwordstore ]; then
|
|
268
|
+ store_original_mariadb_password
|
258
|
269
|
echo $"Restoring password store"
|
259
|
270
|
restore_directory_from_usb / passwordstore
|
260
|
271
|
fi
|