xash3d-installscript/install-xash3d.sh

285 lines
7.6 KiB
Bash
Raw Normal View History

2022-08-21 23:57:56 +02:00
#!/bin/bash
2022-08-21 15:06:00 +02:00
2022-08-23 11:48:26 +02:00
hlds_build=8684
2022-08-21 15:06:00 +02:00
amxmod_version=1.8.2
jk_botti_version=1.43
steamcmd_url="https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz"
hlds_url="https://github.com/DevilBoy-eXe/hlds/releases/download/$hlds_build/hlds_build_$hlds_build.zip"
metamod_url="https://github.com/mittorn/metamod-p/releases/download/1/metamod.so"
amxmod_url="http://www.amxmodx.org/release/amxmodx-$amxmod_version-base-linux.tar.gz"
jk_botti_url="http://koti.kapsi.fi/jukivili/web/jk_botti/jk_botti-$jk_botti_version-release.tar.xz"
2022-09-11 05:15:01 +02:00
for xashvar in BUILD_DIR INSTALL_DIR DS_PORT
do
xashvarname=XASH_$xashvar
if [ -z ${!xashvarname} ]
then
case ${!xashvarname} in
XASH_BUILD_DIR) XASH_BUILD_DIR=$(pwd)/build ;;
XASH_INSTALL_DIR) XASH_INSTALL_DIR=$(pwd)/xash3d ;;
XASH_DS_PORT) XASH_DS_PORT=27015 ;;
esac
fi
done
2022-08-21 15:06:00 +02:00
2022-08-26 01:14:27 +02:00
showhelp() {
echo "Usage: ./$0 [server|client] [install|update] [0.19|0.20]"
2022-08-23 12:19:44 +02:00
echo ""
2022-09-11 15:01:15 +02:00
echo "Description: Script to install an Xash3D engine full game client or dedicated server with game data from steamcmd"
2022-08-23 11:48:26 +02:00
echo "Server tested on Debian 11 ; Client tested on Ubuntu 20.04"
2022-09-11 15:01:15 +02:00
echo "Origin: https://git.la10cy.net/DeltaLima/xash3d-installscript"
2022-08-23 11:48:26 +02:00
echo ""
echo "Resources we are using:"
2022-09-11 15:01:15 +02:00
echo "$steamcmd_url"
echo "$hlds_url"
echo "0.20: https://github.com/FWGS/xash3d-fwgs"
echo "0.19: https://gitlab.com/tyabus/xash3d"
2022-08-23 11:48:26 +02:00
exit 1
2022-08-26 01:14:27 +02:00
}
case $3 in
"0.19")
XASH_GIT_URL="https://gitlab.com/tyabus/xash3d"
2022-08-26 01:14:27 +02:00
;;
"0.20")
XASH_GIT_URL="https://github.com/FWGS/xash3d-fwgs"
2022-08-26 01:14:27 +02:00
;;
2022-08-26 01:14:27 +02:00
*)
showhelp
2022-08-26 01:14:27 +02:00
;;
esac
XASH_INSTALL_VERSION=$3
2022-08-26 01:14:27 +02:00
case $2 in
"update")
;;
"install")
;;
*)
showhelp
;;
2022-08-23 11:50:45 +02:00
esac
XASH_INSTALL_MODE=$2
case $1 in
"client")
case $XASH_INSTALL_VERSION in
0.19)
CMAKE_OPTIONS='-DXASH_DOWNLOAD_DEPENDENCIES=yes -DXASH_STATIC=ON-DXASH_DLL_LOADER=ON -DXASH_VGUI=ON -DMAINUI_USE_STB=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_FLAGS="-m32" -DCMAKE_CXX_FLAGS="-m32"'
;;
0.20)
PACKAGES="git curl build-essential gcc-multilib g++-multilib python python2 libsdl2-dev:i386 libfontconfig-dev:i386 libfreetype6-dev:i386"
WAF_OPTIONS="--enable-utils --enable-stb"
;;
esac
;;
"server")
case $XASH_INSTALL_VERSION in
0.19)
CMAKE_OPTIONS='-DXASH_DEDICATED=ON -DCMAKE_C_FLAGS="-m32" -DCMAKE_CXX_FLAGS="-m32"'
;;
0.20)
PACKAGES="build-essential ca-certificates cmake curl git gnupg2 g++-multilib lib32gcc1-s1 libstdc++6:i386 python unzip xz-utils zip"
WAF_OPTIONS="-d"
;;
esac
;;
*)
showhelp
;;
esac
XASH_INSTALL_TYPE=$1
export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig
2022-08-21 23:35:06 +02:00
2022-08-23 11:59:12 +02:00
echo "= Creating directories ="
XASH_GIT_DIR="$(echo ${XASH_GIT_URL} | cut -d / -f5)"
test -d $XASH_INSTALL_DIR || mkdir -p $XASH_INSTALL_DIR
2022-08-21 15:06:00 +02:00
if [ "$XASH_INSTALL_MODE" == "install" ]
2022-08-26 01:14:27 +02:00
then
echo "= Performing apt install ="
sudo dpkg --add-architecture i386
sudo apt update
sudo apt-get install -y --no-install-recommends $PACKAGES
fi
2022-08-21 15:28:03 +02:00
2022-08-23 11:59:12 +02:00
echo "= Compiling xash3d-fwgs ="
2022-08-21 15:28:03 +02:00
## compile xash3ds
# go to build directory
cd $XASH_BUILD_DIR
case $XASH_INSTALL_MODE in
2022-08-26 01:14:27 +02:00
"install")
git clone --recursive $XASH_GIT_URL
mkdir -p ${XASH_GIT_DIR}/bin/
cd ${XASH_GIT_DIR}/bin
2022-08-26 01:14:27 +02:00
;;
"update")
cd ${XASH_GIT_DIR}
case $XASH_INSTALL_VERSION in
0.19)
cd bin
cmake --cmake-clean-cache ../
cd ../
rm -Rf bin/*
git pull
cd bin
;;
0.20)
./waf clean
rm bin/*
git pull
;;
esac
2022-08-26 01:14:27 +02:00
;;
*)
exit 1
;;
esac
2022-09-03 22:01:36 +02:00
## oldstuff ##
## old if you use deprecated xash3d 0.19.3
## cmake -DXASH_DEDICATED=ON -DCMAKE_C_FLAGS="-m32" -DCMAKE_CXX_FLAGS="-m32" ../
## make
2022-09-03 22:01:36 +02:00
## oldstuff ##
## build
case $XASH_INSTALL_VERSION in
0.19)
cmake $CMAKE_OPTIONS ../
make -j2 #VERBOSE=1
;;
0.20)
./waf configure -T release $WAF_OPTIONS
./waf -p build
./waf install --destdir=bin/
;;
esac
2022-08-21 23:22:25 +02:00
2022-08-21 15:06:00 +02:00
## here we fetch half-life from steam server
if [ "$XASH_INSTALL_MODE" == "install" ]
2022-08-26 01:14:27 +02:00
then
mkdir -p $XASH_BUILD_DIR/steam
cd $XASH_BUILD_DIR/steam
2022-08-26 01:14:27 +02:00
## an steamcmd automation
echo "login anonymous
force_install_dir $XASH_INSTALL_DIR
2022-08-21 15:06:00 +02:00
app_set_config 90 mod valve
app_update 90
app_update 90
app_update 90 validate
app_update 90 validate
quit" > $XASH_BUILD_DIR/steam/hlds.install
2022-08-21 15:06:00 +02:00
2022-08-26 01:14:27 +02:00
echo "= fetching hlds with steamcmd ="
## fetch steamcmd
curl -L "$steamcmd_url" | tar xzvf -
## run half-life download from steam server with steamcmd
## If grep find Error then fetch the hlds zip from github
echo "= This can take a while depending ony your connection ="
2022-09-11 05:51:25 +02:00
if ./steamcmd.sh +runscript hlds.install | grep Error
2022-08-26 01:14:27 +02:00
then
echo "= !! There was an error fetching hlds with steamcmd. Fetching it from github !! ="
echo $hlds_url
## this is just another source you can use instead of steamcmd.
curl -LJO "$hlds_url"
unzip "hlds_build_$hlds_build.zip" -d "hlds_build_$hlds_build"
cp -R "hlds_build_$hlds_build/hlds_build_$hlds_build"/* $XASH_INSTALL_DIR
2022-08-26 01:14:27 +02:00
fi
2022-08-23 11:48:26 +02:00
fi
## copy xash3d binaries to result
2022-08-21 23:22:25 +02:00
## place Xash3D binaries in result and overwrite all
echo "= copy xash3d binaries to $XASH_INSTALL_DIR"
case $XASH_INSTALL_VERSION in
0.19)
cd $XASH_BUILD_DIR/$XASH_GIT_DIR/bin
case $XASH_INSTALL_TYPE in
server)
cp -R engine/xash3d $XASH_INSTALL_DIR/xash
;;
client)
cp -R engine/xash3d mainui/libxashmenu.so vgui_support/libvgui_support.so vgui_support/vgui.so $XASH_INSTALL_DIR
;;
esac
;;
0.20)
cp -R $XASH_BUILD_DIR/$XASH_GIT_DIR/bin/* $XASH_INSTALL_DIR
;;
esac
2022-08-21 15:06:00 +02:00
2022-09-03 22:01:36 +02:00
2022-08-22 01:32:13 +02:00
# it seems that the build actually (21.08.2022) is buggy and does not exec server.cfg by its own
2022-09-11 05:41:22 +02:00
if [ "$XASH_INSTALL_MODE" == "install" ]
2022-08-23 11:59:12 +02:00
then
2022-09-11 05:41:22 +02:00
case $XASH_INSTALL_TYPE in
server)
echo "= Creating start.sh script for dedicated server in $XASH_INSTALL_DIR ="
2022-09-11 05:41:22 +02:00
case $XASH_INSTALL_VERSION in
0.19)
2022-09-11 05:51:25 +02:00
lol="+port"
2022-09-11 05:41:22 +02:00
;;
0.20)
2022-09-11 05:51:25 +02:00
lol="-port"
2022-09-11 05:41:22 +02:00
;;
esac
2022-09-11 06:00:39 +02:00
echo "#!/bin/bash
screen -d -m -S xash_${XASH_INSTALL_VERSION}_${XASH_DS_PORT} ./xash +ip 0.0.0.0 ${lol} ${XASH_DS_PORT} -pingboost 1 -timeout 3 +map boot_camp +exec server.cfg
echo screenname xash_${XASH_INSTALL_VERSION}_${XASH_DS_PORT}" > $XASH_INSTALL_DIR/start.sh
2022-09-11 05:51:25 +02:00
chmod +x $XASH_INSTALL_DIR/start.sh
2022-09-11 06:08:56 +02:00
echo "After=network.target
[Service]
User=$(whoami)
WorkingDirectory=${XASH_INSTALL_DIR}
2022-09-11 06:08:56 +02:00
Type=oneshot
#StandardOutput=journal
ExecStart=${XASH_INSTALL_DIR}/start.sh
2022-09-11 06:08:56 +02:00
ExecStop=/bin/kill -9 \$MAINPID
[Install]
WantedBy=multi-user.target" > $XASH_INSTALL_DIR/xashds_${XASH_INSTALL_VERSION}_${XASH_DS_PORT}.service
2022-09-11 06:08:56 +02:00
touch $XASH_INSTALL_DIR/valve/listip.cfg
touch $XASH_INSTALL_DIR/valve/banned.cfg
2022-09-11 05:41:22 +02:00
echo "= If you need an example config for a public server, have a look into https://github.com/FWGS/xashds-docker/tree/master/valve ="
2022-09-11 05:12:04 +02:00
;;
2022-09-11 05:41:22 +02:00
client)
echo "[Desktop Entry]
Name=Xash3d ${XASH_INSTALL_VERSION}
GenericName=Half-Life
Comment=OpenSource Half-Life Engine v${XASH_INSTALL_VERSION}
Exec=${XASH_INSTALL_DIR}/xash3d
2022-09-11 05:41:22 +02:00
Terminal=false
Type=Application
StartupNotify=false
Categories=Game;
X-Desktop-File-Install-Version=0.24" > $XASH_INSTALL_DIR/Xash3D_${XASH_INSTALL_VERSION}.desktop
2022-09-11 05:12:04 +02:00
;;
esac
2022-08-23 11:59:12 +02:00
fi
echo "= DONE! If everything went well an no errors occured you can just run your game/server from $XASH_INSTALL_DIR ="
2022-08-26 01:14:27 +02:00
echo "= starting server: ./start.sh ; starting game client ./xash3d ="