diff --git a/SOURCES/kf2-srv b/SOURCES/kf2-srv index cabc017..1d4c523 100644 --- a/SOURCES/kf2-srv +++ b/SOURCES/kf2-srv @@ -222,13 +222,13 @@ function new_instance () # $*: InstanceName[s] local InstanceDir="$InstanceConfigDir/$Instance" - local DirMode="-d -g $SteamUser -o $SteamUser -m 775" - local FileMode=" -g $SteamUser -o $SteamUser -m 664" + local DirMode="-d -g $SteamUser -o $ForceIniGroup -m 775" + local FileMode=" -g $SteamUser -o $ForceIniGroup -m $ForceIniPermissions" install $DirMode "$InstanceDir" install $DirMode "$InstanceDir/LinuxServer" - install $FileMode "$InstanceConfigTemplate" "$InstanceDir/instance.conf" + install $FileMode "$InstanceConfigTemplate" "$InstanceDir/instance.conf" install $FileMode "$DefaultConfigDir/KFAI.ini" "$InstanceDir" install $FileMode "$DefaultConfigDir/KFWeb.ini" "$InstanceDir" install $FileMode "$DefaultConfigDir/KFWebAdmin.ini" "$InstanceDir" @@ -255,8 +255,6 @@ function new_instance () # $*: InstanceName[s] multini -s "$InstanceDir/KFWebAdmin.ini" "WebAdmin.WebAdmin" "bHttpAuth" "True" multini -s "$InstanceDir/KFWebAdmin.ini" "WebAdmin.Chatlog" "Filename" "$Instance-chat" multini -s "$InstanceDir/KFWebAdmin.ini" "WebAdmin.Chatlog" "bIncludeTimeStamp" "False" - - # LOGGING?: LinuxServer-KFGame.ini bLog* echo "Instance $Instance created. See /etc/$ScriptName/instances$BetaPostfix/$Instance for edit configuration" done @@ -396,9 +394,9 @@ function make_default_instance () # $1: Dir { local InstanceDir="$InstanceConfigDir/default" - install -d -g "$SteamUser" -o "$SteamUser" -m 775 "$InstanceDir" - install -d -g "$SteamUser" -o "$SteamUser" -m 775 "$InstanceDir/LinuxServer" - install -g "$SteamUser" -o "$SteamUser" -m 664 "$InstanceConfigTemplate" "$InstanceDir/instance.conf" + install -d -g "$SteamUser" -o "$ForceIniGroup" -m 775 "$InstanceDir" + install -d -g "$SteamUser" -o "$ForceIniGroup" -m 775 "$InstanceDir/LinuxServer" + install -g "$SteamUser" -o "$ForceIniGroup" -m $ForceIniPermissions "$InstanceConfigTemplate" "$InstanceDir/instance.conf" ln -s "$DefaultConfigDir/KFAI.ini" "$InstanceDir/KFAI.ini" ln -s "$DefaultConfigDir/KFWeb.ini" "$InstanceDir/KFWeb.ini" ln -s "$DefaultConfigDir/KFWebAdmin.ini" "$InstanceDir/KFWebAdmin.ini" @@ -433,7 +431,7 @@ function fix_ini_permissions () # $1: Dir { find "$1" \( -type l -o -type f \) -name '*.ini' | \ xargs --max-procs=$(nproc) -I {} \ - sh -c "chmod 664 {}; chown $SteamUser:$SteamUser {}" + sh -c "chmod $ForceIniPermissions {}; chown $SteamUser:$ForceIniGroup {}" } function fix_ini_eol () # $1: Dir @@ -453,34 +451,36 @@ function fix_steamclient_so () ln -s "/usr/share/steamcmd/linux64/steamclient.so" "$InstallDir/Binaries/Win64/lib64/steamclient.so" } -function create_map_dirs () +function create_cache () { - # space saving - local InstallDirOrig="/usr/games/kf2-srv" - local InstallDirBeta="/usr/games/kf2-srv-beta" - local DownloadDirOrig="$InstallDirOrig/Binaries/Win64/steamapps/workshop/content/$AppClientNum" - local CacheDirOrig="$InstallDirOrig/KFGame/Cache" - local DownloadDirBeta="$InstallDirBeta/Binaries/Win64/steamapps/workshop/content/$AppClientNum" - local CacheDirBeta="$InstallDirBeta/KFGame/Cache" + if [[ -d "$DownloadDir" ]]; then + if ! [[ -L "$DefaultDownloadDir" ]]; then + if [[ -d "$DefaultDownloadDir" ]]; then + rm -rf "$DefaultDownloadDir" "$DownloadDir" + ln -s "$DownloadDir" "$DefaultDownloadDir" + else + install -d -g "$SteamUser" -o "$SteamUser" -m 775 "$InstallDir/Binaries/Win64/steamapps" + ln -s "$DownloadDir" "$DefaultDownloadDir" + fi + fi + else + if [[ -L "$DefaultDownloadDir" ]]; then + install -d -g "$SteamUser" -o "$SteamUser" -m 775 "$DownloadDir" + elif [[ -d "$DefaultDownloadDir" ]]; then + mv -rf "$DefaultDownloadDir" "$DownloadDir" + ln -s "$DownloadDir" "$DefaultDownloadDir" + else + install -d -g "$SteamUser" -o "$SteamUser" -m 775 "$DownloadDir" + install -d -g "$SteamUser" -o "$SteamUser" -m 775 "$InstallDir/Binaries/Win64/steamapps" + ln -s "$DownloadDir" "$DefaultDownloadDir" + fi + fi - if [[ -z "$BetaPostfix" ]]; then # Orig - sudo -u "$SteamUser" install -d -m 775 "$DownloadDirOrig" - if [[ -d "$CacheDirBeta" ]]; then - ln -s "$CacheDirBeta" "$CacheDirOrig" - rm -rf "$DownloadDirOrig" - ln -s "$DownloadDirBeta" "$DownloadDirOrig" - else - sudo -u "$SteamUser" install -d -m 775 "$CacheDirOrig" - fi - else # Beta - sudo -u "$SteamUser" install -d -m 775 "$DownloadDirBeta" - if [[ -d "$CacheDirOrig" ]]; then - ln -s "$CacheDirOrig" "$CacheDirBeta" - rm -rf "$DownloadDirBeta" - ln -s "$DownloadDirOrig" "$DownloadDirBeta" - else - sudo -u "$SteamUser" install -d -m 775 "$CacheDirBeta" - fi + if ! [[ -d "$CacheDir" ]]; then + install -d -g "$SteamUser" -o "$SteamUser" -m 775 "$CacheDir" + fi + if ! [[ -L "$DefaultCacheDir" ]]; then + ln -s "$CacheDir" "$DefaultCacheDir" fi } @@ -491,8 +491,8 @@ function first_install () exit 1 fi - rm -rf "$LogDir" - ln -s "/var/log/kf2-srv$BetaPostfix" "$LogDir" + rm -rf "$DefaultLogDir" + ln -s "$LogDir" "$DefaultLogDir" echo "Creating base ini files" sudo -u "$SteamUser" $AppBin &> /dev/null & @@ -577,9 +577,9 @@ function first_install () do sleep 2; done killall -KILL KFGameSteamServer.bin.x86_64; sleep 1 - create_map_dirs + create_cache fix_steamclient_so - ln -s "$InstanceConfigDir" "$InstanceConfigLnk" + ln -s "$InstanceConfigDir" "$DefaultConfigDir/instances" make_default_instance echo "KF2 succesfully installed" } @@ -775,7 +775,7 @@ function workshop_list () for WorkshopID in $(workshop_list_ids) do local Cache="$CacheDir/$WorkshopID" - local Downl="$DownloadDir/$WorkshopID" + local Downl="$DownloadDir/content/$AppClientNum/$WorkshopID" local Url="https://steamcommunity.com/sharedfiles/filedetails/?id=$WorkshopID" local WsName=$(name_by_workshopID "$WorkshopID") if [[ -n "$WsName" ]]; then @@ -823,7 +823,7 @@ function workshop_del () # $*: WorkshopID[s] local WorkshopID=$(any_to_workshopID "$Map") local WsName=$(name_by_workshopID "$WorkshopID") local Cache="$CacheDir/$WorkshopID" - local Downl="$DownloadDir/$WorkshopID" + local Downl="$DownloadDir/content/$AppClientNum/$WorkshopID" echo -e "Clear cache:\n$Cache\n$Downl" rm -rf "$Cache" "$Downl" for Instance in $(show_instances) @@ -1189,7 +1189,7 @@ function password_admin () # $1: Password (if empty, use: ''), $*: Instance[s] local Service=$(service_name "$Instance") if systemctl -q is-active $Service ; then admin_curl "$Instance" "ServerAdmin/policy/passwords" \ - --request POST \ + --request POST \ --data action="adminpassword" \ --data adminpw1="$Password" \ --data adminpw2="$Password" @@ -1236,12 +1236,17 @@ fi InstallDir="/usr/games/kf2-srv$BetaPostfix" AppBin="$InstallDir/Binaries/Win64/KFGameSteamServer.bin.x86_64" + DefaultConfigDir="$InstallDir/KFGame/Config" -DownloadDir="$InstallDir/Binaries/Win64/steamapps/workshop/content/$AppClientNum" -CacheDir="$InstallDir/KFGame/Cache" -LogDir="$InstallDir/KFGame/Logs" +DefaultDownloadDir="$InstallDir/Binaries/Win64/steamapps/workshop" +DefaultCacheDir="$InstallDir/KFGame/Cache" +DefaultLogDir="$InstallDir/KFGame/Logs" + +DownloadDir="/var/cache/kf2-srv/workshop" +CacheDir="/var/cache/kf2-srv/cache" +LogDir="/var/log/kf2-srv$BetaPostfix" + InstanceConfigDir="/etc/kf2-srv/instances$BetaPostfix" -InstanceConfigLnk="$DefaultConfigDir/instances" InstanceConfigTemplate="/etc/kf2-srv/instance.conf.template" if [[ $# -eq 0 ]]; then show_help; exit 0; fi diff --git a/SOURCES/kf2-srv.conf b/SOURCES/kf2-srv.conf index 395b7e1..be4df80 100755 --- a/SOURCES/kf2-srv.conf +++ b/SOURCES/kf2-srv.conf @@ -16,7 +16,8 @@ ModeNames['KFGameContent.KFGameInfo_VersusSurvival']='Versus' # Add mutators to the end of the list, similar to what is already there: MutNames['ServerExtMut.ServerExtMut']='RPG' -# These parameters works only if "kf2-srv-force-attr.service" is active +# These parameters are used when creating new instances. +# In order for the parameters to be applied to the files that the working server creates, the "kf2-srv-force-attr.service" must be active. ForceIniPermissions=664 ForceLogPermissions=640 ForceIniGroup=steam diff --git a/SPECS/kf2-srv.spec b/SPECS/kf2-srv.spec index 705d4fe..3136054 100644 --- a/SPECS/kf2-srv.spec +++ b/SPECS/kf2-srv.spec @@ -1,7 +1,7 @@ %global steamuser steam Name: kf2-srv -Version: 0.12.1 +Version: 0.13.0 Release: 1%{dist} Summary: Killing Floor 2 server Group: Amusements/Games @@ -69,6 +69,7 @@ install -d %{buildroot}/%{_prefix}/games/%{name}-beta install -d %{buildroot}/%{_datadir}/licenses/%{name} install -d %{buildroot}/%{_localstatedir}/log/%{name} install -d %{buildroot}/%{_localstatedir}/log/%{name}-beta +install -d %{buildroot}/%{_localstatedir}/cache/kf2-srv # access rights are used here to prevent warnings when building the package install -m 755 %{SOURCE1} %{buildroot}/%{_bindir} @@ -89,6 +90,10 @@ install -m 644 %{SOURCE15} %{buildroot}/%{_sysconfdir}/%{name} install -m 755 %{SOURCE16} %{buildroot}/%{_sbindir} install -m 644 %{SOURCE17} %{buildroot}/%{_prefix}/lib/systemd/system +%check +bash -n %{buildroot}/%{_bindir}/%{name} +bash -n %{buildroot}/%{_bindir}/%{name}-beta + %clean rm -rf $RPM_BUILD_ROOT @@ -101,6 +106,7 @@ rm -rf $RPM_BUILD_ROOT %attr(0775,root,%{steamuser}) %dir %{_sysconfdir}/%{name}/mapcycles %attr(0770,root,%{steamuser}) %dir %{_localstatedir}/log/%{name} %attr(0770,root,%{steamuser}) %dir %{_localstatedir}/log/%{name}-beta +%attr(0775,root,%{steamuser}) %dir %{_localstatedir}/cache/kf2-srv %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 @@ -121,15 +127,22 @@ if [[ $1 -eq 0 ]] ; then # Uninstall rm -rf %{_prefix}/games/%{name}-beta/* rm -rf %{_sysconfdir}/%{name}/instances/default rm -rf %{_sysconfdir}/%{name}/instances-beta/default + rm -rf %{_localstatedir}/cache/kf2-srv/* fi %post -#if [[ $1 == 1 ]]; then # Install -systemctl daemon-reload -systemctl try-restart rsyslog.service -#fi +if [[ $1 == 1 ]]; then # Install + systemctl daemon-reload + systemctl try-restart rsyslog.service +fi %changelog +* Sun Jul 19 2020 GenZmeY - 0.13.0-1 +- /var/cache to store the workshop cache; +- fixed endless downloading of workshop items that tripware gave us in PC Build 1099 patch; +- using ForcePermissions when creating instances; +- add %check section to specfile. + * Mon Jul 13 2020 GenZmeY - 0.12.1-1 - rename main.conf to instance.conf.