Ver código fonte

Migrate database password on repair script

Bob Mottram 8 anos atrás
pai
commit
7bc9089801
1 arquivos alterados com 12 adições e 0 exclusões
  1. 12
    0
      src/freedombone-repair-database

+ 12
- 0
src/freedombone-repair-database Ver arquivo

@@ -44,6 +44,18 @@ ADMIN_EMAIL_ADDRESS=${ADMIN_USERNAME}@${HOSTNAME}
44 44
 # Frequency - daily/weekly
45 45
 BACKUP_TYPE='daily'
46 46
 
47
+
48
+# migrate from database password file to using the password store
49
+DATABASE_PASSWORD_FILE=/root/dbpass
50
+if [ -f $DATABASE_PASSWORD_FILE ]; then
51
+    MARIADB_PASSWORD=$(cat $DATABASE_PASSWORD_FILE)
52
+    ${PROJECT_NAME}-pass -u root -a mariadb -p "$MARIADB_PASSWORD"
53
+    stored_password=$(${PROJECT_NAME}-pass -u root -a mariadb)
54
+    if [[ "$stored_password" == "$MARIADB_PASSWORD" ]]; then
55
+        shred -zu $DATABASE_PASSWORD_FILE
56
+    fi
57
+fi
58
+
47 59
 MYSQL_ROOT_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
48 60
 
49 61
 TEMPFILE=/root/repair-database-$DATABASE