arkmanager / ark-server-tools

Set of server tools used to manage ARK: Survival Evolved servers on Linux
MIT License
684 stars 144 forks source link

WebGUI #635

Open hirsty opened 8 years ago

hirsty commented 8 years ago

If you guys cvan think up the design, I do not mind createing the WebGUI would probs be Laravel/Bootstrap

Flukethoughts commented 8 years ago

webui would seem like an awesome concept but however I would never use it. No offence but to use such would be a security concern for the server as a whole however if you could work on the -webalerts part that would be awesome as all get out for us custom servers.

hirsty commented 8 years ago

thoughts were about the clusters and some of the confusions with the GameUserSettings ini and Game.ini. Whats the current webalert stuff? Any current issues for reference?

Flukethoughts commented 8 years ago

most info i can grab from it is https://survivetheark.com/index.php?/forums/topic/71544-tutorial-set-up-web-notifications-properly-to-receive-e-mails/

hirsty commented 8 years ago

ah ok fairly easy dunno if you have a domain for me to code on if we are making it central but my idea is that servers register then api and access code generated, with optional logo upload, users reg with steam login email and access code and can unsub using link in email

thamathar commented 8 years ago

This would be nice, I have been trying to use the shell_exec of php to have access to the arkmanager stuff without success, still trying to figure this out hehe, allways get the same:

"[  ERROR  ] Your SteamCMD root seems not valid. [  ERROR  ] Your SteamCMD exec could not be found. [  ERROR  ] You have not rights to write in the log directory."

klightspeed commented 8 years ago

PHP would be running under the apache user, which wouldn't have access to the contents of your steam user's home directory, especially if selinux is enabled.

You might want to use visudo to add something like the following to /etc/sudoers:

apache ALL=(steam) NOPASSWD: /usr/local/bin/arkmanager

Then you would use something like:

$arkmanagerUser = "steam";
$arkmanagerExec = "/usr/local/bin/arkmanager";
function arkmanager($args){
    $cmd = "sudo -u " + escapeshellarg($arkmanagerUser) + " " + escapeshellarg($arkmanagerExec);
    foreach ($args as $arg){
        $cmd += " " + escapeshellarg($arg);
    }
    return shell_exec($cmd);
}

# examples:
arkmanager("status");
arkmanager("rconcmd", "broadcast hello");
thamathar commented 8 years ago

If I use

<?php print_r(get_current_user()); '>

I will get a return of steam ( the user that is running the arkmanager) Thats why I rly don't understand what is going here hehe, but I will try to what u should told me to see if it works :D Thanks

thamathar commented 8 years ago

BtW sorry forgot to mention, I did a user install, prefer this way :D

klightspeed commented 8 years ago

If you did a user-install, and removed $HOME/.config/arkmanager/instances/main.cfg in #642, then you will need to refer to instance.cfg.example to add the necessary settings to $HOME/.arkmanager.cfg

thamathar commented 8 years ago

@klightspeed

Was trying to refer to what you say for the $arkmanagerExec = "/usr/local/bin/arkmanager";

Should not be:

$arkmanagerExec = "/home/steam/bin/arkmanager"; since its where the arkmanager file is ?

thamathar commented 8 years ago

BtW allways get the "sh: 1: 0: not found" on error.log of apache, with the code you provide (even with the /usr/local/bin/arkmanager or with the one /home/steam/bin/arkmanager)

@klightspeed another small update.

If i direct on the shell_exec put this:

$output = shell_exec('sudo -u steam /home/steam/bin/arkmanager status');

I get this as result:

We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things:

1) Respect the privacy of others.

2) Think before you type.

3) With great power comes great responsibility.

sudo: no tty present and no askpass program specified

klightspeed commented 8 years ago

D'oh - + is for arithmetic, when I should have used . (string concatenation).

$arkmanagerUser = "steam";
$arkmanagerExec = "/home/steam/bin/arkmanager";
function arkmanager($args){
    $cmd = "sudo -u " . escapeshellarg($arkmanagerUser) . " " . escapeshellarg($arkmanagerExec);
    foreach ($args as $arg){
        $cmd .= " " . escapeshellarg($arg);
    }
    return shell_exec($cmd);
}

# examples:
arkmanager("status");
arkmanager("rconcmd", "broadcast hello");
thamathar commented 8 years ago

@klightspeed allways get this :/

sudo: no tty present and no askpass program specified

have the code like yours, only did have to add the (array) cast for $args on the for each

<?php
ini_set('display_errors',1);
error_reporting(E_ALL);

function arkmanager($args){
    $arkmanagerUser = "steam";
    $arkmanagerExec = "/home/steam/bin/arkmanager";
    $cmd = "sudo -u " . escapeshellarg($arkmanagerUser) . " " . escapeshellarg($arkmanagerExec);
    foreach ((array)$args as $arg){
        $cmd .= " " . escapeshellarg($arg) . "";
    }
    return shell_exec($cmd);
}
$output = arkmanager("status");

echo "<pre>$output</pre>";
arkmanager("rconcmd", "broadcast hello");
?>
klightspeed commented 8 years ago

Since you're running PHP under the steam user, you don't need sudo.

Try:

<?php
ini_set('display_errors',1);
error_reporting(E_ALL);

function arkmanager(){
    $arkmanagerExec = "/home/steam/bin/arkmanager";
    $cmd = escapeshellarg($arkmanagerExec);
    foreach (func_get_args() as $arg){
        $cmd .= " " . escapeshellarg($arg) . "";
    }
    return shell_exec($cmd);
}
$output = arkmanager("status");

echo "<pre>$output</pre>";
?>

If you have PHP 5.6 or later, you can try:

<?php
ini_set('display_errors',1);
error_reporting(E_ALL);

function arkmanager(...$args){
    $arkmanagerExec = "/home/steam/bin/arkmanager";
    $cmd = escapeshellarg($arkmanagerExec);
    foreach ($args as $arg){
        $cmd .= " " . escapeshellarg($arg) . "";
    }
    return shell_exec($cmd);
}
$output = arkmanager("status");

echo "<pre>$output</pre>";
?>
thamathar commented 8 years ago

Fix it, the problem was with the sudoers file.

I did the whoami command with apache I got the return of www-data, and on the sudoers it was like this:

apache ALL=(steam) NOPASSWD: /usr/local/bin/arkmanager

and should be like

www-data ALL=(steam) NOPASSWD: /usr/local/bin/arkmanager

My head isn't thinking right any more hehe all most 3AM here -.- time to go to bet.

by the way the code that is working its like:

<?php
ini_set('display_errors',1);
error_reporting(E_ALL);

function arkmanager($args){
    $arkmanagerUser = "steam";
    $arkmanagerExec = "/home/steam/bin/./arkmanager";
    $cmd = "sudo -u " . escapeshellarg($arkmanagerUser) . " " . escapeshellarg($arkmanagerExec);
    foreach ((array)$args as $arg){
        $cmd .= " " . escapeshellarg($arg) . "";
    }
    return shell_exec($cmd);
}

# examples:
$output = arkmanager("status");
echo "<pre>$output</pre>";
?>
hirsty commented 8 years ago

Well still waiting on what it is u guys are wanting - not worked on anything yet - is it just a notification thing you want or?

thamathar commented 8 years ago

It work like I have told on the previous comment :D and what I did to "fix" it. The problem was the wrong permissions on the arkmanager on the sudoers file

hirsty commented 8 years ago

orig q was do they want a WebGUI or a webnotification app

hirsty commented 8 years ago

time to make a start on web alerts :D screenshot_3

hirsty commented 8 years ago

ok the alpha stage is ready for anyone to try - no editing of content yet - just plain text :D http://webalarm.danielhirst.info

klightspeed commented 8 years ago

@hirsty were you trying to run the server directly using the -webalarm option, and/or specifying the arkflag_webalarm=true option in your arkmanager instance config?

hirsty commented 8 years ago

@klightspeed using arkflag_webalarm=true, trying on TheIsland this morningg -did a tcpdump last night and saw no post logs

klightspeed commented 8 years ago

@hirsty Were any tripwires tripped or babies born during that time?

hirsty commented 8 years ago

@klightspeed I intentionally triggered a tripwire alarm,

hirsty commented 8 years ago

@klightspeed no one on the server right now to trigger it (if they fixed up self-triggering

hirsty commented 8 years ago

screenshot_4

hirsty commented 8 years ago

ok so it doesnt trip if you trip over it

hirsty commented 8 years ago

@klightspeed PROOF - seems to put everything in notetitle.....

screenshot_5

hirsty commented 8 years ago

And it is open to everyone to use so feel free to put it on the readme if you wish or something and close the issue :)

Lihis commented 8 years ago

I found easy way to test tripwire alarms when I was implenting tripwire alarms to my server and website: spawn eg. dodo with admin command and make it walk trough the tripwire.

I wasted sometime too before I found that alarms are not sent if you trigger the tripwire yourself and if I recall correctly the alarm is not sent if the person who triggers it is from same tribe.

And pretty neat thing that which you made :thumbsup:

hirsty commented 8 years ago

thanks @Lihis like i said, its open for anyone to use - and as im using an auth/api system - no messages will get mixed up and no1 can sign up as sum1 else so its quite secure that way

cronner commented 7 years ago

Did anyone do a WebGUI for arkmanager? Would be really usefull to see online users, kick, ban, change settings, restart, stop, start, logs, etc from a webpage