Skip to content
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

Fix prefire plugin #175

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.env copy
/custom_files/*
cs2
tmp
10 changes: 9 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ ENV SRC_DIR="/home/cs2-modded-server"

WORKDIR $SRC_DIR

COPY . $SRC_DIR
COPY custom_files $SRC_DIR/custom_files

COPY install_docker.sh \
run.sh \
start.sh \
stop.sh \
$SRC_DIR

COPY game/csgo $SRC_DIR/game/csgo

USER steam

Expand Down
45 changes: 45 additions & 0 deletions scripts/check-updates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,50 @@ fetch_last_updated() {
fi
}

download_and_extract_latest_release() {
local repo_url="$1"
if [[ $repo_url != *"github.com"* ]]; then
echo "Unsupported URL: $repo_url"
return
fi

local repo_name=$(echo "$repo_url" | awk -F'github.com/' '{print $2}')
local latest_release_urls=$(curl -s "https://api.github.com/repos/${repo_name}/releases/latest" | grep "browser_download_url" | cut -d '"' -f 4)

if [ -z "$latest_release_urls" ]; then
echo "No releases found for $repo_name"
return 1
fi

rm -rf "./tmp/${repo_name}"
local temp_dir="./tmp/${repo_name}"
mkdir -p "${temp_dir}" || echo ""

for url in $latest_release_urls; do
local temp_file="./tmp/$(basename "$url")"
local temp_unzip_dir="$temp_dir"

if [[ "$temp_file" == *"windows"* ]]; then
temp_unzip_dir="$temp_unzip_dir/windows"
elif [[ "$temp_file" == *"linux"* ]]; then
temp_unzip_dir="$temp_unzip_dir/linux"
fi

if [ ! -f "$temp_file" ]; then
echo "Downloading latest release from $url..."
curl -L -o "$temp_file" "$url"
fi

echo "Extracting $temp_file..."
case "$temp_file" in
*.tar.gz) tar --overwrite -xzf "$temp_file" -C "$temp_unzip_dir" >/dev/null ;;
*.zip) unzip -o "$temp_file" -d "$temp_unzip_dir" >/dev/null ;;
*) echo "Unsupported file format: $temp_file" ;;
esac
done
echo "Latest release downloaded and extracted to $temp_dir"
}

main() {
# Call extract_mods and read output into an array
IFS=$'\n' read -rd '' -a modList < <(extract_mods)
Expand All @@ -105,6 +149,7 @@ main() {
echo -e "\033[0;32m✅ ${name} ${latest_release}\033[0m"
else
echo -e "\033[0;33m📦 ${name} update available ${version} > ${latest_release} ${url}\033[0m"
download_and_extract_latest_release "$url"
fi
elif [ -n "$last_updated" ]; then
echo -e "\033[1;30m🔍 ${name} ${version} - Last updated ${last_updated} ${url}\033[0m"
Expand Down