scripts/nginx_config_maker/index.mjs

161 lines
3.7 KiB
JavaScript
Raw Normal View History

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-12 23:41:37 +02:00
import { makeHostFileForPhpPages } from './model.php-website'
2023-06-12 23:13:15 +02:00
const LXCcontainerLocalIP = '10.10.10.103'
const LXCcontainerProtocol = 'https'
2023-06-12 23:33:07 +02:00
2023-06-12 23:13:15 +02:00
const domainsConfig = [{
LXCcontainerLocalIP,
LXCcontainerProtocol,
name: 'Blog cipherbliss',
domain: 'www.cipherbliss.com',
framework: 'wordpress',
disableSSL: false,
2023-06-12 23:21:42 +02:00
},{
2023-06-12 23:13:15 +02:00
LXCcontainerLocalIP,
LXCcontainerProtocol,
2023-06-12 23:21:42 +02:00
name: 'Portfolio cipherbliss',
domain: 'portfolio.cipherbliss.com',
2023-06-12 23:13:15 +02:00
framework: 'symfony',
disableSSL: false,
2023-06-12 23:21:42 +02:00
}, {
2023-06-12 23:13:15 +02:00
LXCcontainerLocalIP,
LXCcontainerProtocol,
2023-06-12 23:21:42 +02:00
name: 'Blog tykayn - le vortex à chats',
domain: 'tykayn.fr',
framework: 'wordpress',
disableSSL: false,
}, {
LXCcontainerLocalIP,
LXCcontainerProtocol,
name: 'Site de la compagnie la puce à l\'oreille',
domain: 'www.pucealoreille.fr',
framework: 'wordpress',
disableSSL: false,
}, {
LXCcontainerLocalIP,
LXCcontainerProtocol,
name: 'Site de Didier, un bec et des ailes',
domain: 'www.unbecetdesailes.fr',
framework: 'wordpress',
disableSSL: false,
}, {
LXCcontainerLocalIP,
LXCcontainerProtocol,
name: 'Site de Catherine Fonder, conteuse',
domain: 'www.catherinefonder.fr',
framework: 'wordpress',
disableSSL: false,
}, {
LXCcontainerLocalIP,
LXCcontainerProtocol,
name: 'Site de la Fromagerie BSF',
domain: 'www.lafromagerie-bsf.com',
framework: 'wordpress',
2023-06-12 23:13:15 +02:00
disableSSL: false,
},
2023-06-12 23:21:42 +02:00
{
LXCcontainerLocalIP,
LXCcontainerProtocol,
name: 'Claire Lemoine portfolio',
domain: 'www.clairelemoine.art',
framework: 'wordpress',
disableSSL: false,
2023-06-12 23:27:17 +02:00
},
{
LXCcontainerLocalIP,
LXCcontainerProtocol,
name: 'Blog Qzine',
domain: 'qzine.fr',
framework: 'symfony',
disableSSL: false,
},
{
2023-06-12 23:21:42 +02:00
LXCcontainerLocalIP,
LXCcontainerProtocol,
name: 'Funky Framadate Démo',
domain: 'framadate-api.cipherbliss.com',
framework: 'symfony',
disableSSL: false,
}, {
LXCcontainerLocalIP,
LXCcontainerProtocol,
name: 'Portfolio cipherbliss',
domain: 'portfolio.cipherbliss.com',
framework: 'symfony',
disableSSL: false,
},
{
LXCcontainerLocalIP,
LXCcontainerProtocol,
name: 'Caisse Bliss',
domain: 'caisse.cipherbliss.com',
framework: 'symfony',
disableSSL: false,
},
2023-06-12 23:27:17 +02:00
{
LXCcontainerLocalIP,
LXCcontainerProtocol,
name: 'Sondages Qzine',
domain: 'sondages.qzine.fr',
framework: 'symfony',
disableSSL: false,
},
2023-06-12 23:41:37 +02:00
{
LXCcontainerLocalIP,
LXCcontainerProtocol,
name: 'Chaton coussinet',
domain: 'www.coussinet.org',
framework: 'static',
disableSSL: false,
},
2023-06-12 23:13:15 +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-12 23:13:15 +02:00
for (let configDomain of domainsConfig) {
console.log('domaine :', configDomain.name)
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-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}`)
}
}
)
}