-
-
Save iamntz-gists/065f42f092764788872a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var readline = require('readline'); | |
var args = process.argv.slice(2); | |
var clientName, projectName; | |
clientName = projectName = args[0]; | |
if( args[1] ){ | |
projectName = args[1]; | |
} | |
var dbName = clientName + '_' + projectName; | |
var nginxConfigPath = "config/nginx-config/sites/" + dbName + ".conf"; | |
if( fs.existsSync(nginxConfigPath) ){ | |
console.log('Project already exists'); | |
return; | |
} | |
console.log('Creating project: ', projectName); | |
var nginxConfig = fs.readFileSync( "config/nginx-config/sites/wp-mu.conf-sample", "utf8" ); | |
nginxConfig = nginxConfig.replace(/\{\{__client__\}\}/g, clientName); | |
nginxConfig = nginxConfig.replace(/\{\{__project\}\}/g, projectName); | |
fs.writeFileSync( nginxConfigPath, nginxConfig, 'utf8'); | |
var database = "\n\nCREATE DATABASE IF NOT EXISTS `" + dbName + "`;\n"; | |
database += "GRANT ALL PRIVILEGES ON `" + dbName + "`.* TO 'wp'@'localhost' IDENTIFIED BY 'wp'"; | |
fs.appendFileSync("database/init-custom.sql", database, 'utf8'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment