• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Server Linux Workshop Collection Helper

®omano

Grizzled Veteran
May 14, 2009
4,202
222
France
www.hellsoldiers.tk
The other day I needed to make some scripts to help a friend gather all the workshop items IDs from a collection he made on Steam Workshop in order to add the 70 maps from the collection to his server.

If you do that manually for such a collection it would take many many time, maybe a few hours. With some googling and a few tests later, I came up with two scripts to make the process painless.


I / Generate Collection

First script will download the collection infos, and create a text file from it with what you need to add to your server KFEngine.ini

Simply modify the Workshop Collection ID at line 7, to match yours, and then execute it from terminal to generate the kfengine.txt file

generateCollectionV3.sh

Code:
#!/bin/bash
echo > kfengine.txt
echo "Please see wiki to setup workshop for server http://wiki.tripwireinteractive.com/index.php?title=Dedicated_Server_(Killing_Floor_2)#Setting_Up_Steam_Workshop_For_Servers" >> kfengine.txt
echo >> kfengine.txt
echo >> kfengine.txt
echo "[OnlineSubsystemSteamworks.KFWorkshopSteamworks]" >> kfengine.txt
curl -s --data "collectioncount=1&publishedfileids[0]=WORKSHOP_COLLECTION_ID_HERE" https://api.steampowered.com/ISteamRemoteStorage/GetCollectionDetails/v1/ \
| jq '.response.collectiondetails[] | .children[] | .publishedfileid' \
| sed 's/^/ServerSubscribedWorkshopItems=/' | tr -d "\"" >> kfengine.txt

The generated kfengine.txt file looks like that:

Please see wiki to setup workshop for server http://wiki.tripwireinteractive.com/...op_For_Servers


[OnlineSubsystemSteamworks.KFWorkshopSteamworks]
ServerSubscribedWorkshopItems=733191110
ServerSubscribedWorkshopItems=820046643
ServerSubscribedWorkshopItems=643269874
ServerSubscribedWorkshopItems=818212145
ServerSubscribedWorkshopItems=889608490
ServerSubscribedWorkshopItems=889615074
ServerSubscribedWorkshopItems=890205021
ServerSubscribedWorkshopItems=889625734
....

Obviously do not copy the line telling you to read the wiki, but read the wiki and copy/paste the needed part to your server KFEngine.ini after you know how workshop for server works.


II / Write Maps Configs

The second one is a script you'll use after all workshop items are downloaded (marked as 'item state 4' in the server console), to search for maps in your KFGame/Cache/ folder, and look for their configuration in the server KFGame.ini file, if the configuration is not found, it will create it.

It will not remove old configurations from maps you removed from your server configs so you still need to think about that when removing a map and manually clean files and configs.

To use it, simply modify the two lines pointing to your server path (/path/to/KF2_server) for the Cache folder and to your server KFGame.ini file, then stop server and execute it from terminal:


writeMapsConfigs.sh

Code:
#!/bin/bash
for maps in $(find /path/to/KF2_server/KFGame/Cache -maxdepth 10 -type f -name "*.kfm"); do
    MAPNAME=$(echo ${maps##*/} | cut -f 1 -d '.')
    LINE="\[$MAPNAME KFMapSummary\]"
    KFGAME="/path/to/KF2_server/KFGame/Config/LinuxServer-KFGame.ini"
    if grep -q "$LINE" "$KFGAME"
    then
        echo CONFIG FOR $MAPNAME OK
    else
        echo CONFIG FOR $MAPNAME WILL BE ADDED TO $KFGAME
        echo  >> "$KFGAME"
        echo "[$MAPNAME KFMapSummary]" >> "$KFGAME"
        echo "MapName=$MAPNAME" >> "$KFGAME"
    fi
done

These two script can be placed where you want it doesn't matter. I'm not a coder so there might be serious bugs, or not :D For sure if you execute them as the same user that owns the files, and the files exist, everything should be alright ;)


Here is a download link for V3: www.dropbox.com/s/m...elper.zip?dl=1


I used part of code from GitHub user shadow-absorber from this page https://github.com/GameServerManager...SM/issues/1623 so credit to him for first script.
 
Last edited: