Fri Sep 20 2019
This commit is contained in:
parent
fed09be3c3
commit
774217b601
@ -22,8 +22,10 @@ source /etc/kf2-srv/kf2-srv.conf
|
|||||||
|
|
||||||
ScriptFullname=$(readlink -e "$0")
|
ScriptFullname=$(readlink -e "$0")
|
||||||
ScriptName=$(echo "$ScriptFullname" | awk -F '/' '{print $NF;}')
|
ScriptName=$(echo "$ScriptFullname" | awk -F '/' '{print $NF;}')
|
||||||
|
|
||||||
AppNum="232130"
|
AppNum="232130"
|
||||||
InstallDir="/usr/games/kf2-srv"
|
InstallDir="/usr/games/kf2-srv"
|
||||||
|
ActiveBranch="$InstallDir/activebranch.txt"
|
||||||
AppBin="$InstallDir/Binaries/Win64/KFGameSteamServer.bin.x86_64"
|
AppBin="$InstallDir/Binaries/Win64/KFGameSteamServer.bin.x86_64"
|
||||||
DefaultConfigDir="$InstallDir/KFGame/Config"
|
DefaultConfigDir="$InstallDir/KFGame/Config"
|
||||||
CustomMapsDir="$InstallDir/KFGame/Cache"
|
CustomMapsDir="$InstallDir/KFGame/Cache"
|
||||||
@ -50,7 +52,9 @@ function show_help ()
|
|||||||
echo " -u, --update при первом запуске производит установку KF2;"
|
echo " -u, --update при первом запуске производит установку KF2;"
|
||||||
echo " в дальнейшем устанавливает обновления при их"
|
echo " в дальнейшем устанавливает обновления при их"
|
||||||
echo " наличии"
|
echo " наличии"
|
||||||
echo " -r. --run [OPTIONS] запускает экземпляр сервера с указанными"
|
echo " -v, --validate проверяет целостность файлов, при"
|
||||||
|
echo " необходимости перекачивает их."
|
||||||
|
echo " -r, --run [OPTIONS] запускает экземпляр сервера с указанными"
|
||||||
echo " ПАРАМЕТРАМИ"
|
echo " ПАРАМЕТРАМИ"
|
||||||
echo " --start [INSTANCE] запускает указанный ЭКЗЕМПЛЯР сервера; если"
|
echo " --start [INSTANCE] запускает указанный ЭКЗЕМПЛЯР сервера; если"
|
||||||
echo " ЭКЗЕМПЛЯР не указан, запускает все"
|
echo " ЭКЗЕМПЛЯР не указан, запускает все"
|
||||||
@ -197,9 +201,12 @@ function show_status_implementation () # $1: [InstanceName]
|
|||||||
local IsRuning="dead"
|
local IsRuning="dead"
|
||||||
fi
|
fi
|
||||||
local Description=$(grep -P 'Description=' "$InstanceConfigDir/$Instance/main.conf" | sed -r 's/(Description=|")//g')
|
local Description=$(grep -P 'Description=' "$InstanceConfigDir/$Instance/main.conf" | sed -r 's/(Description=|")//g')
|
||||||
echo -e "$Instance:$IsEnabled:$IsRuning:$Description"
|
local GamePort=$(grep -Po '"-port=([0-9]+)' "$InstanceConfigDir/$Instance/main.conf" | grep -Po '[0-9]+$')
|
||||||
|
local WebAdminPort=$(grep -Po '"-webadminport=([0-9]+)' "$InstanceConfigDir/$Instance/main.conf" | grep -Po '[0-9]+$')
|
||||||
|
local QueryPort=$(grep -Po '"-queryport=([0-9]+)' "$InstanceConfigDir/$Instance/main.conf" | grep -Po '[0-9]+$')
|
||||||
|
echo -e "$Instance:$IsEnabled:$IsRuning:$GamePort:$QueryPort:$WebAdminPort:$Description"
|
||||||
else
|
else
|
||||||
echo -e "INSTANCE:AUTORUN:STATE:DESCRIPTION"
|
echo -e "INSTANCE:AUTORUN:STATE:P_GAME:P_QUERY:P_WEB:DESCRIPTION"
|
||||||
for Instance in $(show_instances)
|
for Instance in $(show_instances)
|
||||||
do
|
do
|
||||||
show_status_implementation "$Instance"
|
show_status_implementation "$Instance"
|
||||||
@ -212,20 +219,35 @@ function show_status () # $1: [InstanceName]
|
|||||||
show_status_implementation "$1" | column -t -s :
|
show_status_implementation "$1" | column -t -s :
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validate ()
|
||||||
|
{
|
||||||
|
if [[ -n "$BranchName" ]]; then
|
||||||
|
local BetaArg="-beta $BranchName"
|
||||||
|
fi
|
||||||
|
stop_instance
|
||||||
|
steamcmd +login $SteamLogin +force_install_dir $InstallDir +app_update $AppNum $BetaArg validate +exit
|
||||||
|
echo "$BranchName" > "$ActiveBranch"
|
||||||
|
start_instance
|
||||||
|
}
|
||||||
|
|
||||||
function update_kf2 ()
|
function update_kf2 ()
|
||||||
{
|
{
|
||||||
if [[ -n "$BranchName" ]]; then
|
if [[ -n "$BranchName" ]]; then
|
||||||
local BetaArg="-beta $BranchName"
|
local BetaArg="-beta $BranchName"
|
||||||
fi
|
fi
|
||||||
if ! server_exists; then # First install
|
if ! server_exists; then # First install
|
||||||
chown "root:$SteamUser" "$InstallDir"
|
|
||||||
steamcmd +login $SteamLogin +force_install_dir $InstallDir +app_update $AppNum $BetaArg validate +exit
|
steamcmd +login $SteamLogin +force_install_dir $InstallDir +app_update $AppNum $BetaArg validate +exit
|
||||||
mkdir "$InstanceConfigDir" "$CustomMapsDir" && chown -R "$SteamUser:$SteamUser" "$InstallDir/KFGame"
|
mkdir "$InstanceConfigDir" "$CustomMapsDir" && chown -R "$SteamUser:$SteamUser" "$InstallDir/KFGame"
|
||||||
ln -s "$InstanceConfigDir" "$InstanceConfigLnk"
|
ln -s "$InstanceConfigDir" "$InstanceConfigLnk"
|
||||||
|
echo "$BranchName" > "$ActiveBranch"
|
||||||
elif updates_aviable; then # Update
|
elif updates_aviable; then # Update
|
||||||
stop_instance
|
if [[ "$BranchName" == $(cat "$ActiveBranch") ]]; then
|
||||||
steamcmd +login $SteamLogin +force_install_dir $InstallDir +app_update $AppNum $BetaArg +exit
|
stop_instance
|
||||||
start_instance
|
steamcmd +login $SteamLogin +force_install_dir $InstallDir +app_update $AppNum $BetaArg +exit
|
||||||
|
start_instance
|
||||||
|
else
|
||||||
|
validate
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,6 +395,7 @@ case $1 in
|
|||||||
-l|--list ) show_instances; ;;
|
-l|--list ) show_instances; ;;
|
||||||
-s|--status ) show_status "$2"; ;;
|
-s|--status ) show_status "$2"; ;;
|
||||||
-u|--update ) if [[ "$EUID" -eq 0 ]]; then update_kf2 ; else run_as_root $@; fi;;
|
-u|--update ) if [[ "$EUID" -eq 0 ]]; then update_kf2 ; else run_as_root $@; fi;;
|
||||||
|
-v|--validate ) if [[ "$EUID" -eq 0 ]]; then validate ; else run_as_root $@; fi;;
|
||||||
-r|--run ) run $@ ; ;;
|
-r|--run ) run $@ ; ;;
|
||||||
--start ) if [[ "$EUID" -eq 0 ]]; then start_instance "$2"; else run_as_root $@; fi;;
|
--start ) if [[ "$EUID" -eq 0 ]]; then start_instance "$2"; else run_as_root $@; fi;;
|
||||||
--stop ) if [[ "$EUID" -eq 0 ]]; then stop_instance "$2"; else run_as_root $@; fi;;
|
--stop ) if [[ "$EUID" -eq 0 ]]; then stop_instance "$2"; else run_as_root $@; fi;;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
%global steamuser steam
|
||||||
|
|
||||||
Name: kf2-srv
|
Name: kf2-srv
|
||||||
Version: 0.2.1
|
Version: 0.3.0
|
||||||
Release: 1%{dist}
|
Release: 1%{dist}
|
||||||
Summary: Killing Floor 2 server
|
Summary: Killing Floor 2 server
|
||||||
Group: Amusements/Games
|
Group: Amusements/Games
|
||||||
@ -49,8 +51,8 @@ sed -i -r "s|^(InstallDir=).*$|\1\"%{_prefix}/games/%{name}\"|g" %{buildroot}/%{
|
|||||||
rm -rf $RPM_BUILD_ROOT
|
rm -rf $RPM_BUILD_ROOT
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%attr(775,root,root) %dir %{_prefix}/games/%{name}
|
%attr(775,root,%{steamuser}) %dir %{_prefix}/games/%{name}
|
||||||
%attr(755,root,root) %dir %{_sysconfdir}/%{name}
|
%attr(755,root,root) %dir %{_sysconfdir}/%{name}
|
||||||
%attr(644,root,root) %{_sysconfdir}/%{name}/main.conf.template
|
%attr(644,root,root) %{_sysconfdir}/%{name}/main.conf.template
|
||||||
%attr(644,root,root) %config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
|
%attr(644,root,root) %config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
|
||||||
%attr(644,root,root) %config(noreplace) %{_prefix}/lib/firewalld/services/%{name}.xml
|
%attr(644,root,root) %config(noreplace) %{_prefix}/lib/firewalld/services/%{name}.xml
|
||||||
@ -75,6 +77,11 @@ if [[ $1 -eq 0 ]] ; then # Uninstall
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Sep 20 2019 GenZmeY <genzmey@gmail.com> - 0.3.0-1
|
||||||
|
- validate option;
|
||||||
|
- auto validate on change active branch;
|
||||||
|
- port info on --status.
|
||||||
|
|
||||||
* Mon Sep 16 2019 GenZmeY <genzmey@gmail.com> - 0.2.1-1
|
* Mon Sep 16 2019 GenZmeY <genzmey@gmail.com> - 0.2.1-1
|
||||||
- --map-sync bugfixes.
|
- --map-sync bugfixes.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user