-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
51 lines (41 loc) · 1.71 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const fs = require('fs')
const path = require('path')
const util = require('util')
const readFile = util.promisify(fs.readFile)
const writeFile = util.promisify(fs.writeFile)
const DIR = __dirname
let start = async () => {
let mysqlBaseDir = 'D:/Programs/EasySrv-1.6.8-win/core/software/server/mysql-8.0'
// let mysqlDataDir = 'D:/Programs/EasySrv-1.6.8-win/core/database/mysql-8.0-data'
// let mysqlErrorFile = 'D:/Programs/EasySrv-1.6.8-win/core/software/server/mysql-8.0/logs/mysql.log'
let mysqlDataDir = path.join(DIR, 'data')
let mysqlErrorFile = path.join(mysqlDataDir, 'mysql.log')
// __DATA_DIR__ __LOG_ERROR__
let templateDir = path.join(DIR, 'templates')
let templateFileIni = path.join(templateDir, 'mysql.ini') // ini for windows, cnf for linux
let templateFileBat = path.join(templateDir, 'mysql.bat')
let templateFileSql = path.join(templateDir, 'reset.sql')
let distDir = path.join(DIR, 'dist')
let distIni = path.join(distDir, 'mysql.ini')
let distBat = path.join(distDir, 'mysql.bat')
let distSql = path.join(distDir, 'reset.sql')
let newPassword = 'qwert'
let buffer = await readFile(templateFileIni)
let content = buffer.toString()
.replace(/__DATA_DIR__/g, mysqlDataDir)
.replace(/__LOG_ERROR__/g, mysqlErrorFile)
await writeFile(distIni, content)
buffer = await readFile(templateFileBat)
content = buffer.toString()
.replace(/__BASE_DIR__/g, mysqlBaseDir)
.replace(/__DEFAULTS_FILE__/g, distIni)
.replace(/__RESET_FILE__/g, distSql)
.replace(/__LOG_ERROR__/g, mysqlErrorFile)
await writeFile(distBat, content)
buffer = await readFile(templateFileSql)
content = buffer.toString()
.replace(/__PASSWORD__/g, newPassword)
await writeFile(distSql, content)
}
// 0%9DdSdxrZ_y
start()