JimTR Web Interface
Currently The Code I have written has the following features -
- Allows Game control from either a local host or a remote host , the remote option does require a valid unix user on the remote machine & this user name & password is passed to the remote server to ensure the permissions are correct.
- HTML is created via a template engine I coded for another project, which ensures that php code is not allowed in the html file, all results from PHP are fed into the html using variables before PHP renders the completed file, from this a subset of files can be added to the main html file meaning jscript etc. can be added before the browser loads the file so the included are all in-line rather than being loaded from a resource as the browser renders the page.
Requirements from lgsm is to remove the ansi codes from its displays as the web interface currently uses the PHP exec function to get the data back from lsgm example -
exec($path."gmodserver start",$output1)
where the $path variable has been setup up earlier ( point 1) and lgsm's responses, in this example, are stored in the variable $output1 ... $output1 then has to be sanitized of ansi ( as css will style the responses back from lgsm). I guess a variable in the lgsm script could be set to stop ansi codes being sent maybe gui = 1 or 0 depending if ansi is required or not. apart from that I guess everything will work fine .... I'll let you know if I hit other points.
Currently there is No Git for this project but I will drop a link here when I have the structure of the git done
Hmmm not sure the best way to go about striping/adding the ansi code in the correct places since they are pretty much just part of the echo commands. Having to separate messages its inefficient so my guess is teh best way to go about it is to somehow insert the ansi by default and have an option to disable it. I don't really want to loose the pretty command line colours haha. I will have a good think about this. Suggestions welcome
Also do you have a screenshot I would like to see what it looks like :)
Interesting!
How the panel will look like is up to you, So I could send you a screen shot of how I see it & within 10 mins someone else could alter the css and or HTML to look totally different, however I will up load a screen shot of how I set the html ... example of the way a html file is coded is `
from this you can see the responses from lsgm are injected into the html before it is rendered so contains the total number of players on the server ... bad example really as this value is returned from the gameQ class and not lsgm... if you want I'll throw up a game server & an example of how I think the html should look ... I'll post back when the demo is running
So if i'm getting it, you need a single user for all servers in order for it to work ? And the PHP/Web server has to be on the same machine as the "game" server ? Or can it be another machine, or even a slave, and a master ?
An amazing thing would be to have some kind of an admin interface to manage users and give them permissions to control some servers only (using a database for example). That way, you could allow a given admin to view some server status, start/stop/restart it, but not wipe/reinstall or port change.
Game query is a good example actually, we talked about it at some point. It's really something to add to LGSM that would allow nice features.(like saving CPU by rebooting a server if 0 players are connected, but CPU usage is > 50%). I'll open an issue after the next major update. :)
you can have a remote game server to the web server ... a simple method is to have both on the same server but the demo I am putting up at the moment will show the web interface on one server & the game running on another
So it's a master/slave system, but they can also be both on the same machine. Perfect :) Security will have to rock on this though. But all servers have to be on the same user, right ?
I think it's best to differentiate between LSGM for personal use and LSGM for use with multiple servers and multiple different users. With the lather it'd be best to have each server run on a different user.
I don't think there's much overhead for having different users per server anyway so it might be best practice to always do this.
That is exactly how the remote setup works
So PHP is able to run commands as a user onto the slave as long as it has its IDs. Couldn't dream better. :)
there are some caveats which I will explain later but are of no real problem if you can use linux ... so we have a demo running .... goto lightsoundstudios.eu login with the username 'tracey' password is tester . click my area then click game control panel you will notice the web stuff is on a different IP/machine/server to the game server. currently all the controls have been disabled as this is just an idea on what my html looks like
Something else that I forgot could lgsm add the port to the service name so when servicename is defined, it is like this - servicename="servername-"${port} this may require an extra setup question to confirm the port ... however I guess the web interface could write all used ports to a file & lgsm just add 1 to the last entry in the file as the web interface would just write the file in port order
It should be able to read the lgsm script or config to extract the port, right?
no this just makes it a bit easier to identify the tmux window when you are running more than one server, example - gmodserver-27015 & gmodserver-27035 rather than reading the script(s) each time you want to find out what the tmux window has been created as . The web GUi on install, names the base script with it's port appended so I guess I could rename the service name at the same time of altering the port in the script.
Over the weekend I have taken the web gui away from a plugin to my frame work and made it a stand alone project there is a demo at http://noideergames.cu.cc/ with the same login ... This is going to be a little harder to get right as a stand alone (there were so many framework functions the plugin used but it may be a better design in the end. I have opened up the 'join game' button so you can test the players online function
I really need some way around this ... for web purpose perhaps the scripts are a bit too verbose I get returns from them like
Array ( [0] => [K[ .... ] Starting gmod-server-27015: Garry's Mod Web GUI Test [K[[0;36m INFO [0m] Starting gmod-server-27015: Garry's Mod Web GUI Test is already running )
where as all I need is a flag .. E.G Started,didn't start,already running so the script could just return 1 of 3 values E.G 0 or 1 or 2 rather than searching the return string for something (example : - already running ) as if the text is changed by either language or content the web interface will fail
sounds like you need exit codes. if you run a command then to echo $? you get the exit code. this normally returns 0 for OK or another number for an error.
Since you already know the command you are running you simply need to basically get an OK or FAIL message so the web interface knows if the command worked or not. LGSM already uses exit codes 0 and 1. However I can customize the codes and then put together a list of what the error mean. that way if the script returns for example error 5 you can print on the interface "FAIL! Low disk space" or something to that effect.
Let me know if you think exit codes could work for your interface
Exit codes will work well, the php exec function has a return variable for that. so a list of exit codes and their meanings will be spot on
Cool I dont have a list of anything yet but I will start putting together something.
There is now a git .. here To be fair don't download the code yet as there is no install routine yet but if you are brave let me know & I'll walk you through the install. But I guess you can open issues there regarding the demo noted above.
I think there is too much apelle outdoor URL to retrieve a lot of information