2023-06-12 23:13:15 +02:00
|
|
|
/**
|
|
|
|
* setup domains
|
|
|
|
* @type {{framework: string, domain: string}[]}
|
|
|
|
*/
|
|
|
|
|
|
|
|
import fs from 'node-fs'
|
|
|
|
import { makeHostFileForWordpress } from './model.wordpress.mjs'
|
|
|
|
import { makeHostFileForSymfony } from './model.symfony.mjs'
|
2023-06-15 19:42:12 +02:00
|
|
|
import { makeHostFileForPhpPages } from './model.php-website.mjs'
|
2023-06-27 10:28:46 +02:00
|
|
|
import { domainsConfig } from './domains.mjs'
|
2023-06-12 23:13:15 +02:00
|
|
|
|
|
|
|
|
2023-06-12 23:33:07 +02:00
|
|
|
|
2023-06-12 23:21:42 +02:00
|
|
|
// 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
|
2023-06-27 10:28:46 +02:00
|
|
|
let domainsForHostFile = [];
|
|
|
|
|
|
|
|
let domainsSorted = domainsConfig.sort((a,b)=>{
|
|
|
|
return a.domain - b.domain;
|
|
|
|
})
|
|
|
|
|
|
|
|
for (let configDomain of domainsSorted) {
|
2023-06-12 23:13:15 +02:00
|
|
|
|
|
|
|
console.log('domaine :', configDomain.name)
|
2023-06-27 10:28:46 +02:00
|
|
|
domainsForHostFile.push(configDomain.domain)
|
|
|
|
|
2023-06-12 23:13:15 +02:00
|
|
|
let hostFile
|
|
|
|
if (configDomain.framework === 'wordpress') {
|
|
|
|
hostFile = makeHostFileForWordpress(configDomain)
|
|
|
|
}
|
|
|
|
if (configDomain.framework === 'symfony') {
|
|
|
|
hostFile = makeHostFileForSymfony(configDomain)
|
|
|
|
}
|
2023-06-12 23:41:37 +02:00
|
|
|
if (configDomain.framework === 'static') {
|
|
|
|
hostFile = makeHostFileForPhpPages(configDomain)
|
|
|
|
}
|
2023-06-12 23:33:07 +02:00
|
|
|
writeFile(configDomain.domain + '_host.conf', hostFile.homeNginxConf)
|
|
|
|
writeFile(configDomain.domain + '_container.conf', hostFile.containerNginxConf)
|
2023-06-27 10:28:46 +02:00
|
|
|
let hostfileDomains = domainsForHostFile.map(domain => ' 127.0.0.1 '+domain+' \n')
|
|
|
|
console.log('hostfileDomains', hostfileDomains.join('').replace(',',''))
|
|
|
|
|
|
|
|
writeFile('hosts', hostfileDomains.join('').replace(',',''))
|
2023-06-12 23:13:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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}`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|