65 lines
1.7 KiB
JavaScript
65 lines
1.7 KiB
JavaScript
/**
|
|
* setup domains
|
|
* @type {{framework: string, domain: string}[]}
|
|
*/
|
|
|
|
import fs from 'node-fs'
|
|
import { makeHostFileForWordpress } from './model.wordpress.mjs'
|
|
import { makeHostFileForSymfony } from './model.symfony.mjs'
|
|
import { makeHostFileForPhpPages } from './model.php-website.mjs'
|
|
import { domainsConfig } from './domains.mjs'
|
|
|
|
|
|
|
|
// autres frameworks:
|
|
// nextcloud: cloud.tykayn.fr
|
|
// vaultwarden: pass.cipherbliss.com
|
|
// mastodon: mastodon.cipherbliss.com
|
|
// peertube: peertube.cipherbliss.com
|
|
//
|
|
// sites statiques
|
|
// meltingpot.cipherbliss.com
|
|
// joinfediverse
|
|
// coussinet
|
|
let domainsForHostFile = [];
|
|
|
|
let domainsSorted = domainsConfig.sort((a,b)=>{
|
|
return a.domain - b.domain;
|
|
})
|
|
|
|
for (let configDomain of domainsSorted) {
|
|
|
|
console.log('domaine :', configDomain.name)
|
|
domainsForHostFile.push(configDomain.domain)
|
|
|
|
let hostFile
|
|
if (configDomain.framework === 'wordpress') {
|
|
hostFile = makeHostFileForWordpress(configDomain)
|
|
}
|
|
if (configDomain.framework === 'symfony') {
|
|
hostFile = makeHostFileForSymfony(configDomain)
|
|
}
|
|
if (configDomain.framework === 'static') {
|
|
hostFile = makeHostFileForPhpPages(configDomain)
|
|
}
|
|
writeFile(configDomain.domain + '_host.conf', hostFile.homeNginxConf)
|
|
writeFile(configDomain.domain + '_container.conf', hostFile.containerNginxConf)
|
|
let hostfileDomains = domainsForHostFile.map(domain => ' 127.0.0.1 '+domain+' \n')
|
|
console.log('hostfileDomains', hostfileDomains.join('').replace(',',''))
|
|
|
|
writeFile('hosts', hostfileDomains.join('').replace(',',''))
|
|
}
|
|
|
|
function writeFile (fileName, fileContent) {
|
|
console.log('write file', fileName)
|
|
return fs.writeFile(
|
|
`./output/${fileName}`,
|
|
fileContent,
|
|
'utf8',
|
|
(err) => {
|
|
if (err) {
|
|
console.log(`Error writing file: ${err}`)
|
|
}
|
|
}
|
|
)
|
|
} |