Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
03b40427af | |||
cf7cbbfc85 |
263
SOURCES/kf2-srv
263
SOURCES/kf2-srv
@ -18,21 +18,14 @@
|
|||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
source /etc/steamcmd/steamcmd.conf
|
source /etc/steamcmd/steamcmd.conf
|
||||||
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;}')
|
||||||
|
ScriptVersion="0.7.0"
|
||||||
|
|
||||||
AppNum="232130"
|
AppServerNum="232130"
|
||||||
|
AppClientNum="232090"
|
||||||
StrangeConstUID="17825793"
|
StrangeConstUID="17825793"
|
||||||
InstallDir="/usr/games/kf2-srv"
|
|
||||||
ActiveBranch="$InstallDir/activebranch.txt"
|
|
||||||
AppBin="$InstallDir/Binaries/Win64/KFGameSteamServer.bin.x86_64"
|
|
||||||
DefaultConfigDir="$InstallDir/KFGame/Config"
|
|
||||||
CustomMapsDir="$InstallDir/KFGame/Cache"
|
|
||||||
InstanceConfigDir="/etc/kf2-srv/instances"
|
|
||||||
InstanceConfigLnk="$DefaultConfigDir/instances"
|
|
||||||
MainConfigTemplate="/etc/kf2-srv/main.conf.template"
|
|
||||||
|
|
||||||
DiffArray=('Normal' 'Hard' 'Suicide' 'Hell')
|
DiffArray=('Normal' 'Hard' 'Suicide' 'Hell')
|
||||||
WaveArray=('4' '7' '10')
|
WaveArray=('4' '7' '10')
|
||||||
@ -46,10 +39,11 @@ ModeArray['KFGameContent.KFGameInfo_VersusSurvival']='Versus'
|
|||||||
function show_help ()
|
function show_help ()
|
||||||
{
|
{
|
||||||
# echo "TODO: English description"
|
# echo "TODO: English description"
|
||||||
echo "$ScriptName"
|
echo "$ScriptName v$ScriptVersion"
|
||||||
echo "Централизование управление серверами Killing Floor 2"
|
echo "Централизование управление серверами Killing Floor 2"
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo "$ScriptName OPTIONS"
|
echo "${ScriptName} OPTIONS stable branch"
|
||||||
|
echo "${ScriptName}-beta OPTIONS beta branch"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Mandatory arguments to long options are mandatory for short options too."
|
echo "Mandatory arguments to long options are mandatory for short options too."
|
||||||
echo " -n, --new INSTANCE создает новый ЭКЗЕМПЛЯР сервера"
|
echo " -n, --new INSTANCE создает новый ЭКЗЕМПЛЯР сервера"
|
||||||
@ -110,8 +104,12 @@ function show_help ()
|
|||||||
# Use this function with non-root user only!!!
|
# Use this function with non-root user only!!!
|
||||||
function run_as_root () # $*: Args
|
function run_as_root () # $*: Args
|
||||||
{
|
{
|
||||||
|
if [[ -n "$BetaPostfix" ]]; then
|
||||||
|
BetaPostfix="beta"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n $(groups "$USER" | grep -Fo 'wheel') ]]; then
|
if [[ -n $(groups "$USER" | grep -Fo 'wheel') ]]; then
|
||||||
sudo "$ScriptFullname" $*
|
sudo "$ScriptFullname" $BetaPostfix $*
|
||||||
else
|
else
|
||||||
echo "You must be root or sudo-user to run this command."
|
echo "You must be root or sudo-user to run this command."
|
||||||
return 1
|
return 1
|
||||||
@ -123,7 +121,7 @@ function service_name () # $*: Instance[s]
|
|||||||
local Services=""
|
local Services=""
|
||||||
for Instance in $*
|
for Instance in $*
|
||||||
do
|
do
|
||||||
Services+=" kf2-srv@$Instance.service"
|
Services+=" kf2-srv$BetaPostfix@$Instance.service"
|
||||||
done
|
done
|
||||||
echo "$Services"
|
echo "$Services"
|
||||||
}
|
}
|
||||||
@ -156,7 +154,7 @@ function instance_exists () # $1: Instance
|
|||||||
|
|
||||||
function server_exists ()
|
function server_exists ()
|
||||||
{
|
{
|
||||||
if [[ -n $(ls "$InstallDir") ]]; then
|
if [[ -x "$AppBin" ]]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
@ -165,8 +163,21 @@ function server_exists ()
|
|||||||
|
|
||||||
function updates_aviable ()
|
function updates_aviable ()
|
||||||
{
|
{
|
||||||
# TODO: implementation
|
# TODO: check
|
||||||
return 0
|
if [[ -n "$BetaPostfix" ]]; then
|
||||||
|
local BetaArg="-beta preview"
|
||||||
|
fi
|
||||||
|
if steamcmd +login anonymous \
|
||||||
|
+force_install_dir $InstallDir \
|
||||||
|
+app_info_update 1 \
|
||||||
|
+app_status $AppServerNum $BetaArg \
|
||||||
|
+quit | \
|
||||||
|
grep 'install state:' | \
|
||||||
|
grep -qiF 'Update Required'; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function new_instance () # $*: InstanceName[s]
|
function new_instance () # $*: InstanceName[s]
|
||||||
@ -202,20 +213,24 @@ function new_instance () # $*: InstanceName[s]
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local InstanceDir="$InstanceConfigDir/$Instance"
|
local InstanceDir="$InstanceConfigDir/$Instance"
|
||||||
install -d -g "$SteamUser" -o "$SteamUser" -m 755 "$InstanceDir"
|
|
||||||
install -d -g "$SteamUser" -o "$SteamUser" -m 755 "$InstanceDir/LinuxServer"
|
local DirMode="-d -g $SteamUser -o $SteamUser -m 775"
|
||||||
|
local FileMode=" -g $SteamUser -o $SteamUser -m 664"
|
||||||
|
|
||||||
|
install $DirMode "$InstanceDir"
|
||||||
|
install $DirMode "$InstanceDir/LinuxServer"
|
||||||
|
|
||||||
cp -a "$MainConfigTemplate" "$InstanceDir/main.conf"
|
install $FileMode "$MainConfigTemplate" "$InstanceDir/main.conf"
|
||||||
cp -a "$DefaultConfigDir/KFAI.ini" "$InstanceDir"
|
install $FileMode "$DefaultConfigDir/KFAI.ini" "$InstanceDir"
|
||||||
cp -a "$DefaultConfigDir/KFWeb.ini" "$InstanceDir"
|
install $FileMode "$DefaultConfigDir/KFWeb.ini" "$InstanceDir"
|
||||||
cp -a "$DefaultConfigDir/LinuxServer-KFEngine.ini" "$InstanceDir"
|
install $FileMode "$DefaultConfigDir/LinuxServer-KFEngine.ini" "$InstanceDir"
|
||||||
cp -a "$DefaultConfigDir/LinuxServer-KFGame.ini" "$InstanceDir"
|
install $FileMode "$DefaultConfigDir/LinuxServer-KFGame.ini" "$InstanceDir"
|
||||||
cp -a "$DefaultConfigDir/LinuxServer-KFInput.ini" "$InstanceDir"
|
install $FileMode "$DefaultConfigDir/LinuxServer-KFInput.ini" "$InstanceDir"
|
||||||
cp -a "$DefaultConfigDir/LinuxServer-KFSystemSettings.ini" "$InstanceDir"
|
install $FileMode "$DefaultConfigDir/LinuxServer-KFSystemSettings.ini" "$InstanceDir"
|
||||||
cp -a "$DefaultConfigDir/LinuxServer/LinuxServerEngine.ini" "$InstanceDir/LinuxServer"
|
install $FileMode "$DefaultConfigDir/LinuxServer/LinuxServerEngine.ini" "$InstanceDir/LinuxServer"
|
||||||
cp -a "$DefaultConfigDir/LinuxServer/LinuxServerGame.ini" "$InstanceDir/LinuxServer"
|
install $FileMode "$DefaultConfigDir/LinuxServer/LinuxServerGame.ini" "$InstanceDir/LinuxServer"
|
||||||
cp -a "$DefaultConfigDir/LinuxServer/LinuxServerInput.ini" "$InstanceDir/LinuxServer"
|
install $FileMode "$DefaultConfigDir/LinuxServer/LinuxServerInput.ini" "$InstanceDir/LinuxServer"
|
||||||
cp -a "$DefaultConfigDir/LinuxServer/LinuxServerSystemSettings.ini" "$InstanceDir/LinuxServer"
|
install $FileMode "$DefaultConfigDir/LinuxServer/LinuxServerSystemSettings.ini" "$InstanceDir/LinuxServer"
|
||||||
|
|
||||||
((MaxGamePort++)); ((MaxQueryPort++)); ((MaxWebAdminPort++))
|
((MaxGamePort++)); ((MaxQueryPort++)); ((MaxWebAdminPort++))
|
||||||
|
|
||||||
@ -223,7 +238,7 @@ function new_instance () # $*: InstanceName[s]
|
|||||||
sed -i -r --follow-symlinks "s/-queryport=[0-9]+/-queryport=$MaxQueryPort/g" "$InstanceDir/main.conf"
|
sed -i -r --follow-symlinks "s/-queryport=[0-9]+/-queryport=$MaxQueryPort/g" "$InstanceDir/main.conf"
|
||||||
sed -i -r --follow-symlinks "s/-webadminport=[0-9]+/-webadminport=$MaxWebAdminPort/g" "$InstanceDir/main.conf"
|
sed -i -r --follow-symlinks "s/-webadminport=[0-9]+/-webadminport=$MaxWebAdminPort/g" "$InstanceDir/main.conf"
|
||||||
|
|
||||||
echo "Instance $Instance created. See /etc/$ScriptName/instances/$Instance for edit configuration"
|
echo "Instance $Instance created. See /etc/$ScriptName/instances$BetaPostfix/$Instance for edit configuration"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,36 +338,55 @@ function show_status () # $*: [InstanceName[s]]
|
|||||||
|
|
||||||
function validate ()
|
function validate ()
|
||||||
{
|
{
|
||||||
if [[ -n "$BranchName" ]]; then
|
if [[ -n "$BetaPostfix" ]]; then
|
||||||
local BetaArg="-beta $BranchName"
|
local BetaArg="-beta preview"
|
||||||
fi
|
fi
|
||||||
stop_instance
|
stop_instance
|
||||||
steamcmd +login $SteamLogin +force_install_dir $InstallDir +app_update $AppNum $BetaArg validate +exit
|
steamcmd +login $SteamLogin +force_install_dir $InstallDir +app_update $AppServerNum $BetaArg validate +exit
|
||||||
echo "$BranchName" > "$ActiveBranch"
|
|
||||||
start_instance
|
start_instance
|
||||||
}
|
}
|
||||||
|
|
||||||
function link_default_instance ()
|
function make_default_instance ()
|
||||||
{
|
{
|
||||||
local Instance="default"
|
local InstanceDir="$InstanceConfigDir/default"
|
||||||
if instance_exists "$Instance"; then
|
|
||||||
echo "Instance $Instance already exists - skip"
|
chmod 664 \
|
||||||
else
|
"$DefaultConfigDir/KFAI.ini" \
|
||||||
local InstanceDir="$InstanceConfigDir/$Instance"
|
"$DefaultConfigDir/KFWeb.ini" \
|
||||||
install -d -g "$SteamUser" -o "$SteamUser" -m 755 "$InstanceDir"
|
"$DefaultConfigDir/LinuxServer-KFEngine.ini" \
|
||||||
install -d -g "$SteamUser" -o "$SteamUser" -m 755 "$InstanceDir/LinuxServer"
|
"$DefaultConfigDir/LinuxServer-KFGame.ini" \
|
||||||
cp -a "$MainConfigTemplate" "$InstanceDir/main.conf"
|
"$DefaultConfigDir/LinuxServer-KFInput.ini" \
|
||||||
ln -s "$DefaultConfigDir/KFAI.ini" "$InstanceDir/KFAI.ini"
|
"$DefaultConfigDir/LinuxServer-KFSystemSettings.ini" \
|
||||||
ln -s "$DefaultConfigDir/KFWeb.ini" "$InstanceDir/KFWeb.ini"
|
"$DefaultConfigDir/LinuxServer/LinuxServerEngine.ini" \
|
||||||
ln -s "$DefaultConfigDir/LinuxServer-KFEngine.ini" "$InstanceDir/LinuxServer-KFEngine.ini"
|
"$DefaultConfigDir/LinuxServer/LinuxServerGame.ini" \
|
||||||
ln -s "$DefaultConfigDir/LinuxServer-KFGame.ini" "$InstanceDir/LinuxServer-KFGame.ini"
|
"$DefaultConfigDir/LinuxServer/LinuxServerInput.ini" \
|
||||||
ln -s "$DefaultConfigDir/LinuxServer-KFInput.ini" "$InstanceDir/LinuxServer-KFInput.ini"
|
"$DefaultConfigDir/LinuxServer/LinuxServerSystemSettings.ini"
|
||||||
ln -s "$DefaultConfigDir/LinuxServer-KFSystemSettings.ini" "$InstanceDir/LinuxServer-KFSystemSettings.ini"
|
|
||||||
ln -s "$DefaultConfigDir/LinuxServer/LinuxServerEngine.ini" "$InstanceDir/LinuxServer/LinuxServerEngine.ini"
|
dos2unix \
|
||||||
ln -s "$DefaultConfigDir/LinuxServer/LinuxServerGame.ini" "$InstanceDir/LinuxServer/LinuxServerGame.ini"
|
"$DefaultConfigDir/KFAI.ini" \
|
||||||
ln -s "$DefaultConfigDir/LinuxServer/LinuxServerInput.ini" "$InstanceDir/LinuxServer/LinuxServerInput.ini"
|
"$DefaultConfigDir/KFWeb.ini" \
|
||||||
ln -s "$DefaultConfigDir/LinuxServer/LinuxServerSystemSettings.ini" "$InstanceDir/LinuxServer/LinuxServerSystemSettings.ini"
|
"$DefaultConfigDir/LinuxServer-KFEngine.ini" \
|
||||||
fi
|
"$DefaultConfigDir/LinuxServer-KFGame.ini" \
|
||||||
|
"$DefaultConfigDir/LinuxServer-KFInput.ini" \
|
||||||
|
"$DefaultConfigDir/LinuxServer-KFSystemSettings.ini" \
|
||||||
|
"$DefaultConfigDir/LinuxServer/LinuxServerEngine.ini" \
|
||||||
|
"$DefaultConfigDir/LinuxServer/LinuxServerGame.ini" \
|
||||||
|
"$DefaultConfigDir/LinuxServer/LinuxServerInput.ini" \
|
||||||
|
"$DefaultConfigDir/LinuxServer/LinuxServerSystemSettings.ini"
|
||||||
|
|
||||||
|
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 "$MainConfigTemplate" "$InstanceDir/main.conf"
|
||||||
|
ln -s "$DefaultConfigDir/KFAI.ini" "$InstanceDir/KFAI.ini"
|
||||||
|
ln -s "$DefaultConfigDir/KFWeb.ini" "$InstanceDir/KFWeb.ini"
|
||||||
|
ln -s "$DefaultConfigDir/LinuxServer-KFEngine.ini" "$InstanceDir/LinuxServer-KFEngine.ini"
|
||||||
|
ln -s "$DefaultConfigDir/LinuxServer-KFGame.ini" "$InstanceDir/LinuxServer-KFGame.ini"
|
||||||
|
ln -s "$DefaultConfigDir/LinuxServer-KFInput.ini" "$InstanceDir/LinuxServer-KFInput.ini"
|
||||||
|
ln -s "$DefaultConfigDir/LinuxServer-KFSystemSettings.ini" "$InstanceDir/LinuxServer-KFSystemSettings.ini"
|
||||||
|
ln -s "$DefaultConfigDir/LinuxServer/LinuxServerEngine.ini" "$InstanceDir/LinuxServer/LinuxServerEngine.ini"
|
||||||
|
ln -s "$DefaultConfigDir/LinuxServer/LinuxServerGame.ini" "$InstanceDir/LinuxServer/LinuxServerGame.ini"
|
||||||
|
ln -s "$DefaultConfigDir/LinuxServer/LinuxServerInput.ini" "$InstanceDir/LinuxServer/LinuxServerInput.ini"
|
||||||
|
ln -s "$DefaultConfigDir/LinuxServer/LinuxServerSystemSettings.ini" "$InstanceDir/LinuxServer/LinuxServerSystemSettings.ini"
|
||||||
}
|
}
|
||||||
|
|
||||||
function fix_steamclient_so ()
|
function fix_steamclient_so ()
|
||||||
@ -365,14 +399,44 @@ function fix_steamclient_so ()
|
|||||||
ln -s "/usr/share/steamcmd/linux64/steamclient.so" "$InstallDir/Binaries/Win64/lib64/steamclient.so"
|
ln -s "/usr/share/steamcmd/linux64/steamclient.so" "$InstallDir/Binaries/Win64/lib64/steamclient.so"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_map_dirs ()
|
||||||
|
{
|
||||||
|
# space saving
|
||||||
|
local InstallDirOrig="/usr/games/kf2-srv"
|
||||||
|
local InstallDirBeta="/usr/games/kf2-srv-beta"
|
||||||
|
local DownloadMapsDirOrig="$InstallDirOrig/Binaries/Win64/steamapps/workshop/content/$AppClientNum"
|
||||||
|
local CacheMapsDirOrig="$InstallDirOrig/KFGame/Cache"
|
||||||
|
local DownloadMapsDirBeta="$InstallDirBeta/Binaries/Win64/steamapps/workshop/content/$AppClientNum"
|
||||||
|
local CacheMapsDirBeta="$InstallDirBeta/KFGame/Cache"
|
||||||
|
|
||||||
|
if [[ -z "$BetaPostfix" ]]; then # Orig
|
||||||
|
sudo -u "$SteamUser" install -d -m 775 "$DownloadMapsDirOrig"
|
||||||
|
if [[ -d "$CacheMapsDirBeta" ]]; then
|
||||||
|
ln -s "$CacheMapsDirBeta" "$CacheMapsDirOrig"
|
||||||
|
rm -rf "$DownloadMapsDirOrig"
|
||||||
|
ln -s "$DownloadMapsDirBeta" "$DownloadMapsDirOrig"
|
||||||
|
else
|
||||||
|
sudo -u "$SteamUser" install -d -m 775 "$CacheMapsDirOrig"
|
||||||
|
fi
|
||||||
|
else # Beta
|
||||||
|
sudo -u "$SteamUser" install -d -m 775 "$DownloadMapsDirBeta"
|
||||||
|
if [[ -d "$CacheMapsDirOrig" ]]; then
|
||||||
|
ln -s "$CacheMapsDirOrig" "$CacheMapsDirBeta"
|
||||||
|
rm -rf "$DownloadMapsDirBeta"
|
||||||
|
ln -s "$DownloadMapsDirOrig" "$DownloadMapsDirBeta"
|
||||||
|
else
|
||||||
|
sudo -u "$SteamUser" install -d -m 775 "$CacheMapsDirBeta"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function update_kf2 ()
|
function update_kf2 ()
|
||||||
{
|
{
|
||||||
if [[ -n "$BranchName" ]]; then
|
if [[ -n "$BetaPostfix" ]]; then
|
||||||
local BetaArg="-beta $BranchName"
|
local BetaArg="-beta preview"
|
||||||
fi
|
fi
|
||||||
if ! server_exists; then # First install
|
if ! server_exists; then # First install
|
||||||
echo "$BranchName" > "$ActiveBranch"
|
if ! steamcmd +login $SteamLogin +force_install_dir $InstallDir +app_update $AppServerNum $BetaArg validate +exit; then
|
||||||
if ! steamcmd +login $SteamLogin +force_install_dir $InstallDir +app_update $AppNum $BetaArg validate +exit; then
|
|
||||||
echo "Errors during installation - exit"
|
echo "Errors during installation - exit"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -392,23 +456,18 @@ function update_kf2 ()
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
sleep 2
|
sleep 2
|
||||||
|
# TODO: KFWeb.ini > webadmin=true
|
||||||
done
|
done
|
||||||
killall -KILL KFGameSteamServer.bin.x86_64
|
killall -KILL KFGameSteamServer.bin.x86_64
|
||||||
#$InstallDir/Binaries/Win64/steamapps/workshop/content/232090/1078911795/BrewedPC/Maps/KF-HorzineArena-B2-v6.kfm
|
create_map_dirs
|
||||||
#$InstallDir/KFGame/Cache/1078911795/0/BrewedPC/Maps/KF-HorzineArena-B2-v6.kfm
|
|
||||||
install -d -g "$SteamUser" -o "$SteamUser" -m 755 "$CustomMapsDir"
|
|
||||||
fix_steamclient_so
|
fix_steamclient_so
|
||||||
ln -s "$InstanceConfigDir" "$InstanceConfigLnk"
|
ln -s "$InstanceConfigDir" "$InstanceConfigLnk"
|
||||||
link_default_instance
|
make_default_instance
|
||||||
echo "KF2 succesfully installed"
|
echo "KF2 succesfully installed"
|
||||||
elif updates_aviable; then # Update
|
elif updates_aviable; then # Update
|
||||||
if [[ "$BranchName" == $(cat "$ActiveBranch") ]]; then
|
stop_instance
|
||||||
stop_instance
|
steamcmd +login $SteamLogin +force_install_dir $InstallDir +app_update $AppServerNum $BetaArg +exit
|
||||||
steamcmd +login $SteamLogin +force_install_dir $InstallDir +app_update $AppNum $BetaArg +exit
|
start_instance
|
||||||
start_instance
|
|
||||||
else
|
|
||||||
validate
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -548,30 +607,44 @@ function run ()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function map_list_ext () # $1: MaplistFile
|
function map_list_body () # $1: MaplistFile
|
||||||
{
|
{
|
||||||
local Num=1
|
|
||||||
echo "NUM WORKSHOP_ID WORKSHOP_URL"
|
|
||||||
while read WorkshopID
|
while read WorkshopID
|
||||||
do
|
do
|
||||||
|
local Cache="$CacheMapsDir/$WorkshopID"
|
||||||
|
local Downl="$DownloadMapsDir/$WorkshopID"
|
||||||
local Url="https://steamcommunity.com/sharedfiles/filedetails/?id=$WorkshopID"
|
local Url="https://steamcommunity.com/sharedfiles/filedetails/?id=$WorkshopID"
|
||||||
echo "$Num $WorkshopID $Url"
|
if [[ -d "$Cache" ]]; then
|
||||||
((Num++))
|
local MapName=$(find "$Cache" -type f -name '*.kfm' -printf '%f\n' | head -n 1)
|
||||||
|
else
|
||||||
|
local MapName=""
|
||||||
|
fi
|
||||||
|
if [[ -n "$MapName" ]]; then
|
||||||
|
local MapSize=$(du -sch "$Downl" "$Cache" | tail -n 1 | grep -Po '^[^\s]+')
|
||||||
|
else
|
||||||
|
local MapSize="-"; MapName="-"
|
||||||
|
fi
|
||||||
|
echo "$MapName $MapSize $WorkshopID $Url"
|
||||||
done < "$1"
|
done < "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function map_list_full () # $1: MaplistFile
|
||||||
|
{
|
||||||
|
echo "NAME SIZE WORKSHOP_ID WORKSHOP_URL"
|
||||||
|
map_list_body "$1" | sort -k 1
|
||||||
|
}
|
||||||
|
|
||||||
function map_list () # $1: [--human-readable]
|
function map_list () # $1: [--human-readable]
|
||||||
{
|
{
|
||||||
# TODO: Show map names (sizes?)
|
|
||||||
local MapList=$(mktemp)
|
local MapList=$(mktemp)
|
||||||
for Instance in $(show_instances)
|
for Instance in $(show_instances)
|
||||||
do
|
do
|
||||||
local Config="$InstanceConfigDir/$Instance/LinuxServer-KFEngine.ini"
|
local Config="$InstanceConfigDir/$Instance/LinuxServer-KFEngine.ini"
|
||||||
grep -P 'ServerSubscribedWorkshopItems=' "$Config" | sed -r 's/.+=([0-9]+)$/\1/' >> "$MapList"
|
grep -F 'ServerSubscribedWorkshopItems=' "$Config" | sed -r 's/^.+=([0-9]+)$/\1/' >> "$MapList"
|
||||||
done
|
done
|
||||||
sort -u "$MapList" -o "$MapList"
|
sort -u "$MapList" -o "$MapList"
|
||||||
if [[ -n "$1" ]]; then
|
if [[ -n "$1" ]]; then
|
||||||
map_list_ext "$MapList" | column -t
|
map_list_full "$MapList" | column -t
|
||||||
else
|
else
|
||||||
cat "$MapList"
|
cat "$MapList"
|
||||||
fi
|
fi
|
||||||
@ -616,10 +689,17 @@ function map_add () # $*: WorkshopID[s]
|
|||||||
|
|
||||||
function map_del () # $*: WorkshopID[s]
|
function map_del () # $*: WorkshopID[s]
|
||||||
{
|
{
|
||||||
# TODO: Remove lines from LinuxServer-KFGame.ini, clear cache
|
# TODO: Remove lines from LinuxServer-KFGame.ini
|
||||||
|
# I need "crudini" with duplicate keys support >_<
|
||||||
for Map in $*
|
for Map in $*
|
||||||
do
|
do
|
||||||
local WorkshopID=$(any_to_workshopID "$Map")
|
local WorkshopID=$(any_to_workshopID "$Map")
|
||||||
|
local Cache="$CacheMapsDir/$WorkshopID"
|
||||||
|
local Downl="$DownloadMapsDir/$WorkshopID"
|
||||||
|
echo -e "Clear cache:
|
||||||
|
$Cache
|
||||||
|
$Downl"
|
||||||
|
rm -rf "$Cache" "$Downl"
|
||||||
for Instance in $(show_instances)
|
for Instance in $(show_instances)
|
||||||
do
|
do
|
||||||
local Config="$InstanceConfigDir/$Instance/LinuxServer-KFEngine.ini"
|
local Config="$InstanceConfigDir/$Instance/LinuxServer-KFEngine.ini"
|
||||||
@ -634,25 +714,19 @@ function map_del () # $*: WorkshopID[s]
|
|||||||
|
|
||||||
function map_sync ()
|
function map_sync ()
|
||||||
{
|
{
|
||||||
#local InstanceList="$*"
|
|
||||||
#if [[ -z "$InstanceList" ]] ; then
|
|
||||||
# InstanceList=$(show_instances)
|
|
||||||
#fi
|
|
||||||
map_add $(map_list)
|
map_add $(map_list)
|
||||||
|
|
||||||
for Instance in $(show_instances)
|
for Instance in $(show_instances)
|
||||||
do
|
do
|
||||||
if instance_exists "$Instance"; then
|
if instance_exists "$Instance"; then
|
||||||
local Config="$InstanceConfigDir/$Instance/LinuxServer-KFGame.ini"
|
local Config="$InstanceConfigDir/$Instance/LinuxServer-KFGame.ini"
|
||||||
for MapFile in $(find "$CustomMapsDir" -type f -name '*.kfm' -printf "%f\n")
|
for MapFile in $(find -L "$CacheMapsDir" -type f -name '*.kfm' -printf "%f\n")
|
||||||
do
|
do
|
||||||
MapName=$(echo "$MapFile" | sed -r 's|.kfm$||g')
|
MapName=$(echo "$MapFile" | sed -r 's|.kfm$||g')
|
||||||
if [[ ! -f "$Config" ]]; then
|
if [[ ! -f "$Config" ]]; then
|
||||||
echo "$Config does not exist!"
|
echo "$Config does not exist!"
|
||||||
elif grep -qP "MapName=$MapName[ ]*$" "$Config"; then
|
elif ! grep -qP "MapName=$MapName[ ]*$" "$Config"; then
|
||||||
echo "$MapName is already in $Config."
|
echo "Adding $MapName to $Instance."
|
||||||
else
|
|
||||||
echo "Adding $MapName to $Config."
|
|
||||||
echo -e "
|
echo -e "
|
||||||
[$MapName KFMapSummary]
|
[$MapName KFMapSummary]
|
||||||
MapName=$MapName
|
MapName=$MapName
|
||||||
@ -842,6 +916,19 @@ function ban_sync ()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [[ "$1" == "beta" ]]; then
|
||||||
|
BetaPostfix="-beta"; shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
InstallDir="/usr/games/kf2-srv$BetaPostfix"
|
||||||
|
AppBin="$InstallDir/Binaries/Win64/KFGameSteamServer.bin.x86_64"
|
||||||
|
DefaultConfigDir="$InstallDir/KFGame/Config"
|
||||||
|
DownloadMapsDir="$InstallDir/Binaries/Win64/steamapps/workshop/content/$AppClientNum"
|
||||||
|
CacheMapsDir="$InstallDir/KFGame/Cache"
|
||||||
|
InstanceConfigDir="/etc/kf2-srv/instances$BetaPostfix"
|
||||||
|
InstanceConfigLnk="$DefaultConfigDir/instances"
|
||||||
|
MainConfigTemplate="/etc/kf2-srv/main.conf.template"
|
||||||
|
|
||||||
if [[ $# -eq 0 ]]; then show_help; exit 0; fi
|
if [[ $# -eq 0 ]]; then show_help; exit 0; fi
|
||||||
case $1 in
|
case $1 in
|
||||||
-h|--help ) show_help; ;;
|
-h|--help ) show_help; ;;
|
||||||
|
3
SOURCES/kf2-srv-beta
Normal file
3
SOURCES/kf2-srv-beta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
/usr/bin/kf2-srv beta $*
|
14
SOURCES/kf2-srv-beta-update.service
Normal file
14
SOURCES/kf2-srv-beta-update.service
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Check and Update Killing Floor 2 server
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/bin/kf2-srv-beta --update
|
||||||
|
|
||||||
|
PrivateTmp=true
|
||||||
|
PrivateDevices=true
|
||||||
|
ProtectHome=false
|
||||||
|
ProtectSystem=false
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
9
SOURCES/kf2-srv-beta-update.timer
Normal file
9
SOURCES/kf2-srv-beta-update.timer
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Check and Update killing Floor 2 beta job
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=*-*-* 4:00:00
|
||||||
|
Unit=kf2-srv-beta-update.service
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
21
SOURCES/kf2-srv-beta@.service
Normal file
21
SOURCES/kf2-srv-beta@.service
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Killing Floor 2 Beta Server Daemon - %i
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=steam
|
||||||
|
Group=steam
|
||||||
|
Type=simple
|
||||||
|
StandardOutput=null
|
||||||
|
StandardError=null
|
||||||
|
EnvironmentFile=/etc/kf2-srv/instances-beta/%i/main.conf
|
||||||
|
ExecStart=/usr/games/kf2-srv-beta/Binaries/Win64/KFGameSteamServer.bin.x86_64 $Args configsubdir=instances/%i $PortW $PortQ $PortG
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
NoNewPrivileges=yes
|
||||||
|
PrivateTmp=true
|
||||||
|
PrivateDevices=true
|
||||||
|
ProtectHome=true
|
||||||
|
ProtectSystem=false
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
@ -2,7 +2,7 @@
|
|||||||
Description=Check and Update killing Floor 2 job
|
Description=Check and Update killing Floor 2 job
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnCalendar=Wed, 04:00
|
OnCalendar=*-*-* 4:00:00
|
||||||
Unit=kf2-srv-update.service
|
Unit=kf2-srv-update.service
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
%global steamuser steam
|
%global steamuser steam
|
||||||
|
|
||||||
Name: kf2-srv
|
Name: kf2-srv
|
||||||
Version: 0.5.0
|
Version: 0.7.0
|
||||||
Release: 1%{dist}
|
Release: 1%{dist}
|
||||||
Summary: Killing Floor 2 server
|
Summary: Killing Floor 2 server
|
||||||
Group: Amusements/Games
|
Group: Amusements/Games
|
||||||
@ -9,16 +9,28 @@ License: GNU GPLv3
|
|||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
Source1: %{name}
|
Source1: %{name}
|
||||||
Source2: %{name}.conf
|
Source2: %{name}-beta
|
||||||
Source3: %{name}.xml
|
Source3: %{name}.xml
|
||||||
Source4: %{name}@.service
|
Source4: %{name}@.service
|
||||||
Source5: %{name}-update.service
|
Source5: %{name}-update.service
|
||||||
Source6: %{name}-update.timer
|
Source6: %{name}-update.timer
|
||||||
Source7: main.conf.template
|
Source7: main.conf.template
|
||||||
|
Source8: %{name}-beta@.service
|
||||||
|
Source9: %{name}-beta-update.service
|
||||||
|
Source10: %{name}-beta-update.timer
|
||||||
|
|
||||||
Requires: systemd >= 219
|
Requires: systemd >= 219
|
||||||
Requires: steamcmd
|
Requires: steamcmd
|
||||||
Requires: libxml2
|
Requires: libxml2
|
||||||
|
Requires: dos2unix
|
||||||
|
Requires: curl
|
||||||
|
Requires: grep
|
||||||
|
Requires: coreutils
|
||||||
|
Requires: sed
|
||||||
|
Requires: util-linux
|
||||||
|
Requires: sudo
|
||||||
|
Requires: psmisc
|
||||||
|
Requires: gawk
|
||||||
|
|
||||||
Provides: %{name}
|
Provides: %{name}
|
||||||
|
|
||||||
@ -36,47 +48,59 @@ install -m 755 -d %{buildroot}/%{_bindir}
|
|||||||
install -m 755 -d %{buildroot}/%{_prefix}/lib/systemd/system
|
install -m 755 -d %{buildroot}/%{_prefix}/lib/systemd/system
|
||||||
install -m 755 -d %{buildroot}/%{_prefix}/lib/firewalld/services
|
install -m 755 -d %{buildroot}/%{_prefix}/lib/firewalld/services
|
||||||
install -m 755 -d %{buildroot}/%{_sysconfdir}/%{name}/instances
|
install -m 755 -d %{buildroot}/%{_sysconfdir}/%{name}/instances
|
||||||
|
install -m 755 -d %{buildroot}/%{_sysconfdir}/%{name}/instances-beta
|
||||||
install -m 644 -d %{buildroot}/%{_prefix}/games/%{name}
|
install -m 644 -d %{buildroot}/%{_prefix}/games/%{name}
|
||||||
|
install -m 644 -d %{buildroot}/%{_prefix}/games/%{name}-beta
|
||||||
|
|
||||||
install -m 755 %{SOURCE1} %{buildroot}/%{_bindir}
|
install -m 755 %{SOURCE1} %{buildroot}/%{_bindir}
|
||||||
install -m 644 %{SOURCE2} %{buildroot}/%{_sysconfdir}/%{name}
|
install -m 644 %{SOURCE2} %{buildroot}/%{_bindir}
|
||||||
install -m 644 %{SOURCE3} %{buildroot}/%{_prefix}/lib/firewalld/services
|
install -m 644 %{SOURCE3} %{buildroot}/%{_prefix}/lib/firewalld/services
|
||||||
install -m 644 %{SOURCE4} %{buildroot}/%{_prefix}/lib/systemd/system
|
install -m 644 %{SOURCE4} %{buildroot}/%{_prefix}/lib/systemd/system
|
||||||
install -m 644 %{SOURCE5} %{buildroot}/%{_prefix}/lib/systemd/system
|
install -m 644 %{SOURCE5} %{buildroot}/%{_prefix}/lib/systemd/system
|
||||||
install -m 644 %{SOURCE6} %{buildroot}/%{_prefix}/lib/systemd/system
|
install -m 644 %{SOURCE6} %{buildroot}/%{_prefix}/lib/systemd/system
|
||||||
install -m 644 %{SOURCE7} %{buildroot}/%{_sysconfdir}/%{name}
|
install -m 644 %{SOURCE7} %{buildroot}/%{_sysconfdir}/%{name}
|
||||||
|
install -m 644 %{SOURCE8} %{buildroot}/%{_prefix}/lib/systemd/system
|
||||||
sed -i -r "s|^(InstallDir=).*$|\1\"%{_prefix}/games/%{name}\"|g" %{buildroot}/%{_bindir}/%{name}
|
install -m 644 %{SOURCE9} %{buildroot}/%{_prefix}/lib/systemd/system
|
||||||
|
install -m 644 %{SOURCE10} %{buildroot}/%{_prefix}/lib/systemd/system
|
||||||
|
|
||||||
%clean
|
%clean
|
||||||
rm -rf $RPM_BUILD_ROOT
|
rm -rf $RPM_BUILD_ROOT
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%attr(775,root,%{steamuser}) %dir %{_prefix}/games/%{name}
|
%attr(775,root,%{steamuser}) %dir %{_prefix}/games/%{name}
|
||||||
|
%attr(775,root,%{steamuser}) %dir %{_prefix}/games/%{name}-beta
|
||||||
%attr(775,root,%{steamuser}) %dir %{_sysconfdir}/%{name}
|
%attr(775,root,%{steamuser}) %dir %{_sysconfdir}/%{name}
|
||||||
%attr(775,root,%{steamuser}) %dir %{_sysconfdir}/%{name}/instances
|
%attr(775,root,%{steamuser}) %dir %{_sysconfdir}/%{name}/instances
|
||||||
%attr(644,root,root) %{_sysconfdir}/%{name}/main.conf.template
|
%attr(775,root,%{steamuser}) %dir %{_sysconfdir}/%{name}/instances-beta
|
||||||
%attr(644,root,root) %config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
|
%attr(644,root,root) %config(noreplace) %{_sysconfdir}/%{name}/main.conf.template
|
||||||
%attr(644,root,root) %config(noreplace) %{_prefix}/lib/firewalld/services/%{name}.xml
|
%attr(644,root,root) %config(noreplace) %{_prefix}/lib/firewalld/services/%{name}.xml
|
||||||
%attr(755,root,root) %{_bindir}/%{name}
|
%attr(755,root,root) %{_bindir}/%{name}
|
||||||
|
%attr(755,root,root) %{_bindir}/%{name}-beta
|
||||||
%attr(644,root,root) %{_prefix}/lib/systemd/system/*
|
%attr(644,root,root) %{_prefix}/lib/systemd/system/*
|
||||||
|
|
||||||
%post
|
|
||||||
#/bin/env bash
|
|
||||||
#if [[ $1 -eq 1 ]]; then # First installation
|
|
||||||
#
|
|
||||||
#fi
|
|
||||||
#exit 0
|
|
||||||
|
|
||||||
%preun
|
%preun
|
||||||
#/bin/env bash
|
|
||||||
if [[ $1 -eq 0 ]] ; then # Uninstall
|
if [[ $1 -eq 0 ]] ; then # Uninstall
|
||||||
%{_bindir}/%{name} --stop
|
%{_bindir}/%{name} --stop
|
||||||
%{_bindir}/%{name} --disable
|
%{_bindir}/%{name} --disable
|
||||||
rm -rf %{_prefix}/games/%{name}/*
|
rm -rf %{_prefix}/games/%{name}/*
|
||||||
|
rm -rf %{_prefix}/games/%{name}-beta/*
|
||||||
|
rm -rf %{_sysconfdir}/%{name}/instances/default
|
||||||
|
rm -rf %{_sysconfdir}/%{name}/instances-beta/default
|
||||||
fi
|
fi
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sat Mar 7 2020 GenZmeY <genzmey@gmail.com> - 0.7.0-1
|
||||||
|
- dual versions support;
|
||||||
|
- check updates;
|
||||||
|
- bugfixes.
|
||||||
|
|
||||||
|
* Sat Jan 18 2020 GenZmeY <genzmey@gmail.com> - 0.6.0-1
|
||||||
|
- versions;
|
||||||
|
- instance conf tweaks;
|
||||||
|
- extended map list;
|
||||||
|
- clear cache on delete map;
|
||||||
|
- removed useless messages.
|
||||||
|
|
||||||
* Sun Jan 12 2020 GenZmeY <genzmey@gmail.com> - 0.5.0-1
|
* Sun Jan 12 2020 GenZmeY <genzmey@gmail.com> - 0.5.0-1
|
||||||
- ban admin;
|
- ban admin;
|
||||||
- map admin;
|
- map admin;
|
||||||
|
Reference in New Issue
Block a user