[GH-ISSUE #3734] [BUG] Function scripts are needing changes. #2466

Closed
opened 2026-02-27 03:03:08 +03:00 by kerem · 6 comments
Owner

Originally created by @alkaris2 on GitHub (Jan 7, 2022).
Original GitHub issue: https://github.com/GameServerManagers/LinuxGSM/issues/3734

I was having some issues with the function scripts thats included with LinuxGSM, and I have to say they are really needing some changes, because they do not work in their current state.

So the issue here, I was trying sort out setting up a Rust server, but there was issues, so I wanted to try run the fix_rust.sh script. Unfortunately the shell script does not function as you intended. Here's what goes on in the script;

#!/bin/bash
# LinuxGSM fix_rust.sh module
# Author: Daniel Gibbs
# Contributors: http://linuxgsm.com/contrib
# Website: https://linuxgsm.com
# Description: Resolves startup issue with Rust.

functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"

# Fixes: [Raknet] Server Shutting Down (Shutting Down).
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${serverfiles}:${serverfiles}/RustDedicated_Data/Plugins/x86_64"

# Part of random seed feature.
# If seed is not defined by user generate a seed file.
if [ -z "${seed}" ]; then
	if [ ! -f "${datadir}/${selfname}-seed.txt" ]; then
		shuf -i 1-2147483647 -n 1 > "${datadir}/${selfname}-seed.txt"
	fi
	seed="$(cat "${datadir}/${selfname}-seed.txt")"
	randomseed=1
fi

Do you see the issue here in this script? Here let me point it out.

When you run this, it checking in the data directory if a file with ${selfname}-seed.txt exists. But file does not exist, so it immediately fails when run. This selfname business is expecting something like rustserver-seed.txt or something like 1234567890-seed.txt if that's how it suppose to generate a file. So when you run the script you end up with this;

../functions/fix_rust.sh: line 17: /-seed.txt: Permission denied
cat: /-seed.txt: No such file or directory

throws permission denied, because of that trailing slash at the beginning like it's trying to access / root directory, thats also part of second issue there. You should have an else function in there if the file doesn't exist, because you're just assuming the file exists already.

Perhaps define where this ${datadir} is suppose to be before you call ${datadir}, and also replace the - with something else, because this character can and will be confused for a flag switch in some cases. I tried some script modifications of and the result that it ends up creating a file called -seed.txt and becomes unremovable because it's treating that - character as a flag option like; -s.


Script change proposals

Shuf can't be used to name the file using ${selfname} because you need to have a name to exist already, and would involve some bit to take generated number the seed generated from the file to append it to the file name as a prefix, which would only complicate the script more than it already needs to, so just define something simple.

#!/bin/bash
# LinuxGSM fix_rust.sh module
# Author: Daniel Gibbs
# Contributors: http://linuxgsm.com/contrib
# Website: https://linuxgsm.com
# Description: Resolves startup issue with Rust.

functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"

# Fixes: [Raknet] Server Shutting Down (Shutting Down).
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${serverfiles}:${serverfiles}/RustDedicated_Data/Plugins/x86_64"

# define datadir location so it knows where to look.
datadir="${HOME}/lgsm/data"

# define the selfname to keep it simple.
selfname="rust"

# Part of random seed feature.
# If seed is not defined by user generate a seed file.
if [ -z "${seed}" ]; then
	if [ ! -f "${datadir}/${selfname}_seed.txt" ]; then
		shuf -i 1-2147483647 -n 1 > "${datadir}/${selfname}_seed.txt"
        else
                shuf -i 1-2147483647 -n 1 > "${datadir}/${selfname}_seed.txt"
	fi
	seed="$(cat "${datadir}/${selfname}_seed.txt")"
	randomseed=1
fi

this should serve as somewhat better example for other scripts that rely on generating seed text files.

Originally created by @alkaris2 on GitHub (Jan 7, 2022). Original GitHub issue: https://github.com/GameServerManagers/LinuxGSM/issues/3734 I was having some issues with the function scripts thats included with LinuxGSM, and I have to say they are really needing some changes, because they do not work in their current state. So the issue here, I was trying sort out setting up a Rust server, but there was issues, so I wanted to try run the `fix_rust.sh` script. Unfortunately the shell script does not function as you intended. Here's what goes on in the script; ```BASH #!/bin/bash # LinuxGSM fix_rust.sh module # Author: Daniel Gibbs # Contributors: http://linuxgsm.com/contrib # Website: https://linuxgsm.com # Description: Resolves startup issue with Rust. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" # Fixes: [Raknet] Server Shutting Down (Shutting Down). export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${serverfiles}:${serverfiles}/RustDedicated_Data/Plugins/x86_64" # Part of random seed feature. # If seed is not defined by user generate a seed file. if [ -z "${seed}" ]; then if [ ! -f "${datadir}/${selfname}-seed.txt" ]; then shuf -i 1-2147483647 -n 1 > "${datadir}/${selfname}-seed.txt" fi seed="$(cat "${datadir}/${selfname}-seed.txt")" randomseed=1 fi ``` Do you see the issue here in this script? Here let me point it out. When you run this, it checking in the data directory if a file with `${selfname}-seed.txt` exists. But file does not exist, so it immediately fails when run. This `selfname` business is expecting something like `rustserver-seed.txt` or something like `1234567890-seed.txt` if that's how it suppose to generate a file. So when you run the script you end up with this; ``` ../functions/fix_rust.sh: line 17: /-seed.txt: Permission denied cat: /-seed.txt: No such file or directory ``` throws permission denied, because of that trailing slash at the beginning like it's trying to access `/` root directory, thats also part of second issue there. You should have an `else` function in there if the file doesn't exist, because you're just assuming the file exists already. Perhaps define where this `${datadir}` is suppose to be before you call `${datadir}`, and also replace the `-` with something else, because this character can and will be confused for a flag switch in some cases. I tried some script modifications of and the result that it ends up creating a file called `-seed.txt` and becomes unremovable because it's treating that `-` character as a flag option like; `-s`. --- ## Script change proposals Shuf can't be used to name the file using `${selfname}` because you need to have a name to exist already, and would involve some bit to take generated number the seed generated from the file to append it to the file name as a prefix, which would only complicate the script more than it already needs to, so just define something simple. ```BASH #!/bin/bash # LinuxGSM fix_rust.sh module # Author: Daniel Gibbs # Contributors: http://linuxgsm.com/contrib # Website: https://linuxgsm.com # Description: Resolves startup issue with Rust. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" # Fixes: [Raknet] Server Shutting Down (Shutting Down). export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${serverfiles}:${serverfiles}/RustDedicated_Data/Plugins/x86_64" # define datadir location so it knows where to look. datadir="${HOME}/lgsm/data" # define the selfname to keep it simple. selfname="rust" # Part of random seed feature. # If seed is not defined by user generate a seed file. if [ -z "${seed}" ]; then if [ ! -f "${datadir}/${selfname}_seed.txt" ]; then shuf -i 1-2147483647 -n 1 > "${datadir}/${selfname}_seed.txt" else shuf -i 1-2147483647 -n 1 > "${datadir}/${selfname}_seed.txt" fi seed="$(cat "${datadir}/${selfname}_seed.txt")" randomseed=1 fi ``` this should serve as somewhat better example for other scripts that rely on generating seed text files.
Author
Owner

@dgibbs64 commented on GitHub (Jan 7, 2022):

Are you trying to run the module directly?

<!-- gh-comment-id:1007240029 --> @dgibbs64 commented on GitHub (Jan 7, 2022): Are you trying to run the module directly?
Author
Owner

@h3o66 commented on GitHub (Jan 7, 2022):

The script fix_rust.sh is not supposed to be run manually by the user.
All variables what are not inited here, is done by the "framework".
Not sure what you want to try at all with this.

<!-- gh-comment-id:1007597421 --> @h3o66 commented on GitHub (Jan 7, 2022): The script `fix_rust.sh` is not supposed to be run manually by the user. All variables what are not inited here, is done by the "framework". Not sure what you want to try at all with this.
Author
Owner

@alkaris2 commented on GitHub (Jan 7, 2022):

The script fix_rust.sh is not supposed to be run manually by the user. All variables what are not inited here, is done by the "framework". Not sure what you want to try at all with this.

it still stands as is because it doesn't function as its suppose to.

<!-- gh-comment-id:1007766183 --> @alkaris2 commented on GitHub (Jan 7, 2022): > The script `fix_rust.sh` is not supposed to be run manually by the user. All variables what are not inited here, is done by the "framework". Not sure what you want to try at all with this. it still stands as is because it doesn't function as its suppose to.
Author
Owner

@h3o66 commented on GitHub (Jan 7, 2022):

The script fix_rust.sh is not supposed to be run manually by the user. All variables what are not inited here, is done by the "framework". Not sure what you want to try at all with this.

it still stands as is because it doesn't function as its suppose to.

I do not get your point.

<!-- gh-comment-id:1007768153 --> @h3o66 commented on GitHub (Jan 7, 2022): > > The script `fix_rust.sh` is not supposed to be run manually by the user. All variables what are not inited here, is done by the "framework". Not sure what you want to try at all with this. > > it still stands as is because it doesn't function as its suppose to. I do not get your point.
Author
Owner

@dgibbs64 commented on GitHub (Jan 8, 2022):

Its working absolutely fine. You are not using LinuxGSM as indeed and trying to run something that you are not meant to run.
Think of it this way. You wouldn't run a windows .dll file directly you would use the .exe instead. This is basically what you are trying to do here.

<!-- gh-comment-id:1008071901 --> @dgibbs64 commented on GitHub (Jan 8, 2022): Its working absolutely fine. You are not using LinuxGSM as indeed and trying to run something that you are not meant to run. Think of it this way. You wouldn't run a windows .dll file directly you would use the .exe instead. This is basically what you are trying to do here.
Author
Owner

@github-actions[bot] commented on GitHub (Jan 9, 2023):

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

<!-- gh-comment-id:1374965499 --> @github-actions[bot] commented on GitHub (Jan 9, 2023): This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Sign in to join this conversation.
No labels
Atomic
Epic
cannot reproduce
command: backup
command: console
command: debug
command: details
command: fast-dl
command: install
command: mods
command: monitor
command: post-details
command: restart
command: send
command: start
command: stop
command: update
command: update-lgsm
command: validate
command: wipe
distro: AlmaLinux
distro: Arch Linux
distro: CentOS
distro: Debian
distro: Fedora
distro: RedHat
distro: Rocky Linux
distro: Ubuntu
distro: openSUSE
engine: goldsrc
engine: source
game: 7 Days to Die
game: ARMA 3
game: Ark: Survival Evolved
game: Assetto Corsa
game: Avorion
game: BATTALION: Legacy
game: Barotrauma
game: Battalion 1944
game: Battlefield 1942
game: Black Mesa: Deathmatch
game: Blade Symphony
game: Call of Duty 2
game: Call of Duty 4
game: Call of Duty: United Offensive
game: Counter-Strike 1.6
game: Counter-Strike 2
game: Counter-Strike: Global Offensive
game: Counter-Strike: Source
game: Day of Infamy
game: Dayz
game: Death Match Classic
game: Don't Starve Together
game: ET: Legacy
game: Eco
game: Factorio
game: Factorio
game: Garry's Mod
game: Half-Life
game: Hurtword
game: Insurgecy
game: Insurgecy
game: Insurgency: Sandstorm
game: Just Cause 3
game: Killing Floor
game: Killing Floor 2
game: Left 4 Dead 2
game: Minecraft
game: Minecraft Bedrock
game: Mordhau
game: Multi Theft Auto
game: Mumble
game: Natural Selection 2
game: No More Room in Hell
game: Pavlov VR
game: Post Scriptum
game: Project Zomboid
game: Quake 3
game: QuakeWorld
game: Red Orchestra: Ostfront 41-45
game: Return to Castle Wolfenstein
game: Rising World
game: Rust
game: San Andreas Multiplayer
game: Satisfactory
game: Soldat
game: Soldier of Fortune 2
game: Squad
game: Squad 44
game: Starbound
game: Stationeers
game: Sven Co-op
game: Team Fortress 2
game: Teamspeak 3
game: Teeworlds
game: Terraria
game: The Front
game: Unreal Tournament 2004
game: Unreal Tournament 3
game: Unreal Tournament 99
game: Unturned
game: Valheim
game: Wurm Unlimited
game: Zombie Master Reborn
game: label missing
good first issue
help wanted
info: alerts
info: dependency
info: docker
info: docs
info: email
info: query
info: steamcmd
info: systemd
info: tmux
info: website
info: website
needs more info
outcome: duplicate
outcome: issue resolved
outcome: issue resolved
outcome: issue unresolved
outcome: pr accepted
outcome: pr rejected
outcome: unconfirmed
outcome: wontfix
outcome: wrong forum
potential-duplicate
priority
pull-request
type: bug
type: feature
type: feature
type: feature request
type: game server request
type: refactor
waiting response
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/LinuxGSM#2466
No description provided.