Automating CS2KZ server map updates
New KZ maps come out constantly, and updating map lists by hand gets old quickly. This guide sets up two small Bash scripts and a cron job that check the CS2KZ Global API every morning, pull newly approved maps into RockTheVote and your Admin Menu, and restart the server only when new maps are actually found.
Requirements
This setup assumes your server already runs the following stack:
- LinuxGSM (
cs2server) for server management - CS2-SimpleAdmin for the admin menu
- CounterStrikeSharp
- CS2KZ Metamod
- RockTheVote plugin
- jq installed on the host to parse JSON
Install jq if you do not already have it:
sudo apt-get install jq -y
Switch to the server user
Run everything as your dedicated non-root server user (typically cs2server) so file ownership and permissions stay clean:
sudo su - cs2server
Create the scripts directory
Make a folder in the home directory to keep the scripts and logs together:
mkdir -p ~/scripts
Create the admin menu sync script
Whenever new official maps are fetched from cs2kz.org, this helper merges them into CS2-SimpleAdmin.json without wiping out any custom maps you added manually for admins. That way, admin-only or non-WR maps stay in the Admin Menu without showing up in the public RockTheVote list.
Create the script:
nano ~/scripts/sync_maps.sh
Paste the following code:
#!/bin/bash
# CS2 Admin Sync by SpawnTerror 2026
# Paths to your config files
RTV_FILE="/home/cs2server/serverfiles/game/csgo/addons/counterstrikesharp/plugins/RockTheVote/maplist.txt"
ADMIN_FILE="/home/cs2server/serverfiles/game/csgo/addons/counterstrikesharp/configs/plugins/CS2-SimpleAdmin/CS2-SimpleAdmin.json"
# Logic: Merge new maps into Admin Config safely
RTV_JSON=$(grep -vE "^\s*//|^\s*$" "$RTV_FILE" | jq -R -n 'reduce inputs as $line ({}; ($line|split(":")) as $p | .[$p[0] | gsub("^\\s+|\\s+$";"")] = ($p[1] | gsub("^\\s+|\\s+$";"") | tonumber))')
jq --argjson newmaps "$RTV_JSON" '.WorkshopMaps = ($newmaps + .WorkshopMaps)' <(sed 's|//.*||g' "$ADMIN_FILE") > "${ADMIN_FILE}.tmp" && mv "${ADMIN_FILE}.tmp" "$ADMIN_FILE"
Save and exit (Ctrl+O, Enter, then Ctrl+X).
Create the map updater script
This main script polls the CS2KZ API for approved maps, compares the result against your current maplist.txt, and only updates files and restarts the server when new maps appear.
Create the script:
nano ~/scripts/update_rtv.sh
Paste the following code:
#!/bin/bash
# CS2 RockTheVote Sync by SpawnTerror 2026
# --- Configuration ---
API_URL="https://api.cs2kz.org/maps?state=approved"
RTV_FILE="/home/cs2server/serverfiles/game/csgo/addons/counterstrikesharp/plugins/RockTheVote/maplist.txt"
SYNC_SCRIPT="/home/cs2server/scripts/sync_maps.sh"
LOG_FILE="/home/cs2server/scripts/map_updates.log"
SERVER_CMD="/home/cs2server/cs2server"
HEADER="//Put your map list here, just official maps for WR"
# --- Temp Files ---
TEMP_NEW="/tmp/kz_new.tmp"
TEMP_OLD="/tmp/kz_old.tmp"
# --- 1. Fetch API Data ---
# Downloads the list and formats it as "mapname:workshopid"
curl -s "$API_URL" | jq -r '.values[] | "\(.name):\(.workshop_id)"' > "$TEMP_NEW"
# Stop if API fails (file is empty)
if [ ! -s "$TEMP_NEW" ]; then exit 1; fi
# --- 2. Compare with Current List ---
grep -vE "^\s*//|^\s*$" "$RTV_FILE" > "$TEMP_OLD" 2> /dev/null || touch "$TEMP_OLD"
NEW_MAPS=$(grep -Fxv -f "$TEMP_OLD" "$TEMP_NEW")
# --- 3. Update if New Maps Found ---
if [ -n "$NEW_MAPS" ]; then
# A. Log changes
echo "========================================" >> "$LOG_FILE"
echo "Update: $(date)" >> "$LOG_FILE"
echo "New maps detected: $NEW_MAPS" >> "$LOG_FILE"
# B. Overwrite Maplist
echo "$HEADER" > "$RTV_FILE"
cat "$TEMP_NEW" >> "$RTV_FILE"
# C. Sync Admin Menu
if [ -f "$SYNC_SCRIPT" ]; then bash "$SYNC_SCRIPT"; fi
# D. Restart Server to Load Maps
echo "Restarting server to apply changes..." >> "$LOG_FILE"
$SERVER_CMD restart >> "$LOG_FILE"
else
echo "No new maps found. No restart needed."
fi
# Cleanup
rm "$TEMP_NEW" "$TEMP_OLD"
Save and exit (Ctrl+O, Enter, then Ctrl+X).
Make the scripts executable
Mark both scripts as executable:
chmod +x ~/scripts/*.sh
Schedule the daily cron job
Open the user's crontab:
crontab -e
Add the following line at the bottom (alongside your existing LinuxGSM ./cs2server monitor entries) to run the check every day at 04:30:
30 4 * * * /home/cs2server/scripts/update_rtv.sh >> /home/cs2server/scripts/update.log 2>&1
Save and exit.
Check the update log
Your server will now check for newly approved maps automatically every morning and restart only when needed. To review past map updates at any time:
cat ~/scripts/map_updates.log