Skip to content

Commit

Permalink
linux support
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed May 23, 2019
1 parent ce95a46 commit 0080d68
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ One of the problems I noticed with the servers out there is that the "bases" are
- Monitor server’s CPU/RAM consumption
- Real-time playerlist with ping + steam-linked accounts (when available)
- OneSync Support (more than 32 slots server)
- Linux Support


## Installation
Expand All @@ -28,7 +29,7 @@ $ cd fivem-fxadmin
$ npm install
```
Copy your `server-template.json` to `server.json` and modify it according to your preferences.
- `buildPath` is the folder containing the files `run.cmd`, `fxserver.exe` and a bunch of DLLs.
- `buildPath` is the folder containing the files `run.cmd`, `fxserver.exe` and a bunch of DLLs in case of Windows, and only `run.sh` in case of Linux.
- `basePath` is the folder that **contains** the `resources` folder, usually it's here that you put your `server.cfg`.
- `cfgPath` is the absolute or relative path of your `server.cfg`.

Expand Down
2 changes: 1 addition & 1 deletion data/server-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"cfgPath": "C:/Users/Admin/Desktop/server01/server.cfg",
"onesync": false,
"isLinux": false,
"autostart": true
"autostart": false
}
}
31 changes: 23 additions & 8 deletions src/components/fxRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,31 @@ module.exports = class FXRunner {
*/
async spawnServer(){
if(this.fxChild !== null) return false;

cleanTerminal();
let onesyncFlag = (this.config.onesync)? '+set onesync_enabled 1' : '';
//TODO: linux compatibility
this.fxChild = spawn(
"cmd.exe",
['/c', `${this.config.buildPath}/run.cmd ${onesyncFlag} +exec ${this.config.cfgPath}`],
{cwd: this.config.basePath}
);
logOk(`::Iniciado com PID ${this.fxChild.pid}!`, context);
let spawnShell = null;
let spawnCmdArgs = null;
if(this.config.isLinux){
spawnShell = '/bin/bash';
spawnCmdArgs = [`${this.config.buildPath}/run.sh`, `${onesyncFlag} +exec ${this.config.cfgPath}`];
}else{
spawnShell = 'cmd.exe';
spawnCmdArgs = ['/c', `${this.config.buildPath}/run.cmd ${onesyncFlag} +exec ${this.config.cfgPath}`];
}

try {
this.fxChild = spawn(
spawnShell,
spawnCmdArgs,
{cwd: this.config.basePath}
);
} catch (error) {
logError('Failed to start FXServer with the following error:');
dir(error);
process.exit(0);
}

logOk(`::Server started with PID ${this.fxChild.pid}!`, context);
this.fxChild.stdout.pipe(process.stdout);
process.stdin.pipe(this.fxChild.stdin);

Expand Down
4 changes: 2 additions & 2 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "0.4.3",
"changelog": "Config tester, better error handling and configuration change."
"version": "0.5.0",
"changelog": "Linux support, Config tester."
}

0 comments on commit 0080d68

Please sign in to comment.