BSPZIP bash script for linux users

  • If you're asking a question make sure to set the thread type to be a question!

Gezebu MindBlue

L1: Registered
Oct 12, 2016
29
1
I'm not sure if this is the right place to share this, maybe a moderator wants to move it at another place.

I'm using custom textures, and bspzip to embed them in my maps. I created a simple script that facilitates this task, to embed them and upload the map to my server, in an automated way. Maybe it's useful to others too ...

Code:
#!/bin/bash

# /usr/bin/bspzip

# This script embed your custom textures (or any file who bspzip can add) in your bsp, and upload the new bsp at your server.
# You need a sshd server configured for accept logins with keys.
# Of course, also need to edit the values of the variables with the routes of your system, and the ssh connection.
# All routes here are examples.

IFS='
'
# Route of bszip.exe
BSPZIP="/mnt/your_device_path/playonlinux/SteamLibrary/steamapps/common/Team Fortress 2/bin/bspzip.exe"

# Route at gameinfo.txt folder.
GAMEINFOROUTE="/mnt/your_device_path/playonlinux/SteamLibrary/steamapps/common/Team Fortress 2/tf"

# Where you save your bsp files in hammer. Keep the / at the end of the route.
BSPROUTE="/home/user/work/tf2/maps/"

# BSPNAME take the name what the map you are working. 
# You need tell this in the command line when invoke the script. 
# For example: if you save this script in /usr/bin/bspzip you write "bspzip yourmapname.bsp" in terminal.
# Do not touch.
BSPNAME=$1

# Route at your <file list>.txt file
# https://developer.valvesoftware.com/wiki/BSPZIP
ADDFILELIST="/home/user/work/tf2/maps/include_custom_textures.txt"

# Where you want save the new bsp file
SAVEPATH="/home/user/work/tf2/maps/bspziped"

# output
BSPOUTPUT=$SAVEPATH$BSPNAME 

# When you update the map on the server, without changing the map name, it is necessary to delete the old map downloaded for the game. 
# Otherwise you will receive an error message when entering the server: "Your map *** differs from the server's".
# Where TF2 Game save the maps downloaded.
TF2GAMEMAPSFOLDER="/mnt/your_device_path/Steam/steamapps/common/Team Fortress 2/tf/download/maps/"

# ssh variables #
SERVERIP="192.168.1.2"
SERVERPORT="22"
SERVERUSER="your_ssh_user"
# Where you host the bsp files in your server (tf/maps).
SERVERMAPSFOLDER="/absolute_path_of_your_tf2_server/tf2/tf/maps"

### Working ...

# Embed files
wine $BSPZIP -game $GAMEINFOROUTE -addlist $BSPROUTE$BSPNAME $ADDFILELIST $BSPOUTPUT; 

# If exist delete old bsp file in tf2 game maps folder
if [ -e $TF2GAMEMAPSFOLDER$BSPNAME ]; then
        rm $TF2GAMEMAPSFOLDER$BSPNAME 
fi

# Upload the new map to server
scp -P $SERVERPORT -i "~/.ssh/id_rsa" $BSPOUTPUT $SERVERUSER@$SERVERIP:$SERVERMAPSFOLDER;

echo "Done ..."
exit 0