Skip to content

Commit

Permalink
README, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
kimzuni committed Apr 6, 2024
1 parent 28cff53 commit 89bc806
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on: # yamllint disable-line rule:truthy
push:
branches:
- main
- dev

jobs:
container-scanning:
Expand Down
17 changes: 17 additions & 0 deletions docs/en/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,23 @@ docker run -d \
kimzuni/longvinter-docker-server:latest
```

### Update the Container

If you are running the server first, please stop:

```bash
docker stop longvinter-server
docker rm longvinter-server
```

Next, remove the installed image:

```bash
docker rmi $(docker images | grep -E ^"(ghcr.io\/)?kimzuni/longvinter-docker-server" | awk '{print $3}')
```

Finally, run the [Docker Compose](#docker-compose) or [Docker Run](#docker-run) with the `latest` tag.

### Running without root

This is only for advanced users.
Expand Down
17 changes: 17 additions & 0 deletions docs/kr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,23 @@ docker run -d \
kimzuni/longvinter-docker-server:latest
```

### 컨테이너 업데이트 방법

먼저 서버를 실행 중이라면 아래 명령어로 서버를 중지해 주세요.

```bash
docker stop longvinter-server
docker rm longvinter-server
```

그리고 아래 명령어를 실행햐여 설치된 이미지를 제거합니다.

```bash
docker rmi $(docker images | grep -E ^"(ghcr.io\/)?kimzuni/longvinter-docker-server" | awk '{print $3}')
```

마지막으로 `latest` 태그를 이용하여 [Docker Compose](#docker-compose) 또는 [Docker Run](#docker-run)을 실행하면 최신 버전의 컨테이너를 사용할 수 있습니다.

### root 없이 실행하기

고급 유저를 위한 기능입니다.
Expand Down
58 changes: 52 additions & 6 deletions scripts/helper_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ container_version_check() {

if [ "${current_version}" != "${latest_version}" ]; then
LogWarn "New version available: ${latest_version}"
LogWarn "Learn how to update the container: https://github.com/kimzuni/longvinter-docker-server#update-the-container"
LogWarn "Learn how to update the container:"
LogWarn " - English : https://github.com/kimzuni/longvinter-docker-server/tree/main/docs/en/#update-the-container"
LogWarn " - 한국어 : https://github.com/kimzuni/longvinter-docker-server/tree/main/docs/kr/#컨테이너-업데이트-방법"
else
LogSuccess "The container is up to date!"

fi
}

Expand All @@ -161,15 +162,60 @@ get_latest_version() {

# Use it when you have to wait for it to be saved automatically because it does not support RCON.
wait_save() {
local path log
local path old_path new_path
local num old_num adminpanel

old_path=$(last_savefile)
old_num=$(wc -l 2> /dev/null < "$old_path")
while path=$(inotifywait -q -e modify -r "$SERVER_LOG_DIR" | sed "s/ MODIFY //g"); do
log=$(tail -1 "$path")
if [[ "$log" =~ ^\[[a-zA-Z]+\ [0-9\ ,:]+\ [AP]M\]\ Game\ saved!$ ]]; then
if [[ "${path##*/}" =~ ^AdminPanelServer-.*\.log$ ]]
then adminpanel=true
else adminpanel=false
fi

if [ -n "$old_path" ] && num=$(check_save "$old_path" "$old_num"); then
break
elif [ "$adminpanel" = false ]; then
path="$old_path"
elif [ "$old_path" != "$path" ] && num=$(check_save "$path" 0); then
break
fi

new_path=$(last_savefile)
if [ "$path" != "$new_path" ] && num=$(check_save "$new_path" 0); then
break
fi

old_path="$new_path"
old_num="${num:-$old_num}"
done
}

# Outputs the latest log file among log files where saves are recorded
last_savefile() {
# shellcheck disable=SC2012
ls -t "$SERVER_LOG_DIR"/AdminPanelServer-*.log 2> /dev/null | head -1
}

# Check if there is any saved history in the log file
# And Output the last line number of that file
# Returns 0 if saved
# Returns 1 if unsaved
check_save() {
local path num old_num
path="$1"
old_num="$2"
num=$(wc -l < "$path")

echo "$num"

logs=$(tail -$((num - old_num)) "$path")
if echo "$logs" | grep -i ^"\[[a-z]\+ [0-9 ,:]\+ [AP]M\] Game saved!"$ > /dev/null 2>&1; then
return 0
fi
return 1
}

Server_Info() {
local HTTP URL="$CFG_COMMUNITY_WEBSITE"
if ! [[ "$URL" =~ ^https?:// ]] && [ -n "$URL" ]; then
Expand All @@ -191,4 +237,4 @@ Server_Info() {
echo "Max Tent: $CFG_MAX_TENTS"
echo "Coop Play: $CFG_COOP_PLAY"
echo "Coop Spawn: $CFG_COOP_SPAWN"
}
}

0 comments on commit 89bc806

Please sign in to comment.