Skip to content

Commit a9a53bd

Browse files
dgibbs64gitbook-bot
authored andcommitted
GITBOOK-34: change request with no subject merged in GitBook
1 parent 0620a2a commit a9a53bd

12 files changed

+171
-161
lines changed

SUMMARY.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,19 @@
2424

2525
## Technical
2626

27+
* [Main Executable](technical/main-executable.md)
2728
* [Commands](technical/commands.md)
2829
* [Exit Codes](technical/exit-codes.md)
2930
* [Functions](technical/functions.md)
30-
* [Modules](technical/modules.md)
31+
* [Modules](technical/modules/README.md)
32+
* [Fixes](technical/modules/fixes.md)
33+
* [Core](technical/modules/core.md)
3134
* [Game Server Querying](technical/game-server-querying.md)
35+
* [Messages & Logs](technical/messages-and-logs.md)
36+
* [Checks](technical/checks.md)
37+
* [Exit](technical/exit.md)
38+
* [Install](technical/install.md)
39+
* [Debuggins](technical/debuggins.md)
3240

3341
## Code Standards
3442

Lines changed: 6 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,173 +1,19 @@
11
# Developing LinuxGSM
22

3-
This page has been designed to help you learn how LinuxGSM code works.
4-
5-
As a user, it will allow you a better understanding of how LinuxGSM works. As a developer, it will help you with adding new servers, fixing bugs, and adding new features.
6-
7-
## Generalities
8-
9-
The LinuxGSM _executable_ `./gameserver` is the main entry point for users, their main interactions will be with this script. However, from a development perspective, this is only the gateway as it simply does the initial bootstrap and points to the commands and modules that are stored elsewhere. LinuxGSM is made up of many smaller (mainly bash) scripts (modules) that interact with each other to complete a set of tasks. A command will complete its set of tasks using the LinuxGSM modules.
10-
11-
## Main Executable
12-
13-
The main executable file `linuxgsm.sh` or `gameserver` is what the user interacts with to run commands.
14-
15-
`linuxgsm.sh` is designed to be used for the installation of a specific game server. You can run `./linuxgsm.sh install` to get a menu of the available servers or `./linuxgsm.sh gameserver` to install the specific game server.
16-
17-
To install a specific server `linuxgsm.sh` first downloads a complete list of all available servers from `serverlist.csv`. This file contains variables required to identify the server; `${gamename}`, `${shortname}` and `${servername}`. When installing a game server `linuxgsm.sh` copies itself using the`${servername}` variable as the script name and inserting the other variables into the copied file. The added variables allow LinuxGSM to know which server the user selected.
18-
19-
A user can also run the install again if they want multiple instances of the same server. This will give an output of `gameserver-2`,`gameserver-3` etc as the file name.
20-
213
## Modules
224

235
Modules are individual bash scripts containing code and functions that complete specific tasks. See the [modules](broken-reference) page for more info.
246

25-
## Commands
26-
27-
Within LInuxGSM there are many commands that a user will run to complete tasks such as start, stop, monitor, and details. Command scripts are stored will all other modules and are always named something like `command_install.sh`. See the [commands](broken-reference) page for more info.
28-
29-
30-
31-
#### Fixes
32-
33-
`command_install.sh` runs `fix.sh` at the end of server installation. If the given server requires a fix, then add `fix_gameserver.sh` and run it from `fix.sh`.
34-
35-
#### Core functions
36-
37-
**core\_dl.sh**
38-
39-
This is the first script to be run when `gameserver`is executed. This script allows for fetching LinuxGSM core files, but also for downloading big files within kind of an API.
40-
41-
**core\_functions.sh**
42-
43-
This is the second script to be run when `gameserver`is executed. This script declares all functions and fetches them when they are required.
44-
45-
**core\_getopt.sh**
46-
47-
This is the third and last script to be run when `gameserver`is executed. This script allows for setting and printing available commands to the user.
48-
49-
**core\_messages.sh**
50-
51-
This script allows for easy message output and logging. More details about it in the next part.
52-
53-
#### Messages & Logs
54-
55-
LGSM has a message/logging framework to avoid painful syntax into scripts.
56-
57-
Framework syntax is: `fn_print_whatever "This is your message"` If you want to replace the line afterwards, then reuse `fn_print_whatever`. If you want a new output on a new line, then use `fn_print_whatever_nl`. "nl" stands for "new line".
58-
59-
**On-Screen - Automated functions**
60-
61-
* \[ .... ] | fn\_print\_dots | fn\_print\_dots\_nl
62-
* \[ OK ] | fn\_print\_ok | fn\_print\_ok\_nl
63-
* \[ FAIL ] | fn\_print\_fail | fn\_print\_fail\_nl
64-
* \[ ERROR ] | fn\_print\_error | fn\_print\_error\_nl
65-
* \[ WARN ] | fn\_print\_warn | fn\_print\_warn\_nl
66-
* \[ INFO ] | fn\_print\_info | fn\_print\_info\_nl
67-
68-
**On-Screen - Interactive messages**
69-
70-
* Print $gamename $commandaction and jump some lines | fn\_print\_header (used at the beginning of a command)
71-
* Complete! |fn\_print\_complete | fn\_print\_complete\_nl
72-
* Failure! | fn\_print\_failure | fn\_print\_failure\_nl
73-
* Error! | fn\_print\_error2 | fn\_print\_error2\_nl
74-
* Warning! | fn\_print\_warning | fn\_print\_warning\_nl
75-
* Information! | fn\_print\_information | fn\_print\_information\_nl
76-
77-
**On-Screen End of Line**
78-
79-
* OK| fn\_print\_ok\_eol | fn\_print\_ok\_eol\_nl
80-
* FAIL | fn\_print\_fail\_eol | fn\_print\_fail\_eol\_nl
81-
* WARN | fn\_print\_warn\_eol | fn\_print\_warn\_eol\_nl
82-
* FAIL | fn\_print\_info\_eol | fn\_print\_info\_eol\_nl
83-
* QUERYING | fn\_print\_querying\_eol | fn\_print\_querying\_eol\_nl
84-
* CHECKING | fn\_print\_checking\_eol | fn\_print\_checking\_eol\_nl
85-
* CANCELED | fn\_print\_canceled\_eol | fn\_print\_canceled\_eol\_nl
86-
* REMOVED | fn\_print\_removed\_eol | fn\_print\_removed\_eol\_nl
87-
* UPDATE | fn\_print\_update\_eol | fn\_print\_update\_eol\_nl
88-
89-
**Logging**
90-
91-
Syntax: `fn_script_log "Message goes here."` Output: `## Feb 28 14:56:58 ut99-server: Monitor: Message goes here.`
92-
93-
* Simple action log | fn\_script\_log
94-
* PASS (a successful test) | fn\_script\_log\_pass
95-
* FATAL (an error has interrupted LGSM) | fn\_script\_log\_fatal
96-
* ERROR | fn\_script\_log\_error
97-
* WARN | fn\_script\_log\_warn
98-
* INFO | fn\_script\_log\_info
99-
100-
#### Checks
101-
102-
Any script file must run `check.sh` at some point. Within `check.sh`, you will then choose what tests to run for a given function. The syntax of check.sh is a bit counter-intuitive: `local allowed_commands_array=( )` is the variable where you will enter the functions into which you need to run the following check.
103-
104-
There are several checks available:
105-
106-
* check\_config.sh checks for a missing config file or a wrong parameter.
107-
* check\_deps.sh checks for missing dependencies and contains requirements
108-
* check\_glibs.sh checks if the server has the correct Glibc version or a fix available.
109-
* check\_ip.sh automatically identifies the server interface IP.
110-
* check\_logs.sh checks if log files exist.
111-
* check\_permissions.sh checks ownership & permissions of scripts, files and directories
112-
* check\_root.sh checks if the user tried to run the script as root
113-
* check\_status.sh checks the process status of the server. Either online or offline
114-
* check\_steamcmd.sh checks if SteamCMD is installed correctly
115-
* check\_system\_dir.sh checks if systemdir is accessible
116-
* check\_system\_requirements.sh checks RAM requirements (maybe more into the future)
117-
* check\_tmuxception.sh checks and prevents server start from tmux or screen
118-
119-
**core\_exit.sh**
120-
121-
This script allows for the use of exit codes which will print different outputs to LinuxGSM logs. Running `core_exit.sh` defaults exitcode variable to 0 which stands for a proper exit
122-
123-
* Normal exit: exitcode=0
124-
* FATAL exitcode=1
125-
* ERROR: exitcode=2
126-
* WARN: exitcode=3
127-
128-
#### Server installation
129-
130-
Installing a new server is mainly done through two scripts:
131-
132-
* install\_server\_files.sh
133-
* install\_config.sh
134-
135-
Sometimes, another script is required, such as for TeamSpeak 3: `update_ts3.sh`
136-
137-
#### Versioning
138-
139-
At the moment, only the main "gameserver" script has a version number. The syntax is pretty easy, it's all incremental, based on the date: `version="YYMMDD"`
140-
141-
### Testing and debugging your code
142-
143-
#### Working from your own GitHub branch
144-
145-
You will usually be developing onto your own repo. Using your own repo instead of the original one is quite easy.
146-
147-
1. Display your main "gameserver" file on GitHub, and select "Raw".
148-
2. Make a test user, login to it
149-
3. wget your Raw link and chmod +x the script.
150-
4. Edit your "gameserver" file by changing GitHub information to your username and repo and branch.
7+
##
1518

152-
```bash
153-
## Github Branch Select
154-
# Allows for the use of different function files
155-
# from a different repo and/or branch.
156-
githubuser="YourUsername"
157-
githubrepo="YourRepository"
158-
githubbranch="YourBranchName"
159-
```
9+
##
16010

161-
Now, any command you run will get your own GitHub files, and after any change you make on your repo, `./gameserver uf` will grab new files. If you make a change and that `./gameserver uf` don't get them, it means you were too quick, and that your curl still has old files in cache; in this case, you'll need to wait a few minutes to get your modifications.
11+
##
16212

163-
#### How to test
13+
##
16414

165-
You need to make sure that all needed commands displayed in opt work properly. So just run `./gameserver` to show available commands, then try commands one by one. A common procedure is to first work on command\_install, then start, then stop, then debug, then details, then monitor.
16615

167-
#### Oops, I found a bug!
16816

169-
If you found a bug, either you'll instantly know how to fix it, or you won't. And either it will be a bug caused by your own code or a bug into LinuxGSM itself. So let's address those cases.
17+
####
17018

171-
1. It's caused by your own code parts and you know how to fix it: Just go on and fix it.
172-
2. It's caused by your own code parts but you got no idea why: Use `./gameserver dev-debug` that will add a very detailed log into your rootdir that might help you figure this out. To disable the dev-debug mode, just re-run the command. If you still can't find why it's not working, come get help on Discord's #gsm-development channel or Github issue that might have been created for this issue.
173-
3. You found a bug into LinuxGSM itself. First, you need to be sure that it's really a bug that affects every game, by testing with another game onto the original repo, otherwise, if it only affects your game, you will usually just need to add a clever conditional check to fix the issue.
19+
##

technical/checks.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Checks
2+
3+
Any script file must run `check.sh` at some point. Within `check.sh`, you will then choose what tests to run for a given function. The syntax of check.sh is a bit counter-intuitive: `local allowed_commands_array=( )` is the variable where you will enter the functions into which you need to run the following check.
4+
5+
There are several checks available:
6+
7+
* check\_config.sh checks for a missing config file or a wrong parameter.
8+
* check\_deps.sh checks for missing dependencies and contains requirements
9+
* check\_glibs.sh checks if the server has the correct Glibc version or a fix available.
10+
* check\_ip.sh automatically identifies the server interface IP.
11+
* check\_logs.sh checks if log files exist.
12+
* check\_permissions.sh checks ownership & permissions of scripts, files and directories
13+
* check\_root.sh checks if the user tried to run the script as root
14+
* check\_status.sh checks the process status of the server. Either online or offline
15+
* check\_steamcmd.sh checks if SteamCMD is installed correctly
16+
* check\_system\_dir.sh checks if systemdir is accessible
17+
* check\_system\_requirements.sh checks RAM requirements (maybe more into the future)
18+
* check\_tmuxception.sh checks and prevents server start from tmux or screen

technical/commands.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Commands
22

3+
## Commands
4+
5+
Within LinuxGSM there are many commands that a user will run to complete tasks such as start, stop, monitor, and details. Command scripts are stored will all other modules and are always named something like `command_install.sh`. See the [commands](broken-reference) page for more info.
6+
37
Within LinuxGSM there are many commands that a user will run to complete tasks such as start, stop, monitor, and details. Command scripts are stored with all other modules and are always named something like `command_install.sh`.
48

59
Some game servers may require bespoke commands to complete tasks. Examples of this include Teamspeak 3 and Unreal Tournament 2004. Take a look at the `core_getopts.sh` module for examples of how to add commands.

technical/debuggins.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Debuggins
2+
3+
## Testing and debugging your code
4+
5+
#### Working from your own GitHub branch
6+
7+
You will usually be developing onto your own repo. Using your own repo instead of the original one is quite easy.
8+
9+
1. Display your main "gameserver" file on GitHub, and select "Raw".
10+
2. Make a test user, login to it
11+
3. wget your Raw link and chmod +x the script.
12+
4. Edit your "gameserver" file by changing GitHub information to your username and repo and branch.
13+
14+
```bash
15+
## Github Branch Select
16+
# Allows for the use of different function files
17+
# from a different repo and/or branch.
18+
githubuser="YourUsername"
19+
githubrepo="YourRepository"
20+
githubbranch="YourBranchName"
21+
```
22+
23+
Now, any command you run will get your own GitHub files, and after any change you make on your repo, `./gameserver uf` will grab new files. If you make a change and that `./gameserver uf` don't get them, it means you were too quick, and that your curl still has old files in cache; in this case, you'll need to wait a few minutes to get your modifications.
24+
25+
#### How to test
26+
27+
You need to make sure that all needed commands displayed in opt work properly. So just run `./gameserver` to show available commands, then try commands one by one. A common procedure is to first work on command\_install, then start, then stop, then debug, then details, then monitor.
28+
29+
#### Oops, I found a bug!
30+
31+
If you found a bug, either you'll instantly know how to fix it, or you won't. And either it will be a bug caused by your own code or a bug into LinuxGSM itself. So let's address those cases.
32+
33+
1. It's caused by your own code parts and you know how to fix it: Just go on and fix it.
34+
2. It's caused by your own code parts but you got no idea why: Use `./gameserver dev-debug` that will add a very detailed log into your rootdir that might help you figure this out. To disable the dev-debug mode, just re-run the command. If you still can't find why it's not working, come get help on Discord's #gsm-development channel or Github issue that might have been created for this issue.
35+
3. You found a bug into LinuxGSM itself. First, you need to be sure that it's really a bug that affects every game, by testing with another game onto the original repo, otherwise, if it only affects your game, you will usually just need to add a clever conditional check to fix the issue.

technical/exit.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Exit
2+
3+
**core\_exit.sh**
4+
5+
This script allows for the use of exit codes which will print different outputs to LinuxGSM logs. Running `core_exit.sh` defaults exitcode variable to 0 which stands for a proper exit
6+
7+
* Normal exit: exitcode=0
8+
* FATAL exitcode=1
9+
* ERROR: exitcode=2
10+
* WARN: exitcode=3

technical/install.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Install
2+
3+
#### Server installation
4+
5+
Installing a new server is mainly done through two scripts:
6+
7+
* install\_server\_files.sh
8+
* install\_config.sh
9+
10+
Sometimes, another script is required, such as for TeamSpeak 3: `update_ts3.sh`

technical/main-executable.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Main Executable
2+
3+
The LinuxGSM _executable_ `./gameserver` is the main entry point for users, their main interactions will be with this script. However, from a development perspective, this is only the gateway as it simply does the initial bootstrap and points to the commands and modules that are stored elsewhere. LinuxGSM is made up of many smaller (mainly bash) scripts (modules) that interact with each other to complete a set of tasks. A command will complete its set of tasks using the LinuxGSM modules.
4+
5+
The main executable file `linuxgsm.sh` or `gameserver` is what the user interacts with to run commands.
6+
7+
`linuxgsm.sh` is designed to be used for the installation of a specific game server. You can run `./linuxgsm.sh install` to get a menu of the available servers or `./linuxgsm.sh gameserver` to install the specific game server.
8+
9+
To install a specific server `linuxgsm.sh` first downloads a complete list of all available servers from `serverlist.csv`. This file contains variables required to identify the server; `${gamename}`, `${shortname}` and `${servername}`. When installing a game server `linuxgsm.sh` copies itself using the`${servername}` variable as the script name and inserting the other variables into the copied file. The added variables allow LinuxGSM to know which server the user selected.
10+
11+
A user can also run the install again if they want multiple instances of the same server. This will give an output of `gameserver-2`,`gameserver-3` etc as the file name.

technical/messages-and-logs.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Messages & Logs
2+
3+
LGSM has a message/logging framework to avoid painful syntax into scripts.
4+
5+
Framework syntax is: `fn_print_whatever "This is your message"` If you want to replace the line afterwards, then reuse `fn_print_whatever`. If you want a new output on a new line, then use `fn_print_whatever_nl`. "nl" stands for "new line".
6+
7+
**On-Screen - Automated functions**
8+
9+
* \[ .... ] | fn\_print\_dots | fn\_print\_dots\_nl
10+
* \[ OK ] | fn\_print\_ok | fn\_print\_ok\_nl
11+
* \[ FAIL ] | fn\_print\_fail | fn\_print\_fail\_nl
12+
* \[ ERROR ] | fn\_print\_error | fn\_print\_error\_nl
13+
* \[ WARN ] | fn\_print\_warn | fn\_print\_warn\_nl
14+
* \[ INFO ] | fn\_print\_info | fn\_print\_info\_nl
15+
16+
**On-Screen - Interactive messages**
17+
18+
* Print $gamename $commandaction and jump some lines | fn\_print\_header (used at the beginning of a command)
19+
* Complete! |fn\_print\_complete | fn\_print\_complete\_nl
20+
* Failure! | fn\_print\_failure | fn\_print\_failure\_nl
21+
* Error! | fn\_print\_error2 | fn\_print\_error2\_nl
22+
* Warning! | fn\_print\_warning | fn\_print\_warning\_nl
23+
* Information! | fn\_print\_information | fn\_print\_information\_nl
24+
25+
**On-Screen End of Line**
26+
27+
* OK| fn\_print\_ok\_eol | fn\_print\_ok\_eol\_nl
28+
* FAIL | fn\_print\_fail\_eol | fn\_print\_fail\_eol\_nl
29+
* WARN | fn\_print\_warn\_eol | fn\_print\_warn\_eol\_nl
30+
* FAIL | fn\_print\_info\_eol | fn\_print\_info\_eol\_nl
31+
* QUERYING | fn\_print\_querying\_eol | fn\_print\_querying\_eol\_nl
32+
* CHECKING | fn\_print\_checking\_eol | fn\_print\_checking\_eol\_nl
33+
* CANCELED | fn\_print\_canceled\_eol | fn\_print\_canceled\_eol\_nl
34+
* REMOVED | fn\_print\_removed\_eol | fn\_print\_removed\_eol\_nl
35+
* UPDATE | fn\_print\_update\_eol | fn\_print\_update\_eol\_nl
36+
37+
**Logging**
38+
39+
Syntax: `fn_script_log "Message goes here."` Output: `## Feb 28 14:56:58 ut99-server: Monitor: Message goes here.`
40+
41+
* Simple action log | fn\_script\_log
42+
* PASS (a successful test) | fn\_script\_log\_pass
43+
* FATAL (an error has interrupted LGSM) | fn\_script\_log\_fatal
44+
* ERROR | fn\_script\_log\_error
45+
* WARN | fn\_script\_log\_warn
46+
* INFO | fn\_script\_log\_info
File renamed without changes.

technical/modules/core.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Core
2+
3+
### **core\_dl.sh**
4+
5+
This is the first script to be run when `gameserver`is executed. This script allows for fetching LinuxGSM core files, but also for downloading big files within kind of an API.
6+
7+
### **core\_modules.sh**
8+
9+
This is the second script to be run when `gameserver`is executed. This script declares all functions and fetches them when they are required.
10+
11+
### **core\_getopt.sh**
12+
13+
This is the third and last script to be run when `gameserver`is executed. This script allows for setting and printing available commands to the user.
14+
15+
### **core\_messages.sh**
16+
17+
This script allows for easy message output and logging. More details about it in the next part.

technical/modules/fixes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Fixes
2+
3+
##
4+
5+
`command_install.sh` runs `fix.sh` at the end of server installation. If the given server requires a fix, then add `fix_gameserver.sh` and run it from `fix.sh`.

0 commit comments

Comments
 (0)