Tool Workshop Mods to Named .paks Shell Script

Discussion in 'Starbound Modding' started by Darexon, Feb 16, 2017.

  1. Darexon

    Darexon Void-Bound Voyager

    Hello, I've created a shell script to easily make workshop mods installable manually so I could put all my workshop mods on my server. I decided to share it because someone else may find it useful.

    To use this simply make sure the sbworkshop and assetpacker variables are correct for your system and run it. All mods will be in your Starbound workshop folder named appropriately and any mods that weren't packed will be packed. To install them manually just install them like any other mod by moving the .paks to your Starbound mods folder.

    For the first run this script will get mod names from IDs by checking the Steam Workshop. This can take a while depending on your number of mods and internet connection. After the first run all current IDs will be stored into a text file in the same directory as the script for quick access for the next runs. The attached zip already has a mod ID list for about 850 mods. If you have any mods not on the list they will be added to the list after running the script.

    If you are running this script more than once make sure you clear out your Starbound workshop folder of any .paks created by this script.

    This script will work on Mac OS and Linux. If you are running it on Mac OS change the sbworkshop and assetpacker variables to wherever they are located on your system.

    You may be able to get this working on Windows through Cygwin or Bash for Windows if you change the sbworkshop and assetpacker variables.

    Code:
    #!/bin/sh
    
    sbworkshop=~/.local/share/Steam/steamapps/workshop/content/211820
    assetpacker=$sbworkshop/../../../common/Starbound/linux/asset_packer
    scriptdir=$(dirname $0)
    
    find $sbworkshop/**/* -maxdepth 0 -type d | while read file
    do
    $assetpacker "$file" "$file.pak"
    done
    
    find $sbworkshop/**/ -maxdepth 1 -type f -name '*.pak' | while read file
    do
      dirname=$(dirname "$file")
      cp -v "$file" "${dirname}.pak"
    done
    
    for i in $(basename -as .pak $sbworkshop/*.pak)
    do
      modid=$(grep $i "$scriptdir/idlist.txt")
      if [ $? -eq 0  ]
      then
        modname=$(echo $modid | sed "s/$i://")
      else
        modname=$(curl -s https://steamcommunity.com/sharedfiles/filedetails/?id=$i | grep "<title>Steam Workshop :: " | sed -e "s/<[^>]*>//g" -e "s/Steam\sWorkshop\s::\s//" -e "s/ //g" -e "s:/::g" -e "s/://g" -e "s/&amp;/and/g" -e "s/\./_/g" -e "s/\r$//")
        echo "$i:$modname" >> "$scriptdir/idlist.txt"
      fi
      mv -v $sbworkshop/$i.pak $sbworkshop/$modname.pak
    done
    sort "$scriptdir/idlist.txt" -o "$scriptdir/idlist.txt"
    
     

    Attached Files:

    Last edited: Feb 17, 2017
  2. cpeosphoros

    cpeosphoros Orbital Explorer

    Just dropping a thank you note here. Saved me a lot of work. Thanks.
     
  3. PistolRcks

    PistolRcks Void-Bound Voyager

    Huh. I completely missed this as I was making my own Starbound workshop mod loader. I like how you add the names of the mods from their actual Steam Workshop pages. I personally just made the script copy them over and then rename the .pak file to wsmod-{ID}.tmp.pak (which would then be deleted once Starbound was closed). I like to see how different coders do things in their own ways. Nice, though!
     

Share This Page