const mysql = require("mysql2"); const fs = require("fs"); const shell = require("shelljs"); 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 += '\n\tRequire all granted\n' fs.writeFileSync("./alias.conf", fileContent); shell.exec("sh restart.sh"); }); conn.end();