You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
797 B
33 lines
797 B
const mysql = require("mysql2");
|
|
const fs = require("fs");
|
|
|
|
require('dotenv').config({
|
|
path: '../../.env'
|
|
});
|
|
|
|
let conn = mysql.createConnection({
|
|
host: 'localhost',
|
|
port: process.env.MYSQL_PORT,
|
|
user: process.env.MYSQL_USER,
|
|
password: process.env.MYSQL_PASSWORD,
|
|
database: 'website'
|
|
});
|
|
|
|
conn.connect();
|
|
|
|
conn.query("SELECT name FROM projects WHERE visible=1", (err, results) => {
|
|
let names = results.map(res => res.name);
|
|
|
|
let fileContent = "";
|
|
|
|
// Aliases
|
|
for (let name of names)
|
|
fileContent += `Alias /${name} \${ProjectsPath}/${name}\n`
|
|
|
|
// Allow access
|
|
fileContent += '<Directory ~ \"^${ProjectsPath}/(' + names.join("|") + ')\">\n\tRequire all granted\n</Directory>'
|
|
|
|
fs.writeFileSync("./alias.conf", fileContent);
|
|
})
|
|
|
|
conn.end(); |