Support VPCS delivered with WebUI on gns3server, Fixes: #325

This commit is contained in:
ziajka 2019-03-05 12:01:24 +01:00
parent 5f32945f9f
commit f471d8134a

View File

@ -194,6 +194,22 @@ async function configure(configPath, server) {
fs.writeFileSync(configPath, ini.stringify(config, { section: 'Server' }));
}
async function setPATHEnv() {
const vpcsLookup = [
path.join(__dirname, 'dist', 'vpcs'),
path.join(path.dirname(app.getPath('exe')), 'dist', 'vpcs')
];
// prevent adding duplicates
let extra = [
...vpcsLookup
].filter((dir) => {
return process.env.PATH.indexOf(dir) < 0;
});
extra.push(process.env.PATH);
process.env.PATH = extra.join(";");
}
async function run(server, options) {
if(!options) {
options = {};
@ -202,11 +218,14 @@ async function run(server, options) {
const logStdout = options.logStdout || false;
const logSterr = options.logSterr || false;
console.log(`Configuring`)
console.log(`Configuring`);
const configPath = await getIniFile(server);
await configure(configPath, server);
console.log(`Setting up PATH`);
await setPATHEnv();
console.log(`Running '${server.path}'`);
let serverProcess = spawn(server.path, getServerArguments(server, {}, configPath));
@ -271,14 +290,15 @@ async function main() {
});
}
ipcMain.on('local-server-run', async function (event, server) {
const responseChannel = getChannelForServer();
await run(server);
event.sender.send(responseChannel, {
success: true
if(ipcMain) {
ipcMain.on('local-server-run', async function (event, server) {
const responseChannel = getChannelForServer();
await run(server);
event.sender.send(responseChannel, {
success: true
});
});
});
}
if (require.main === module) {
process.on('SIGINT', function() {