Skip to content

Commit

Permalink
build v1.38.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo82148 committed Aug 31, 2024
1 parent 8aa8287 commit 1888a3e
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 27 deletions.
13 changes: 10 additions & 3 deletions lib/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,16 @@ async function shutdownMySQL(state) {
if (core.isDebug()) {
env["MYSQL_DEBUG"] = "1";
}
await exec.exec(path.join(state.toolPath, "bin", `mysqladmin${binExt}`), [...args, `shutdown`], {
env,
});
if (fs.existsSync(path.join(state.toolPath, "bin", `mariadb-admin${binExt}`))) {
await exec.exec(path.join(state.toolPath, "bin", `mariadb-admin${binExt}`), [...args, "--skip-ssl", "shutdown"], {
env,
});
}
else {
await exec.exec(path.join(state.toolPath, "bin", `mysqladmin${binExt}`), [...args, "shutdown"], {
env,
});
}
core.info("wait for MySQL shutdown");
for (let i = 0; i < 30; i++) {
try {
Expand Down
86 changes: 63 additions & 23 deletions lib/starter.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,23 @@ async function startMySQL(mysql, cnf, rootPassword) {
try {
await core.group("configure root password", async () => {
await retry(async () => {
await execute(path.join(mysql.toolPath, "bin", `mysqladmin${binExt}`), [
`--defaults-file=${baseDir}${sep}etc${sep}my.cnf`,
`--user=root`,
`password`,
rootPassword,
]);
if (fs.existsSync(path.join(mysql.toolPath, "bin", `mariadb-admin${binExt}`))) {
await execute(path.join(mysql.toolPath, "bin", `mariadb-admin${binExt}`), [
`--defaults-file=${baseDir}${sep}etc${sep}my.cnf`,
`--skip-ssl`,
`--user=root`,
`password`,
rootPassword,
]);
}
else {
await execute(path.join(mysql.toolPath, "bin", `mysqladmin${binExt}`), [
`--defaults-file=${baseDir}${sep}etc${sep}my.cnf`,
`--user=root`,
`password`,
rootPassword,
]);
}
});
});
}
Expand Down Expand Up @@ -229,22 +240,47 @@ async function startMySQL(mysql, cnf, rootPassword) {
};
}
async function createUser(state, user, password) {
const mysql = path.join(state.toolPath, "bin", `mysql${binExt}`);
const env = {};
const args = [`--defaults-file=${state.baseDir}${sep}etc${sep}my.cnf`, `--user=root`];
if (state.rootPassword) {
env["MYSQL_PWD"] = state.rootPassword;
}
if (core.isDebug()) {
env["MYSQL_DEBUG"] = "1";
if (fs.existsSync(path.join(state.toolPath, "bin", `mariadb${binExt}`))) {
const mariadb = path.join(state.toolPath, "bin", `mariadb${binExt}`);
const env = {};
const args = [
`--defaults-file=${state.baseDir}${sep}etc${sep}my.cnf`,
`--skip-ssl`,
`--user=root`,
];
if (state.rootPassword) {
env["MYSQL_PWD"] = state.rootPassword;
}
if (core.isDebug()) {
env["MYSQL_DEBUG"] = "1";
}
for (const host of ["localhost", "127.0.0.1", "::1"]) {
await execute(mariadb, [...args, "-e", `CREATE USER '${user}'@'${host}' IDENTIFIED BY '${password}'`], {
env,
});
await execute(mariadb, [...args, "-e", `GRANT ALL PRIVILEGES ON *.* TO '${user}'@'${host}' WITH GRANT OPTION`], {
env,
});
}
}
for (const host of ["localhost", "127.0.0.1", "::1"]) {
await execute(mysql, [...args, "-e", `CREATE USER '${user}'@'${host}' IDENTIFIED BY '${password}'`], {
env,
});
await execute(mysql, [...args, "-e", `GRANT ALL PRIVILEGES ON *.* TO '${user}'@'${host}' WITH GRANT OPTION`], {
env,
});
else {
const mysql = path.join(state.toolPath, "bin", `mysql${binExt}`);
const env = {};
const args = [`--defaults-file=${state.baseDir}${sep}etc${sep}my.cnf`, `--user=root`];
if (state.rootPassword) {
env["MYSQL_PWD"] = state.rootPassword;
}
if (core.isDebug()) {
env["MYSQL_DEBUG"] = "1";
}
for (const host of ["localhost", "127.0.0.1", "::1"]) {
await execute(mysql, [...args, "-e", `CREATE USER '${user}'@'${host}' IDENTIFIED BY '${password}'`], {
env,
});
await execute(mysql, [...args, "-e", `GRANT ALL PRIVILEGES ON *.* TO '${user}'@'${host}' WITH GRANT OPTION`], {
env,
});
}
}
}
// execute "mysqld --verbose --help" and returns its result.
Expand All @@ -265,7 +301,7 @@ async function verboseHelp(mysql) {
await execute(path.join(mysql.toolPath, "bin", `mysqld${binExt}`), ["--no-defaults", "--verbose", "--help"], options);
}
catch (e) {
core.error("fail to get mysqld options");
core.error(`fail to get mysqld options: ${e}`);
core.error(myOutput);
return "";
}
Expand All @@ -280,6 +316,8 @@ async function setupTls(mysql, baseDir) {
const options = {};
process.env["LD_LIBRARY_PATH"] = `${mysql.toolPath}${sep}lib`;
process.env["DYLD_LIBRARY_PATH"] = `${mysql.toolPath}${sep}lib`;
// show the version of openssl
await exec.exec(openssl, ["version"], options);
// Generate CA Key and Certificate
await exec.exec(openssl, [
"req",
Expand Down Expand Up @@ -319,7 +357,7 @@ async function setupTls(mysql, baseDir) {
"-keyout",
`${datadir}${sep}server-key.pem`,
"-subj",
"/CN=Actions_Setup_MySQL_Auto_Generated_Certificate",
"/CN=127.0.0.1",
"-out",
`${datadir}${sep}server-req.pem`,
]);
Expand All @@ -338,6 +376,8 @@ async function setupTls(mysql, baseDir) {
`${datadir}${sep}ca-key.pem`,
"-set_serial",
"01",
"-extfile",
`${__dirname}${sep}..${sep}subjectnames.txt`,
"-out",
`${datadir}${sep}server-cert.pem`,
], options);
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1888a3e

Please sign in to comment.