various changes - colored output
This commit is contained in:
parent
0a47c7bd30
commit
d1ad1eae6b
1 changed files with 121 additions and 32 deletions
|
@ -1,15 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
## these variables are from github.com/FWGS/xashds-docker, nice to have :)
|
|
||||||
hlds_build=8684
|
|
||||||
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"
|
|
||||||
|
|
||||||
## check if variables for installation are predefined otherwise set defaults
|
## check if variables for installation are predefined otherwise set defaults
|
||||||
for xashvar in BUILD_DIR INSTALL_DIR DS_PORT
|
for xashvar in BUILD_DIR INSTALL_DIR DS_PORT
|
||||||
do
|
do
|
||||||
|
@ -27,6 +17,21 @@ do
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
## these variables are from github.com/FWGS/xashds-docker, nice to have :)
|
||||||
|
hlds_build=8684
|
||||||
|
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"
|
||||||
|
|
||||||
|
# colors for colored output 8)
|
||||||
|
RED="\e[31m"
|
||||||
|
GREEN="\e[32m"
|
||||||
|
YELLOW="\e[33m"
|
||||||
|
ENDCOLOR="\e[0m"
|
||||||
|
|
||||||
showhelp() {
|
showhelp() {
|
||||||
echo "Usage: $0 [server|client] [install|update] [0.19|0.20]
|
echo "Usage: $0 [server|client] [install|update] [0.19|0.20]
|
||||||
|
@ -56,6 +61,30 @@ $hlds_url
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function message() {
|
||||||
|
case $1 in
|
||||||
|
info)
|
||||||
|
MESSAGE_TYPE="${GREEN}INFO${ENDCOLOR}"
|
||||||
|
;;
|
||||||
|
warn)
|
||||||
|
MESSAGE_TYPE="${YELLOW}WARN${ENDCOLOR}"
|
||||||
|
;;
|
||||||
|
error)
|
||||||
|
MESSAGE_TYPE="${RED}ERROR${ENDCOLOR}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo -e "[${MESSAGE_TYPE}] $2"
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkerror() {
|
||||||
|
if [ $1 -gt 0 ]
|
||||||
|
then
|
||||||
|
message error "Something went wrong, got wrong exit code ${RED}ERROR${ENDCOLOR}"
|
||||||
|
message error "Exit here."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
case $3 in
|
case $3 in
|
||||||
"0.19")
|
"0.19")
|
||||||
XASH_GIT_URL="https://gitlab.com/tyabus/xash3d"
|
XASH_GIT_URL="https://gitlab.com/tyabus/xash3d"
|
||||||
|
@ -118,33 +147,43 @@ XASH_INSTALL_TYPE=$1
|
||||||
|
|
||||||
export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig
|
export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig
|
||||||
|
|
||||||
echo "= Creating directories ="
|
message info "Creating directories"
|
||||||
XASH_GIT_DIR="$(echo ${XASH_GIT_URL} | cut -d / -f5)"
|
XASH_GIT_DIR="$(echo ${XASH_GIT_URL} | cut -d / -f5)"
|
||||||
test -d $XASH_INSTALL_DIR || mkdir -p $XASH_INSTALL_DIR
|
if [ ! -d $XASH_INSTALL_DIR ]
|
||||||
test -d $XASH_BUILD_DIR || mkdir -p $XASH_BUILD_DIR
|
then
|
||||||
|
mkdir -p $XASH_INSTALL_DIR && message info "created ${YELLOW}${XASH_INSTALL_DIR}${ENDCOLOR}"
|
||||||
|
checkerror $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d $XASH_BUILD_DIR ]
|
||||||
|
then
|
||||||
|
mkdir -p $XASH_BUILD_DIR && message info "created ${YELLOW}${XASH_BUILD_DIR}${ENDCOLOR}"
|
||||||
|
checkerror $?
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$XASH_INSTALL_MODE" == "install" ]
|
if [ "$XASH_INSTALL_MODE" == "install" ]
|
||||||
then
|
then
|
||||||
echo "= Performing apt install ="
|
message info "Performing apt install"
|
||||||
sudo dpkg --add-architecture i386
|
sudo dpkg --add-architecture i386
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt-get install -y --no-install-recommends $PACKAGES
|
sudo apt-get install -y --no-install-recommends $PACKAGES
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "= Compiling xash3d-fwgs ="
|
message info "Prepare ${YELLOW}${XASH_GIT_DIR}${ENDCOLOR}"
|
||||||
## compile xash3ds
|
## compile xash3ds
|
||||||
# prepare and configure for compiling
|
# prepare and configure for compiling
|
||||||
cd $XASH_BUILD_DIR
|
cd $XASH_BUILD_DIR
|
||||||
case $XASH_INSTALL_MODE in
|
case $XASH_INSTALL_MODE in
|
||||||
"install")
|
"install")
|
||||||
|
git clone --recursive $XASH_GIT_URL
|
||||||
|
checkerror $?
|
||||||
|
test -d ${XASH_GIT_DIR} || mkdir -p ${XASH_GIT_DIR}/bin/
|
||||||
|
checkerror $?
|
||||||
case $XASH_INSTALL_VERSION in
|
case $XASH_INSTALL_VERSION in
|
||||||
0.19)
|
0.19)
|
||||||
git clone --recursive $XASH_GIT_URL
|
|
||||||
mkdir -p ${XASH_GIT_DIR}/bin/
|
|
||||||
cd ${XASH_GIT_DIR}/bin
|
cd ${XASH_GIT_DIR}/bin
|
||||||
;;
|
;;
|
||||||
0.20)
|
0.20)
|
||||||
mkdir -p ${XASH_GIT_DIR}/bin/
|
|
||||||
cd ${XASH_GIT_DIR}
|
cd ${XASH_GIT_DIR}
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -156,15 +195,28 @@ case $XASH_INSTALL_MODE in
|
||||||
0.19)
|
0.19)
|
||||||
cd bin
|
cd bin
|
||||||
cmake --cmake-clean-cache ../
|
cmake --cmake-clean-cache ../
|
||||||
|
checkerror $?
|
||||||
cd ../
|
cd ../
|
||||||
rm -Rf bin/*
|
if [ "$(ls -A bin)" ]
|
||||||
|
then
|
||||||
|
rm -Rf bin/*
|
||||||
|
checkerror $?
|
||||||
|
fi
|
||||||
git pull
|
git pull
|
||||||
|
checkerror $?
|
||||||
cd bin
|
cd bin
|
||||||
;;
|
;;
|
||||||
0.20)
|
0.20)
|
||||||
./waf clean
|
./waf clean
|
||||||
rm bin/*
|
checkerror $?
|
||||||
|
if [ "$(ls -A bin)" ]
|
||||||
|
then
|
||||||
|
rm -Rf bin/*
|
||||||
|
checkerror $?
|
||||||
|
fi
|
||||||
|
checkerror $?
|
||||||
git pull
|
git pull
|
||||||
|
checkerror $?
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -176,26 +228,32 @@ case $XASH_INSTALL_MODE in
|
||||||
esac
|
esac
|
||||||
|
|
||||||
## build
|
## build
|
||||||
##
|
message info "Compiling ${YELLOW}${XASH_GIT_DIR}${ENDCOLOR}"
|
||||||
case $XASH_INSTALL_VERSION in
|
case $XASH_INSTALL_VERSION in
|
||||||
0.19)
|
0.19)
|
||||||
cmake $CMAKE_OPTIONS ../
|
cmake $CMAKE_OPTIONS ../
|
||||||
|
checkerror $?
|
||||||
make -j2 #VERBOSE=1
|
make -j2 #VERBOSE=1
|
||||||
|
checkerror $?
|
||||||
;;
|
;;
|
||||||
0.20)
|
0.20)
|
||||||
./waf configure -T release $WAF_OPTIONS
|
./waf configure -T release $WAF_OPTIONS
|
||||||
|
checkerror $?
|
||||||
./waf -p build
|
./waf -p build
|
||||||
|
checkerror $?
|
||||||
./waf install --destdir=bin/
|
./waf install --destdir=bin/
|
||||||
|
checkerror $?
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## here we fetch half-life from steam server
|
## here we fetch half-life from steam server
|
||||||
|
message info "prepare steamcmd for downloading gamedata"
|
||||||
if [ "$XASH_INSTALL_MODE" == "install" ]
|
if [ "$XASH_INSTALL_MODE" == "install" ]
|
||||||
then
|
then
|
||||||
mkdir -p $XASH_BUILD_DIR/steam
|
mkdir -p $XASH_BUILD_DIR/steam
|
||||||
|
checkerror $?
|
||||||
cd $XASH_BUILD_DIR/steam
|
cd $XASH_BUILD_DIR/steam
|
||||||
## an steamcmd automation
|
## an steamcmd automation
|
||||||
echo "login anonymous
|
echo "login anonymous
|
||||||
|
@ -206,27 +264,32 @@ app_update 90
|
||||||
app_update 90 validate
|
app_update 90 validate
|
||||||
app_update 90 validate
|
app_update 90 validate
|
||||||
quit" > $XASH_BUILD_DIR/steam/hlds.install
|
quit" > $XASH_BUILD_DIR/steam/hlds.install
|
||||||
|
checkerror $?
|
||||||
|
|
||||||
echo "= fetching hlds with steamcmd ="
|
|
||||||
## fetch steamcmd
|
## fetch steamcmd
|
||||||
|
message info "getting steamcmd binary"
|
||||||
curl -L "$steamcmd_url" | tar xzvf -
|
curl -L "$steamcmd_url" | tar xzvf -
|
||||||
|
checkerror $?
|
||||||
## run half-life download from steam server with steamcmd
|
## run half-life download from steam server with steamcmd
|
||||||
## If grep find Error then fetch the hlds zip from github
|
## If grep find Error then fetch the hlds zip from github
|
||||||
echo "= This can take a while depending ony your connection ="
|
message info "downloading gamedata with steamcmd from valve"
|
||||||
if ./steamcmd.sh +runscript hlds.install | grep Error
|
if ./steamcmd.sh +runscript hlds.install | grep Error
|
||||||
then
|
then
|
||||||
echo "= !! There was an error fetching hlds with steamcmd. Fetching it from github !! ="
|
message warn "${YELLOW}!!${ENDCOLOR} There was an error fetching Half-Life with steamcmd. Fallback download it from github ${YELLOW}!!${ENDCOLOR}"
|
||||||
echo $hlds_url
|
message info "$hlds_url"
|
||||||
## this is just another source you can use instead of steamcmd.
|
## this is just another source you can use instead of steamcmd.
|
||||||
curl -LJO "$hlds_url"
|
curl -LJO "$hlds_url"
|
||||||
|
checkerror $?
|
||||||
unzip "hlds_build_$hlds_build.zip" -d "hlds_build_$hlds_build"
|
unzip "hlds_build_$hlds_build.zip" -d "hlds_build_$hlds_build"
|
||||||
|
checkerror $?
|
||||||
cp -R "hlds_build_$hlds_build/hlds_build_$hlds_build"/* $XASH_INSTALL_DIR
|
cp -R "hlds_build_$hlds_build/hlds_build_$hlds_build"/* $XASH_INSTALL_DIR
|
||||||
|
checkerror $?
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## copy xash3d binaries to result
|
## copy xash3d binaries to result
|
||||||
## place Xash3D binaries in result and overwrite all
|
## place Xash3D binaries in result and overwrite all
|
||||||
echo "= copy xash3d binaries to $XASH_INSTALL_DIR"
|
message info "copy xash3d binaries to ${YELLOW}${XASH_INSTALL_DIR}${ENDCOLOR}"
|
||||||
|
|
||||||
case $XASH_INSTALL_VERSION in
|
case $XASH_INSTALL_VERSION in
|
||||||
0.19)
|
0.19)
|
||||||
|
@ -234,14 +297,17 @@ case $XASH_INSTALL_VERSION in
|
||||||
case $XASH_INSTALL_TYPE in
|
case $XASH_INSTALL_TYPE in
|
||||||
server)
|
server)
|
||||||
cp -R engine/xash3d $XASH_INSTALL_DIR/xash
|
cp -R engine/xash3d $XASH_INSTALL_DIR/xash
|
||||||
|
checkerror $?
|
||||||
;;
|
;;
|
||||||
client)
|
client)
|
||||||
cp -R engine/xash3d mainui/libxashmenu.so vgui_support/libvgui_support.so vgui_support/vgui.so $XASH_INSTALL_DIR
|
cp -R engine/xash3d mainui/libxashmenu.so vgui_support/libvgui_support.so vgui_support/vgui.so $XASH_INSTALL_DIR
|
||||||
|
checkerror $?
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
0.20)
|
0.20)
|
||||||
cp -R $XASH_BUILD_DIR/$XASH_GIT_DIR/bin/* $XASH_INSTALL_DIR
|
cp -R $XASH_BUILD_DIR/$XASH_GIT_DIR/bin/* $XASH_INSTALL_DIR
|
||||||
|
checkerror $?
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -252,7 +318,8 @@ if [ "$XASH_INSTALL_MODE" == "install" ]
|
||||||
then
|
then
|
||||||
case $XASH_INSTALL_TYPE in
|
case $XASH_INSTALL_TYPE in
|
||||||
server)
|
server)
|
||||||
echo "= Creating start.sh script for dedicated server in $XASH_INSTALL_DIR ="
|
message info "Creating start.sh script for dedicated server in ${YELLOW}${XASH_INSTALL_DIR}${ENDCOLOR}"
|
||||||
|
# all 0.19 xash3d versions are using +port and 0.20 -port
|
||||||
case $XASH_INSTALL_VERSION in
|
case $XASH_INSTALL_VERSION in
|
||||||
0.19)
|
0.19)
|
||||||
lol="+port"
|
lol="+port"
|
||||||
|
@ -262,10 +329,12 @@ then
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
echo "#!/bin/bash
|
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
|
./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
|
echo screenname xash_${XASH_INSTALL_VERSION}_${XASH_DS_PORT}" > $XASH_INSTALL_DIR/start.sh
|
||||||
|
checkerror $?
|
||||||
|
|
||||||
chmod +x $XASH_INSTALL_DIR/start.sh
|
chmod +x $XASH_INSTALL_DIR/start.sh
|
||||||
|
checkerror $?
|
||||||
|
|
||||||
echo "After=network.target
|
echo "After=network.target
|
||||||
|
|
||||||
|
@ -279,10 +348,11 @@ ExecStop=/bin/kill -9 \$MAINPID
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target" > $XASH_INSTALL_DIR/xashds_${XASH_INSTALL_VERSION}_${XASH_DS_PORT}.service
|
WantedBy=multi-user.target" > $XASH_INSTALL_DIR/xashds_${XASH_INSTALL_VERSION}_${XASH_DS_PORT}.service
|
||||||
|
checkerror $?
|
||||||
|
|
||||||
touch $XASH_INSTALL_DIR/valve/listip.cfg
|
touch $XASH_INSTALL_DIR/valve/listip.cfg
|
||||||
touch $XASH_INSTALL_DIR/valve/banned.cfg
|
touch $XASH_INSTALL_DIR/valve/banned.cfg
|
||||||
echo "= If you need an example config for a public server, have a look into https://github.com/FWGS/xashds-docker/tree/master/valve ="
|
message info "If you need an example config for a public server, have a look into ${YELLOW}https://github.com/FWGS/xashds-docker/tree/master/valve${ENDCOLOR}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
client)
|
client)
|
||||||
|
@ -296,9 +366,28 @@ Type=Application
|
||||||
StartupNotify=false
|
StartupNotify=false
|
||||||
Categories=Game;
|
Categories=Game;
|
||||||
X-Desktop-File-Install-Version=0.24" > $XASH_INSTALL_DIR/Xash3D_${XASH_INSTALL_VERSION}.desktop
|
X-Desktop-File-Install-Version=0.24" > $XASH_INSTALL_DIR/Xash3D_${XASH_INSTALL_VERSION}.desktop
|
||||||
|
checkerror $?
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "= DONE! If everything went well an no errors occured you can just run your game/server from $XASH_INSTALL_DIR ="
|
|
||||||
echo "= starting server: ./start.sh ; starting game client ./xash3d ="
|
|
||||||
|
case $XASH_INSTALLATION_MODE in
|
||||||
|
install)
|
||||||
|
message info "${GREEN}DONE!!${ENDCOLOR} Installation completed without erros."
|
||||||
|
message info "Your ready to run Xash3D installation is located in"
|
||||||
|
message info "${YELLOW}${XASH_INSTALL_DIR}${ENDCOLOR}"
|
||||||
|
case $XASH_INSTALLATION_TYPE in
|
||||||
|
client)
|
||||||
|
message info "You can run the game with ${YELLOW}'./xash3d'${ENDCOLOR} from the install location"
|
||||||
|
;;
|
||||||
|
server)
|
||||||
|
message info "You can start the server with ${YELLOW}'./start.sh'${ENDCOLOR} from the install location"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
update)
|
||||||
|
message info "${GREEN}DONE!!${ENDCOLOR} Update completed without errors."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
Loading…
Reference in a new issue