Skip to content

fix(update-lgsm): incorrect wdir sometimes #4140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2023

Conversation

jusito
Copy link
Contributor

@jusito jusito commented Mar 13, 2023

Description

If lgsm updates itself it cds into functions directory but not back, this is in at least one case an issue.

Fixes #[issue] Discord LGSM cannot update itself, breaks when checking lgsm module
Got the same error some time ago as well: jusito/docker-ttt#9
image

In the "files changed" it looks weird, basically I just wrapped the cd into ( cd ".."; do somethin), this ensures that even if it exits somewhere in between it will cd back if outside of the block.

Example to trigger the issue and also the validation that the pr will fix it:

Check the log before and after "a server is already installed" for the first log is shows function directory.

#!/bin/bash

set -euo pipefail

function stop_after_update() {
	pid="$1"
	while ! grep -F 'Checking Dependencies' gmodserver.log; do
		sleep 1s
	done
	kill "$pid"
	while ps -p "$pid" -o pid= > /dev/null 2>&1; do
		sleep 1s
	done
	if [ -d "./functions/lgsm/" ]; then
		echo "Issue: found folder $(pwd)/functions/lgsm"
	else
		echo "Solved: no folder $(pwd)/functions/lgsm"
	fi
}

(
	cd "$(dirname "$0")"
	if [ -d bugreport ]; then
		echo "please remove folder \"$(pwd)/bugreport\""
		exit 1
	fi
	mkdir bugreport
	(
		cd bugreport
		wget -O linuxgsm.sh "https://github.com/raw/GameServerManagers/LinuxGSM/v23.1.0/linuxgsm.sh"
		chmod +x linuxgsm.sh
		(
			export LGSM_GITHUBUSER="GameServerManagers"
			export LGSM_GITHUBBRANCH="master"
			./linuxgsm.sh gmodserver
			sed -i 's/"v23.1.0"/"v21.5.1"/' ./gmodserver
			./gmodserver auto-install
		) | tee /dev/tty > gmodserver.log 2>&1 &
		stop_after_update "$!"
		mv gmodserver.log gmodserver.before.log

		rm -rf ../bugreport/lgsm

		(
			export LGSM_GITHUBUSER="jusito"
			export LGSM_GITHUBBRANCH="fix/update-lgsm"
			sed -i 's/"v23.1.0"/"v21.5.1"/' ./gmodserver
			./gmodserver auto-install
		) | tee /dev/tty > gmodserver.log 2>&1 &
		stop_after_update "$!"
		mv gmodserver.log gmodserver.after.log
	)
)

Type of change

  • Bug fix (a change which fixes an issue).
  • New feature (a change which adds functionality).
  • New Server (new server added).
  • Refactor (restructures existing code).
  • Comment update (typo, spelling, explanation, examples, etc).

Checklist

PR will not be merged until all steps are complete.

  • This pull request links to an issue.
  • This pull request uses the develop branch as its base.
  • This pull request subject follows the Conventional Commits standard.
  • This code follows the style guidelines of this project.
  • I have performed a self-review of my code.
  • I have checked that this code is commented where required.
  • I have provided a detailed enough description of this PR.
  • I have checked if documentation needs updating.

Documentation

If documentation does need updating either update it by creating a PR (preferred) or request a documentation update.

Thank you for your Pull Request!

@dgibbs64 dgibbs64 added the type: bug Something isn't working label Mar 20, 2023
@dgibbs64 dgibbs64 added this to the v23.2.0 milestone Mar 20, 2023
@dgibbs64 dgibbs64 merged commit bc7e200 into GameServerManagers:develop Mar 27, 2023
Copy link
Contributor

github-actions bot commented Apr 1, 2024

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants