You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
2.7 KiB
104 lines
2.7 KiB
const os = require('os')
|
|
const path = require('path')
|
|
const mkdirp = require('mkdirp')
|
|
const fs = require('fs-extra')
|
|
|
|
const config = {
|
|
background: '#ffffff',
|
|
margins: 0.005,
|
|
style: 'default',
|
|
nbPicture: 4,
|
|
cropSize: {
|
|
width: 900,
|
|
height: 1200
|
|
},
|
|
pictNames: [],
|
|
layout: [],
|
|
booths: {},
|
|
paths: {
|
|
final: '',
|
|
template: '',
|
|
prebuilt: '',
|
|
original: '',
|
|
toprint: ''
|
|
},
|
|
output: path.resolve('/media/share/'),
|
|
footer: 'm-30ansv2.jpg'
|
|
}
|
|
|
|
config.server = {
|
|
ipAddress: getIpAddress(),
|
|
port: 3111
|
|
}
|
|
|
|
config.killZone = {
|
|
top: 2,
|
|
bottom: 2,
|
|
left: 25,
|
|
right: 25
|
|
}
|
|
|
|
config.output = path.join(config.output, 'bobinoscope')
|
|
|
|
try {
|
|
fs.ensureDirSync(config.output)
|
|
console.log('[!] Bobinogrammes will be available in: ' + config.output)
|
|
} catch (e) {
|
|
console.log('[!] Failed to create folders: ' + config.output)
|
|
try {
|
|
config.output = process.cwd()
|
|
config.output = path.join(config.output, 'bobinoscope')
|
|
console.log('[!] Bobinogrammes will be available in: ' + config.output)
|
|
} catch (e) {
|
|
console.log('[!] Failed to create folders: ' + config.output)
|
|
process.exit(1)
|
|
}
|
|
}
|
|
|
|
// Init PATH
|
|
config.paths.template = path.resolve(__dirname, './server/public/rsc/template')
|
|
config.footer = path.resolve(__dirname, './server/public/rsc/footer', config.footer)
|
|
config.paths.final = path.resolve(config.output, './final')
|
|
config.paths.final_ld = path.resolve(config.output, './final_ld')
|
|
config.paths.prebuilt = path.resolve(config.output, './cache')
|
|
config.paths.original = path.resolve(config.output, './original')
|
|
config.paths.toprint = path.resolve(config.output, './toprint')
|
|
|
|
mkdirp.sync(config.paths.final)
|
|
mkdirp.sync(config.paths.final_ld)
|
|
mkdirp.sync(config.paths.prebuilt)
|
|
mkdirp.sync(config.paths.original)
|
|
mkdirp.sync(config.paths.toprint)
|
|
|
|
// Init pinctures names
|
|
for (let index = 0; index < config.nbPicture; index++) {
|
|
config.pictNames.push('pict_' + index + '.jpg')
|
|
}
|
|
|
|
module.exports = config
|
|
|
|
function getIpAddress () {
|
|
let ipAddress = 'localhost'
|
|
// Get local server ip address
|
|
let ifaces = os.networkInterfaces()
|
|
Object.keys(ifaces).forEach(function (ifname) {
|
|
let alias = 0
|
|
|
|
ifaces[ifname].forEach(function (iface) {
|
|
// skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
|
|
if (iface.family !== 'IPv4' || iface.internal !== false) return
|
|
if (/wlan/i.test(ifname)) ipAddress = iface.address
|
|
|
|
if (alias >= 1) {
|
|
// this single interface has multiple ipv4 addresses
|
|
// console.log(`[-] network: ${ifname} : ${alias} - ${iface.address}`)
|
|
} else {
|
|
// this interface has only one ipv4 adress
|
|
// console.log(`[-] network: ${ifname} - ${iface.address}`)
|
|
// console.log(ifname, iface.address)
|
|
}
|
|
})
|
|
})
|
|
|
|
return ipAddress
|
|
}
|