Repository navigation
fix(update-lgsm): build updated game script in tmpdir and restore backup on failure - #5118
Merged
Merged
Conversation
…kup on failure
sed -i writes its temporary file next to the target, so editing the game
script in place needed write access to rootdir itself. Without it the
copy from linuxgsm.sh succeeded but the substitutions failed, leaving the
script with the "core" placeholders ("unknown game server"). Only the last
sed call was checked, and the backup taken just before was never restored.
The script is now assembled in tmpdir with a single sed call and copied
over the existing file, which only needs write access to the file. If
that copy fails, the backup is restored. The backup path is computed once
so the logged location matches the file actually written.
Fixes #3060
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
update-lgsmcopiedlinuxgsm.shover the game script and then ran six separatesed -icalls on it inrootdir.sed -icreates its temporary file in the same directory as the target, so without write access torootdiritself the copy succeeded but every substitution failed. The game script was left with the"core"placeholders and reportedunknown game server. Only the lastsedexit code was checked, and the backup taken just before was never restored.Changes:
tmpdirwith a singlesed -i -e ...call, and that result is checked.rootdir.datewas called three times).Fixes #3060
Affected servers: all
Type of change
Testing
shellcheck -xon the module.pmcserverin a throwaway container.rootdirset toroot:root 755with all contents owned bylinuxgsm(the setup from the issue), and a line appended to the game script soupdate-lgsmalways has a change to apply. RanLGSM_GITHUBBRANCH=<branch> ./pmcserver update-lgsmondevelopand on this branch (after a first run to fetch that branch's modules), then./pmcserver details.develop: all sixsedcalls failed withcouldn't open temporary file <rootdir>/sedXXXXXX: Permission denied, the script was left withshortname="core", anddetailsreportedUnknown game server. The backup was not restored.copying pmcserver ... OK, the script has the correctshortname/gameservername,detailsworks, and no temporary files are left inrootdirortmpdir.gameservermanagers/linuxgsm:ubuntu-26.04container on a test server.Risk and rollback
lgsm/backup/script/before any change.Breaking changes
Documentation
Checklist
PR will not be merged until all steps are complete.
Thank you for your Pull Request!