Skip to content

Commit

Permalink
(simatec) Fix mySql Password
Browse files Browse the repository at this point in the history
  • Loading branch information
simatec committed Nov 20, 2023
1 parent f759e74 commit 87e706d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ When the adapter crashes or another Code error happens, this error message that
* (simatec) dependencies updated
* (simatec) Fix CIFS Password
* (simatec) Fix mySql Password
* (simatec) Fix pgSql Password

### 2.9.3 (2023-11-11)
* (simatec) Fix Port for Filerserver
Expand Down
7 changes: 7 additions & 0 deletions lib/restore/pgsql.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ const fs = require('fs');
const path = require('path');

function replayPgSql(options, fileNamePgsql, log, callback) {

if ((options.pass.startsWith(`"`) && options.pass.endsWith(`"`)) || (options.pass.startsWith(`'`) && options.pass.endsWith(`'`))) {
options.pass = options.pass;
} else {
options.pass = `"${options.pass}"`;
}

const { exec } = require('child_process');
// create DB before executing script psql -c "create database Db name;" postgresql://iobroker:iobroker@localhost:5432/
const cmdCreate = `psql -c "create database ${options.dbName};" postgresql://${options.user}:${options.pass}@${options.host}:${options.port}/`;
Expand Down
6 changes: 6 additions & 0 deletions lib/scripts/30-pgsql.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ async function startBackup(options, log, callback) {
options.context.fileNames = options.context.fileNames || [];
options.context.fileNames.push(fileName);

if ((options.pass.startsWith(`"`) && options.pass.endsWith(`"`)) || (options.pass.startsWith(`'`) && options.pass.endsWith(`'`))) {
options.pass = options.pass;
} else {
options.pass = `"${options.pass}"`;
}

const child_process = require('child_process');

child_process.exec(`${options.exe ? options.exe : 'pg_dump'} --dbname=postgresql://${options.user}:${options.pass}@${options.host}:${options.port}/${options.dbName} > ${fileNamePgsql}`, {maxBuffer: 10 * 1024 * 1024}, async (error, stdout, stderr) => {
Expand Down

0 comments on commit 87e706d

Please sign in to comment.