mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-16 05:48:10 +00:00
Support VPCS delivered with WebUI on gns3server, Fixes: #325
This commit is contained in:
@ -194,6 +194,22 @@ async function configure(configPath, server) {
|
|||||||
fs.writeFileSync(configPath, ini.stringify(config, { section: '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) {
|
async function run(server, options) {
|
||||||
if(!options) {
|
if(!options) {
|
||||||
options = {};
|
options = {};
|
||||||
@ -202,11 +218,14 @@ async function run(server, options) {
|
|||||||
const logStdout = options.logStdout || false;
|
const logStdout = options.logStdout || false;
|
||||||
const logSterr = options.logSterr || false;
|
const logSterr = options.logSterr || false;
|
||||||
|
|
||||||
console.log(`Configuring`)
|
console.log(`Configuring`);
|
||||||
|
|
||||||
const configPath = await getIniFile(server);
|
const configPath = await getIniFile(server);
|
||||||
await configure(configPath, server);
|
await configure(configPath, server);
|
||||||
|
|
||||||
|
console.log(`Setting up PATH`);
|
||||||
|
await setPATHEnv();
|
||||||
|
|
||||||
console.log(`Running '${server.path}'`);
|
console.log(`Running '${server.path}'`);
|
||||||
|
|
||||||
let serverProcess = spawn(server.path, getServerArguments(server, {}, configPath));
|
let serverProcess = spawn(server.path, getServerArguments(server, {}, configPath));
|
||||||
@ -271,14 +290,15 @@ async function main() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcMain.on('local-server-run', async function (event, server) {
|
if(ipcMain) {
|
||||||
const responseChannel = getChannelForServer();
|
ipcMain.on('local-server-run', async function (event, server) {
|
||||||
await run(server);
|
const responseChannel = getChannelForServer();
|
||||||
event.sender.send(responseChannel, {
|
await run(server);
|
||||||
success: true
|
event.sender.send(responseChannel, {
|
||||||
|
success: true
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
process.on('SIGINT', function() {
|
process.on('SIGINT', function() {
|
||||||
|
Reference in New Issue
Block a user