I apologise in advance for the amount of formatting applied here, but my intention was to better illustrate each point.
==========================================
I would recommend using set built-ins for your script. For example, set -e will exit the script for any error occurred during command execution, and thus prevents from performing any destructive / unstable actions accidentally:
#!/bin/sh
set -e
2. Similarly, you could add `DEBUG` switch and activate `set -x` mode for traceability.
==========================================
3. You can simplify killing of your `screen`s by sending a [`quit`](https://linux.die.net/man/1/screen) command to them, instead of grep'ping and awk'ing PIDs for the `kill`, like you do here:
https://github.com/TouchMe-Inc/l4d2_ds_script/blob/fc0bf9aa5db197a03efc28ca81f667a27ba1009e/srcds#L96
https://github.com/TouchMe-Inc/l4d2_ds_script/blob/fc0bf9aa5db197a03efc28ca81f667a27ba1009e/srcds#L108
Example:
```bash
screen -S "$SCREENNAME" -X quit
While this may be required for some wildly different server configs, unless you have that you can use the same SRCDS installation to run multiple identical instances, since there are no locks on any shared files (except for logs which can easily be forked by using sv_logsdir <dir> launch parameter).
You can validate it for yourself by running lslocks and examining the output:
It might be better to concatenate your script's requirements with the existing PATH:
PATH="/bin:/usr/bin:/sbin:/usr/sbin:$PATH"
==========================================
I can tell that this script is meant to be run as root (due to usage of su for command execution). This is generally very unsafe approach and it would be nice to make this configurable.
I know about the possibility of running a server from one directory. In this case, there is a problem with sourcemod and its logs, as well as some plugins that have their own special configurations in “/configs/”. It's expensive to rewrite each of them.
For the script I only considered Ubuntu 18/20
Yes you are right. The script was written a long time ago and I simply missed this point. Thank you
I apologise in advance for the amount of formatting applied here, but my intention was to better illustrate each point.
==========================================
set -e
will exit the script for any error occurred during command execution, and thus prevents from performing any destructive / unstable actions accidentally:set -e
==========================================
While this may be required for some wildly different server configs, unless you have that you can use the same SRCDS installation to run multiple identical instances, since there are no locks on any shared files (except for logs which can easily be forked by using
sv_logsdir <dir>
launch parameter).You can validate it for yourself by running
lslocks
and examining the output:==========================================
PATH
for the script may lead to unforeseen consequences in different environments: https://github.com/TouchMe-Inc/l4d2_ds_script/blob/fc0bf9aa5db197a03efc28ca81f667a27ba1009e/srcds#L66-L67It might be better to concatenate your script's requirements with the existing
PATH
:==========================================
root
(due to usage ofsu
for command execution). This is generally very unsafe approach and it would be nice to make this configurable.==========================================
Hope that helps. Cheers.