gist/freehlded-bootstrap.sh

378 lines
No EOL
9 KiB
Bash
Executable file

#!/bin/sh
# Quick rundown:
#
# This script bootstraps a FreeHL server complete
# with support for the following games:
# - Half-Life
# - Counter-Strike
# - Deathmatch Classic
# - Team Fortress
# - Half-Life: Opposing Force
# - Gunman Chronicles
# - Scientist Hunt (mod)
# - They Hunger (mod)
#
# You need to place the three files (unmodified) into
# the same directory as this script:
#
# hlserver4110.exe
# csv15full.exe (optional)
# opfor1108.tar.bz2 (optional)
# gunman_server.exe (optional)
# shunt12.exe (optional)
# TheyHunger3.exe (optional)
#
# Once you've done so, run this script and in the same
# directory the bootstrapping process will begin.
#
# You can run a server like this:
#
# ./fteqw-sv64 -halflife +sv_public 1 +set deathmatch 1 +set maxplayers 16 +map crossfire
#
# A mod server looks like this:
#
# ./fteqw-sv64 -halflife -game cstrike +sv_public 1 +set deathmatch 1 +set maxplayers 16 +map de_dust2
#
# You'll probably want to specify other parameters, such as mp_timelimit etc.
# but you should probably put those into a server.cfg into their respective game
# directories. The server will execute files named `server.cfg` if present.
#
# This script should work on other operting systems, you only need to
# replace the fteqw-sv64 binary with one for your target platform/arch.
# The game-logic is entirely platform independent.
#
# Happy hosting!
set -e
fix_case()
{
if [ "$1" = "-r" ]
then
recursive=1
shift
else
recursive=0
fi
for i in "$@"
do
new=`echo $i | tr "[:upper:]" "[:lower:]"`
if [ "$new" != "$i" ]
then
echo $i "->" $new >&2
mv "$i" "$new"
fi
if [ $recursive = 1 -a -d "$new" ]
then
fix_case -r "$new"/*
fi
done
}
check_pak()
{
if [ -f "$1" ]
then
printf "\t- %s\n" "$2"
fi
}
# dependencies: rewise
if [ ! -f ./rewise ]
then
# is this GNU?
if [ "$MAKEVER" = "GNU" ]
then
MAKETOOL="make"
else
# guess not, do we have gmake?
if [ -x "$(command -v gmake)" ]
then
MAKEVER=$(gmake --version | awk '{ print $1 }' | head -n 1)
if [ "$MAKEVER" = "GNU" ]
then
MAKETOOL="gmake"
else
echo "Please install GNU Make."
exit 2
fi
fi
fi
BINDIR="$(pwd)"
git clone https://vcs.vera-visions.com/eukara/REWise
cd REWise
# some distros do not have a `cc` symlink.
# some distros do not have `gcc`, they may only have `gcc10`
# or something else I cannot predict (some don't even have gcc!)
# if something breaks for you adjust this right here. good luck!
if [ -z $(command -v cc) ]
then
$MAKETOOL
else
$MAKETOOL CC=cc
fi
mv -v rewise "$BINDIR/rewise"
cd "$BINDIR"
fi
# get the FTE dedicated server binary set up
if [ -f ./fteqw-sv64 ]
then
rm ./fteqw-sv64
fi
wget "https://www.fteqw.org/dl/fteqw-sv_linux64.zip"
unzip "fteqw-sv_linux64.zip"
rm "fteqw-sv_linux64.zip"
rm readme.txt
# remove the old FreeHL packages if they exist
if [ -f ./valve/package_valve.pk3 ]
then
rm ./valve/package_valve.pk3
fi
if [ -f ./tfc/package_tfc.pk3 ]
then
rm ./tfc/package_tfc.pk3
fi
if [ -f ./dmc/package_dmc.pk3 ]
then
rm ./dmc/package_dmc.pk3
fi
# get the new ones
wget "https://www.frag-net.com/pkgs/package_valve.pk3" -P ./valve/
unzip -p ./valve/package_valve.pk3 progs.dat >valve/progs.dat
unzip -p ./valve/package_valve.pk3 csprogs.dat >valve/csprogs.dat
wget "https://www.frag-net.com/pkgs/package_tfc.pk3" -P ./tfc/
unzip -p ./tfc/package_tfc.pk3 progs.dat >tfc/progs.dat
unzip -p ./tfc/package_tfc.pk3 csprogs.dat >tfc/csprogs.dat
wget "https://www.frag-net.com/pkgs/package_dmc.pk3" -P ./dmc/
unzip -p ./dmc/package_dmc.pk3 progs.dat >dmc/progs.dat
unzip -p ./dmc/package_dmc.pk3 csprogs.dat >dmc/csprogs.dat
#wget "https://www.frag-net.com/pkgs/package_ricochet.pk3" -P ./ricochet/
#unzip -p ./ricochet/package_ricochet.pk3 progs.dat >ricochet/progs.dat
#unzip -p ./ricochet/package_ricochet.pk3 csprogs.dat >ricochet/csprogs.dat
# We need at least hlserver4110.exe
if [ ! -f ./hlserver4110.exe ]
then
printf "You require hlserver4110.exe! Place it in %s and run it again, or provide your own content otherwise! Then run this command again.\n", $(pwd)
exit 1
else
FOUND_HL=1
fi
# Check if we have Counter-Strike 1.5's installer
if [ -f ./csv15full.exe ]
then
FOUND_CS=1
else
FOUND_CS=0
fi
# Check if we have Opposing Force's dedicated server files
if [ -f ./opfor1108.tar.bz2 ]
then
FOUND_OPFOR=1
else
FOUND_OPFOR=0
fi
# Check if we have Gunman Chronicles's dedicated server files
if [ -f ./gunman_server.exe ]
then
FOUND_GUNMAN=1
else
FOUND_GUNMAN=0
fi
# Check if we have Scientist Hunt's installer files
if [ -f ./shunt12.exe ]
then
FOUND_SCIHUNT=1
else
FOUND_SCIHUNT=0
fi
# Check if we have They Hunger's installer files
if [ -f ./TheyHunger3.exe ]
then
FOUND_HUNGER=1
else
FOUND_HUNGER=0
fi
# extract the installer contents
if [ ! -f ./valve/halflife.wad ]
then
./rewise -x ./ ./hlserver4110.exe
cp -a ./MAINDIR/valve/. ./valve/
cp -a ./MAINDIR/dmc/. ./dmc/
cp -a ./MAINDIR/tfc/. ./tfc/
cp -a ./MAINDIR/ricochet/. ./ricochet/
rm -rf ./MAINDIR
rm -rf ./TEMP
rm ./UNINSTALL_PATH
fix_case -r ./valve/
fix_case -r ./dmc/
fix_case -r ./tfc/
fix_case -r ./ricochet/
fi
# if we have CS its installer detected, extract it
if [ "$FOUND_CS" = "1" ]
then
# don't bother extracting it, if contents exist
if [ ! -f ./cstrike/cstrike.wad ]
then
./rewise -x ./ ./csv15full.exe
cp -a ./MAINDIR/cstrike/. ./cstrike/
rm -rf ./MAINDIR
rm -rf ./TEMP
fix_case -r ./cstrike/
fi
fi
# if we have OP4 its installer detected, extract it
if [ "$FOUND_OPFOR" = "1" ]
then
# don't bother extracting it, if contents exist
if [ ! -f ./gearbox/opfor.wad ]
then
tar xjvf opfor1108.tar.bz2
fi
fi
# if we have Gunman's its installer detected, extract it
if [ "$FOUND_GUNMAN" = "1" ]
then
# don't bother extracting it, if contents exist
if [ ! -f ./rewolf/rewolf.wad ]
then
./rewise -x ./ ./gunman_server.exe
cp -a ./MAINDIR/rewolf/. ./rewolf/
rm -rf ./MAINDIR
rm -rf ./TEMP
fix_case -r ./rewolf/
fi
fi
# if we have Scientist Hunt's its installer detected, extract it
if [ "$FOUND_SCIHUNT" = "1" ]
then
# don't bother extracting it, if contents exist
if [ ! -f ./scihunt/hondo3.wad ]
then
unzip ./shunt12.exe -d ./
fix_case -r ./scihunt/
fi
fi
# if we have They Hunger's its installer detected, extract it
if [ "$FOUND_HUNGER" = "1" ]
then
# don't bother extracting it, if contents exist
if [ ! -f ./hunger/pak4.pak ]
then
unzip ./TheyHunger3.exe -d ./
mv ./Hunger ./hunger
fix_case -r ./hunger/
fi
fi
if [ -f ./cstrike/cstrike.wad ]
then
# remove the old FreeCS package
if [ -f ./cstrike/package_cstrike.pk3 ]
then
rm ./cstrike/package_cstrike.pk3
fi
# get the new FreeCS package
wget "https://www.frag-net.com/pkgs/package_cstrike.pk3" -P ./cstrike/
unzip -p ./cstrike/package_cstrike.pk3 progs.dat >cstrike/progs.dat
unzip -p ./cstrike/package_cstrike.pk3 csprogs.dat >cstrike/csprogs.dat
fi
if [ -f ./gearbox/opfor.wad ]
then
# remove the old FreeOP4 package
if [ -f ./gearbox/package_gearbox.pk3 ]
then
rm ./gearbox/package_gearbox.pk3
fi
# get the new FreeOP4 package
wget "https://www.frag-net.com/pkgs/package_gearbox.pk3" -P ./gearbox/
unzip -p ./gearbox/package_gearbox.pk3 progs.dat >gearbox/progs.dat
unzip -p ./gearbox/package_gearbox.pk3 csprogs.dat >gearbox/csprogs.dat
fi
if [ -f ./rewolf/rewolf.wad ]
then
# remove the old FreeGunman package
if [ -f ./rewolf/package_rewolf.pk3 ]
then
rm ./rewolf/package_rewolf.pk3
fi
# get the new FreeGunman package
wget "https://www.frag-net.com/pkgs/package_rewolf.pk3" -P ./rewolf/
unzip -p ./rewolf/package_rewolf.pk3 progs.dat >rewolf/progs.dat
unzip -p ./rewolf/package_rewolf.pk3 csprogs.dat >rewolf/csprogs.dat
fi
if [ -f ./scihunt/hondo3.wad ]
then
# remove the old FreeSciHunt package
if [ -f ./scihunt/package_scihunt.pk3 ]
then
rm ./scihunt/package_scihunt.pk3
fi
# get the new FreeSciHunt package
wget "https://www.frag-net.com/pkgs/package_scihunt.pk3" -P ./scihunt/
unzip -p ./scihunt/package_scihunt.pk3 progs.dat >scihunt/progs.dat
unzip -p ./scihunt/package_scihunt.pk3 csprogs.dat >scihunt/csprogs.dat
fi
if [ -f ./hunger/pak4.pak ]
then
# remove the old StillHungry package
if [ -f ./hunger/package_hunger.pk3 ]
then
rm ./hunger/package_hunger.pk3
fi
# get the new StillHungry package
wget "https://www.frag-net.com/pkgs/package_hunger.pk3" -P ./hunger/
unzip -p ./hunger/package_hunger.pk3 progs.dat >hunger/progs.dat
unzip -p ./hunger/package_hunger.pk3 csprogs.dat >hunger/csprogs.dat
fi
# Final evaluation
printf "Install/upgrade successful. Detected games that you can host games for:\n"
check_pak ./valve/package_valve.pk3 "Half-Life"
check_pak ./cstrike/package_cstrike.pk3 "Counter-Strike"
check_pak ./tfc/package_tfc.pk3 "Team Fortress Classic"
check_pak ./dmc/package_dmc.pk3 "Deathmatch Classic"
check_pak ./ricochet/package_ricochet.pk3 "Ricochet"
check_pak ./gearbox/package_gearbox.pk3 "Half-Life: Opposing Force"
check_pak ./rewolf/package_rewolf.pk3 "Gunman Chronicles"
check_pak ./scihunt/package_scihunt.pk3 "Scientist Hunt"
check_pak ./hunger/package_hunger.pk3 "They Hunger"