From 7a3eb2195435ee88358119b1c774cbb6feae81df Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Mon, 22 Feb 2021 12:57:13 +0300 Subject: [PATCH] binary patching support --- SOURCES/Makefile | 40 ++++++++++++---------- SOURCES/main/kf2-srv | 1 + SOURCES/main/lib/game.lib | 10 ++++++ SOURCES/main/systemd/kf2-srv-beta@.service | 3 +- SOURCES/main/systemd/kf2-srv@.service | 3 +- SPECS/kf2-srv.spec | 6 +++- 6 files changed, 39 insertions(+), 24 deletions(-) diff --git a/SOURCES/Makefile b/SOURCES/Makefile index b1686b7..f3dad78 100644 --- a/SOURCES/Makefile +++ b/SOURCES/Makefile @@ -43,6 +43,7 @@ DATADIR = $(DESTDIR)$(PREFIX)/share SCRIPTDIR = $(DATADIR)/$(NAME) SCRIPTGRPDIR = $(SCRIPTDIR)/cmdgrp SCRIPTLIBDIR = $(SCRIPTDIR)/lib +SCRIPTPATCHDIR = $(SCRIPTDIR)/patch LICENSEDIR = $(DATADIR)/licenses/$(NAME) KF2MAINDIR = $(GAMEDIR)/$(NAME) KF2BETADIR = $(GAMEDIR)/$(NAME)-beta @@ -69,25 +70,26 @@ fake-systemd-build: find $(RELEASEDIR) -type f -exec sed -i -r 's|ExecStart=.+KFGameSteamServer.bin.x86_64|ExecStart=/bin/bash|g;' {} \; filesystem: - test -d '$(CONFDIR)' || install -m 775 -d '$(CONFDIR)' - test -d '$(INSTMAINDIR)' || install -m 775 -d '$(INSTMAINDIR)' - test -d '$(INSTBETADIR)' || install -m 775 -d '$(INSTBETADIR)' - test -d '$(MAPCYCLEDIR)' || install -m 775 -d '$(MAPCYCLEDIR)' - test -d '$(CACHEDIR)' || install -m 775 -d '$(CACHEDIR)' - test -d '$(BINDIR)' || install -m 755 -d '$(BINDIR)' - test -d '$(SBINDIR)' || install -m 755 -d '$(SBINDIR)' - test -d '$(KF2MAINDIR)' || install -m 775 -d '$(KF2MAINDIR)' - test -d '$(KF2BETADIR)' || install -m 775 -d '$(KF2BETADIR)' - test -d '$(LICENSEDIR)' || install -m 755 -d '$(LICENSEDIR)' - test -d '$(MAINLOGDIR)' || install -m 770 -d '$(MAINLOGDIR)' - test -d '$(BETALOGDIR)' || install -m 770 -d '$(BETALOGDIR)' - test -d '$(UNITDIR)' || install -m 755 -d '$(UNITDIR)' - test -d '$(FIREWALLDDIR)' || install -m 755 -d '$(FIREWALLDDIR)' - test -d '$(LOGROTATEDIR)' || install -m 755 -d '$(LOGROTATEDIR)' - test -d '$(RSYSLOGDIR)' || install -m 755 -d '$(RSYSLOGDIR)' - test -d '$(SCRIPTGRPDIR)' || install -m 755 -d '$(SCRIPTGRPDIR)' - test -d '$(SCRIPTLIBDIR)' || install -m 755 -d '$(SCRIPTLIBDIR)' - test -d '$(BASHCOMPDIR)' || install -m 755 -d '$(BASHCOMPDIR)' + test -d '$(CONFDIR)' || install -m 775 -d '$(CONFDIR)' + test -d '$(INSTMAINDIR)' || install -m 775 -d '$(INSTMAINDIR)' + test -d '$(INSTBETADIR)' || install -m 775 -d '$(INSTBETADIR)' + test -d '$(MAPCYCLEDIR)' || install -m 775 -d '$(MAPCYCLEDIR)' + test -d '$(CACHEDIR)' || install -m 775 -d '$(CACHEDIR)' + test -d '$(BINDIR)' || install -m 755 -d '$(BINDIR)' + test -d '$(SBINDIR)' || install -m 755 -d '$(SBINDIR)' + test -d '$(KF2MAINDIR)' || install -m 775 -d '$(KF2MAINDIR)' + test -d '$(KF2BETADIR)' || install -m 775 -d '$(KF2BETADIR)' + test -d '$(LICENSEDIR)' || install -m 755 -d '$(LICENSEDIR)' + test -d '$(MAINLOGDIR)' || install -m 770 -d '$(MAINLOGDIR)' + test -d '$(BETALOGDIR)' || install -m 770 -d '$(BETALOGDIR)' + test -d '$(UNITDIR)' || install -m 755 -d '$(UNITDIR)' + test -d '$(FIREWALLDDIR)' || install -m 755 -d '$(FIREWALLDDIR)' + test -d '$(LOGROTATEDIR)' || install -m 755 -d '$(LOGROTATEDIR)' + test -d '$(RSYSLOGDIR)' || install -m 755 -d '$(RSYSLOGDIR)' + test -d '$(SCRIPTGRPDIR)' || install -m 755 -d '$(SCRIPTGRPDIR)' + test -d '$(SCRIPTLIBDIR)' || install -m 755 -d '$(SCRIPTLIBDIR)' + test -d '$(SCRIPTPATCHDIR)' || install -m 755 -d '$(SCRIPTPATCHDIR)' + test -d '$(BASHCOMPDIR)' || install -m 755 -d '$(BASHCOMPDIR)' install: filesystem build install -m 755 $(RELEASEDIR)/main/$(NAME) $(BINDIR) diff --git a/SOURCES/main/kf2-srv b/SOURCES/main/kf2-srv index 0684776..2dc5546 100755 --- a/SOURCES/main/kf2-srv +++ b/SOURCES/main/kf2-srv @@ -25,6 +25,7 @@ readonly ScriptVersion=$(rpm -q --queryformat '%{VERSION}' "$ScriptName") readonly GrpDir=":DEFINE_PREFIX:/share/kf2-srv/cmdgrp" readonly LibDir=":DEFINE_PREFIX:/share/kf2-srv/lib" +readonly PatchDir=":DEFINE_PREFIX:/share/kf2-srv/patch" readonly InstallDir=":DEFINE_PREFIX:/games/kf2-srv${KF2POSTFIX}" readonly AppBin="$InstallDir/Binaries/Win64/KFGameSteamServer.bin.x86_64" diff --git a/SOURCES/main/lib/game.lib b/SOURCES/main/lib/game.lib index 859b9a9..6021bc8 100644 --- a/SOURCES/main/lib/game.lib +++ b/SOURCES/main/lib/game.lib @@ -60,6 +60,7 @@ function game_update () elif updates_aviable; then instance_stop steamcmd +login $SteamLogin +force_install_dir $InstallDir +app_update $AppServerNum $BetaArg +exit + apply_patch instance_start else echo "Server is up to date" @@ -96,6 +97,7 @@ function game_validate () fi instance_stop steamcmd +login $SteamLogin +force_install_dir $InstallDir +app_update $AppServerNum $BetaArg validate +exit + apply_patch fix_steamclient_so instance_start } @@ -200,6 +202,7 @@ function first_install () fix_steamclient_so ln -s "$InstanceConfigDir" "$DefaultConfigDir/instances" make_default_instance + apply_patch echo "KF2 succesfully installed" } @@ -275,6 +278,13 @@ function make_default_instance () # $1: Dir fix_ini_eol "$InstanceDir" } +function apply_patch () +{ + if [[ -x "$PatchDir/kf2-ranked-patch" ]]; then + "$PatchDir/kf2-ranked-patch" "$AppBin" + fi +} + function fix_ini_eol () # $1: Dir { find "$1" \( -type l -o -type f \) -name '*.ini' | \ diff --git a/SOURCES/main/systemd/kf2-srv-beta@.service b/SOURCES/main/systemd/kf2-srv-beta@.service index 1db2ed5..6f9d1c2 100644 --- a/SOURCES/main/systemd/kf2-srv-beta@.service +++ b/SOURCES/main/systemd/kf2-srv-beta@.service @@ -1,6 +1,5 @@ [Unit] Description=Killing Floor 2 Beta Server Daemon - %i -After=kf2-srv-force-attr.service After=network-online.target Wants=network-online.target @@ -13,7 +12,7 @@ StandardError=syslog SyslogIdentifier=kf2-srv-beta/%i EnvironmentFile=/etc/kf2-srv/instances-beta/%i/instance.conf ExecStart=:DEFINE_PREFIX:/games/kf2-srv-beta/Binaries/Win64/KFGameSteamServer.bin.x86_64 ${Map}?Difficulty=${Difficulty}?GameLength=${Length}?Game=${Game}?Mutator=${Mutators}?${Args} configsubdir=instances/%i -webadminport=${PortWeb} -queryport=${PortQuery} -port=${PortGame} -Restart=always +Restart=on-failure NoNewPrivileges=yes PrivateTmp=true diff --git a/SOURCES/main/systemd/kf2-srv@.service b/SOURCES/main/systemd/kf2-srv@.service index ba96be2..22f030d 100644 --- a/SOURCES/main/systemd/kf2-srv@.service +++ b/SOURCES/main/systemd/kf2-srv@.service @@ -1,6 +1,5 @@ [Unit] Description=Killing Floor 2 Server Daemon - %i -After=kf2-srv-force-attr.service After=network-online.target Wants=network-online.target @@ -13,7 +12,7 @@ StandardError=syslog SyslogIdentifier=kf2-srv/%i EnvironmentFile=/etc/kf2-srv/instances/%i/instance.conf ExecStart=:DEFINE_PREFIX:/games/kf2-srv/Binaries/Win64/KFGameSteamServer.bin.x86_64 ${Map}?Difficulty=${Difficulty}?GameLength=${Length}?Game=${Game}?Mutator=${Mutators}?${Args} configsubdir=instances/%i -webadminport=${PortWeb} -queryport=${PortQuery} -port=${PortGame} -Restart=always +Restart=on-failure NoNewPrivileges=yes PrivateTmp=true diff --git a/SPECS/kf2-srv.spec b/SPECS/kf2-srv.spec index 905f551..7f39e85 100644 --- a/SPECS/kf2-srv.spec +++ b/SPECS/kf2-srv.spec @@ -1,7 +1,7 @@ %global steamuser steam Name: kf2-srv -Version: 0.16.0 +Version: 0.17.0 Release: 1%{dist} Summary: Killing Floor 2 server Group: Amusements/Games @@ -68,6 +68,7 @@ rm -rf $RPM_BUILD_ROOT %attr(0775,root,root) %dir %{_datadir}/%{name}/cmdgrp %attr(0755,root,root) %dir %{_datadir}/%{name}/cmdgrp/* %attr(0775,root,root) %dir %{_datadir}/%{name}/lib +%attr(0775,root,root) %dir %{_datadir}/%{name}/patch %attr(0664,root,%{steamuser}) %config(noreplace) %{_sysconfdir}/%{name}/instance.conf.template %attr(0664,root,%{steamuser}) %config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf %attr(0640,root,%{steamuser}) %config(noreplace) %{_sysconfdir}/%{name}/bot.conf @@ -100,6 +101,9 @@ if [[ $1 == 1 ]]; then # Install fi %changelog +* Sun Feb 21 2021 GenZmeY - 0.17.0-1 +- Binary patching support. + * Mon Sep 21 2020 GenZmeY - 0.16.0-1 - remove force-attr daemon; - log cmg group;