Skip to content

Commit 0080d68

Browse files
committed
linux support
1 parent ce95a46 commit 0080d68

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ One of the problems I noticed with the servers out there is that the "bases" are
1313
- Monitor server’s CPU/RAM consumption
1414
- Real-time playerlist with ping + steam-linked accounts (when available)
1515
- OneSync Support (more than 32 slots server)
16+
- Linux Support
1617

1718

1819
## Installation
@@ -28,7 +29,7 @@ $ cd fivem-fxadmin
2829
$ npm install
2930
```
3031
Copy your `server-template.json` to `server.json` and modify it according to your preferences.
31-
- `buildPath` is the folder containing the files `run.cmd`, `fxserver.exe` and a bunch of DLLs.
32+
- `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.
3233
- `basePath` is the folder that **contains** the `resources` folder, usually it's here that you put your `server.cfg`.
3334
- `cfgPath` is the absolute or relative path of your `server.cfg`.
3435

data/server-template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
"cfgPath": "C:/Users/Admin/Desktop/server01/server.cfg",
3232
"onesync": false,
3333
"isLinux": false,
34-
"autostart": true
34+
"autostart": false
3535
}
3636
}

src/components/fxRunner.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,31 @@ module.exports = class FXRunner {
2323
*/
2424
async spawnServer(){
2525
if(this.fxChild !== null) return false;
26-
2726
cleanTerminal();
2827
let onesyncFlag = (this.config.onesync)? '+set onesync_enabled 1' : '';
29-
//TODO: linux compatibility
30-
this.fxChild = spawn(
31-
"cmd.exe",
32-
['/c', `${this.config.buildPath}/run.cmd ${onesyncFlag} +exec ${this.config.cfgPath}`],
33-
{cwd: this.config.basePath}
34-
);
35-
logOk(`::Iniciado com PID ${this.fxChild.pid}!`, context);
28+
let spawnShell = null;
29+
let spawnCmdArgs = null;
30+
if(this.config.isLinux){
31+
spawnShell = '/bin/bash';
32+
spawnCmdArgs = [`${this.config.buildPath}/run.sh`, `${onesyncFlag} +exec ${this.config.cfgPath}`];
33+
}else{
34+
spawnShell = 'cmd.exe';
35+
spawnCmdArgs = ['/c', `${this.config.buildPath}/run.cmd ${onesyncFlag} +exec ${this.config.cfgPath}`];
36+
}
37+
38+
try {
39+
this.fxChild = spawn(
40+
spawnShell,
41+
spawnCmdArgs,
42+
{cwd: this.config.basePath}
43+
);
44+
} catch (error) {
45+
logError('Failed to start FXServer with the following error:');
46+
dir(error);
47+
process.exit(0);
48+
}
49+
50+
logOk(`::Server started with PID ${this.fxChild.pid}!`, context);
3651
this.fxChild.stdout.pipe(process.stdout);
3752
process.stdin.pipe(this.fxChild.stdin);
3853

version.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"version": "0.4.3",
3-
"changelog": "Config tester, better error handling and configuration change."
2+
"version": "0.5.0",
3+
"changelog": "Linux support, Config tester."
44
}

0 commit comments

Comments
 (0)