Change variables to be overwritten by environment variables
Instead of setting variables using foo = "bar" style, a alternative could be to use foo = "${foo:-"bar"}" since it would allow defining variables beforehand.
This is very useful if you want to use scripts from here in Docker since it's often best to only change application data (game folders, logs etc.) and not binaries/scripts.
It would not be required change the variables in the function scripts. There could be potential problems regarding existing variables on the system, but I have not found any on a new Ubuntu 16.04 (using printenv). Another problem I see is integrating it with all the branches and other ongoing development without breaking stuff.
Thoughts?
Well, if this allows people to use dockers (and there have been some) it's something to maybe consider. LGSM has not been considering dockers for now. I personally still don't know much about dockers so... a "why would it fix it" explanation would be welcome. However the major downside i see to it is that it would look way less pretty and way less easy to edit for users. Maybe, it's something that could be done to the main script after we moved configs to external files ? (yes, this is a project, sorry for spoiler :p)
The "why" would be that users could run something like docker run -it -p 1.2.3.4:27015:27015 -e "port=27015" -e ="ip=1.2.3.4" lgsm-css:latest start to create a new server in very few seconds instead of full installs for every server, and all the dependencies and setup would already be done in the docker image that can be reused by multiple docker containers (by default, docker transparently uses files from a image unless it has been changed in the container). It's also possible to "mount" a directory making stuff like maps shared among multiple servers easy.
For testing I've build a Dockerfile and edited the script for garrys mod. Turns out docker only runs untill whatever used in the docker run command runs, meaning using tmux is not possible (or needed) and it's currently only possible to run the server in debug mode. I imagine a special command that starts a server without using tmux would fix this. I'm also unsure if srcds is able to bind to IP addresses, I had to remove the -ip part of the parameters for it to be able to run.
Looking at it again from a docker perspective, it seems to require a good amount of work, but it could be worth it imo :)
srcds can usually bind to IPv4s with no issue, unless there is some weird stuff happening to the IP routing when using dockers or something. Are dockers already kind of working like tmux does ? And is there some kind of environment variable to detect wether or not it's being started from a docker ?
It seems manageable to make special config files for dockers and some conditional checks (or a config setting... and loads of rework) to not use tmux, but would be much easier once config files have moved from main scripts. Would be preferable that somebody who actually uses dockers do it i guess. On the other hand, having two sets of config files for all servers would be a pain to maintain. From what i understand for the few years of LGSM usage and support and more recently, dev, is that the philosophy is 1) easy for users 2) as universal as possible 3) maintainable for devs. Keep that in mind. ^^
As someone that is running the servers on a 864 person lan using lgsm, docker is not a solution catered for game servers with mods at this moment. You are better off using lxc/lxd with overlayfs, or vmware with linked clones (current solution - could use hyper-v for free though). Mainly since game servers were more developed with a "pet ideology" than cattle since they are usually left running. Also much easier to assign CPU groups.