Skip to content
Permalink
Browse files

Added docker compose generator

  • Loading branch information...
makitsune committed May 11, 2019
1 parent db32ff9 commit 21b0fbf98015c815ac451ac32038a0b234a54d7d
Binary file not shown.
@@ -0,0 +1,8 @@
module.exports = {
version: "0.82.1",
host: "example.com",
domains: {
makiland: [40100, "admin:password"],
foxshrine: [40120, "admin:password"],
}
};
@@ -0,0 +1,61 @@
var fs = require("fs");
var YAML = require("yaml");

var config = require(__dirname+"/domains.js")
var services = {};

var command = "sh -c \""+
"sed -i '{s/4800/'$${HIFI_ASSIGNMENT_RANGE_START%?}'/g;}' /etc/supervisor/conf.d/hifi.conf && "+
"supervisord -c /etc/supervisor/conf.d/hifi.conf"+
"\"";

Object.keys(config.domains).forEach(name=>{
let port = config.domains[name][0];
// port = [
// {
// start: port,
// end: port+9,
// },
// {
// start: port+7900,
// end: port+7900+9,
// }
// ]
port = [
{
start: port,
end: port+9,
},
{
start: port+10,
end: port+19,
}
]

services[name] = {
hostname: name,
image: "highfidelity/hifi:"+config.version,
ports: [
port[0].start+"-"+port[0].end+":40100-40109",
port[0].start+"-"+port[0].end+":40100-40109/udp",
port[1].start+"-"+port[1].end,
port[1].start+"-"+port[1].end+"/udp",
],
volumes: [
"./domains/"+name+":/root/.local/share/High Fidelity"
],
environment: [
"HIFI_ASSIGNMENT_RANGE_START="+port[1].start
],
command: command,
restart: "always",
};
});

console.log("Using High Fidelity v"+config.version);
console.log("Wrote "+Object.keys(config.domains).length+" domains\n");

fs.writeFileSync("./docker-compose.yml", YAML.stringify({
version: "3.6",
services: services
}));
@@ -0,0 +1,30 @@

var config = require(__dirname+"/domains.js");

const RESET = "\x1b[0m";
const BRIGHT = "\x1b[1m";

const FGBLACK = "\x1b[30m";
const BGWHITE = "\x1b[47m";

var maxLength = 0;
Object.keys(config.domains).forEach(name=>{
if (name.length>maxLength) maxLength=name.length;
});

function fit(name) {
var spacesLength = maxLength-name.length;
var spaces = "";

for (var i=0; i<spacesLength; i++) spaces+=" ";
return spaces+name;
}

console.log("");
Object.keys(config.domains).forEach((name,i)=>{
let port = config.domains[name][0];
let auth = config.domains[name][1];

console.log(BGWHITE+FGBLACK+fit(name)+RESET+" http://"+auth+"@"+config.host+":"+port+"/settings");
});
console.log("");%

0 comments on commit 21b0fbf

Please sign in to comment.
You can’t perform that action at this time.