Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Обновлён arma3server-tolower.sh #8

Merged
merged 8 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 46 additions & 20 deletions arma3server-tolower.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,52 @@
#!/bin/bash
# Скрипт создает в новой директории символьные ссылки в нижнем регистре на файлы.

# Права на запуск...
# chmod +x ~/bin/arma3server-tolower.sh
# Запуск...
# GAME=~/arma3 SERVER=~/arma3lower ~/bin/arma3server-tolower.sh
#####
# Скрипт создает в директории сервера символьные ссылки
# в нижнем регистре на отсутствующие у сервера файлы игры.
#
# Запуск
# GAME="путь/к/a2oa" SERVER="путь/к/серверу" ./arma3server-tolower.sh
#
# После обновления игры могут появиться битые ссылки
# на отсутствующие файлы, их нужно удалять.
#####

IFS=$'\n'

cd ${GAME}
if cd ${GAME}
then
mkdir -p ${SERVER}

for DIR in $(find ./ -type d)
do
if [ ! -d ${SERVER}/${DIR,,} ]
then
mkdir -p ${SERVER}/${DIR,,}
fi
done
array=( $(find -L . -not \( -path "./steamapps/common/*" -prune \) \
-not \( -path "*/shadercache/*" -prune \) \
-not \( -path "*/steamapps/compatdata/*" -prune \) \
-not \( -path "*download*" -prune \) \
-not \( -path "*/temp/*" -prune \) \
-not \( -path "*/.wine/*" -prune \) \
-not \( -path "*/.proton/*" -prune \) \
-type d ) )
for i in "${array[@]}"
do
if [ ! -d ${SERVER}/${i,,} ]
then
mkdir ${SERVER}/${i,,}
fi
done

for FILE in $(find ./ -type f ! -path "./ACR/*" ! -path "./PMC/*" ! -path "./BAF/*" ! -path "./DirectX/*" ! -path "./BEsetup/*")
do
if [ ! -f ${SERVER}/${FILE,,} ] && [ ! -L ${SERVER}/${FILE,,} ]
then
ln -s ${GAME}/${FILE} ${SERVER}/${FILE,,}
fi
done
array=( $(find -L . -not \( -path "./steamapps/common/*" -prune \) \
-not \( -path "*/shadercache/*" -prune \) \
-not \( -path "*/steamapps/compatdata/*" -prune \) \
-not \( -path "*download*" -prune \) \
-not \( -path "*/temp/*" -prune \) \
-not \( -path "*/.wine/*" -prune \) \
-not \( -path "*/.proton/*" -prune \) \
-not \( -iname "appmanifest*.tmp" -prune \) \
-type f ) )
for i in "${array[@]}"
do
if [ ! -f ${SERVER}/${i,,} ] && [ ! -L ${SERVER}/${i,,} ]
then
ln -s ${GAME}/${i} ${SERVER}/${i,,}
fi
done
fi
29 changes: 29 additions & 0 deletions keys-arma.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

# cd ~/arma3

# CBA вожможно не приводит к ошибкам.
# terrains, maps вожможно не приводят к ошибкам.
find -L . \
\( \
-not \( -path "*cache*" -prune \) \
-not \( -path "*compatdata*" -prune \) \
-not \( -path "*download*" -prune \) \
-not \( -path "*temp*" -prune \) \
-not \( -path "*wine*" -prune \) \
-not \( -path "*proton*" -prune \) \
\) -and \
\( \
-path '*workshop*' -or \
-path '*addon*' -or \
-path '*mod*' -or \
-path "*/steamapps/common/*" \
\) -and \
\( \
-iname '*map*.bikey' -or \
-iname '*terrain*.bikey' -or \
-iname 'ibr_panthera*.bikey' -or \
-iname '*cba*.bikey' \
\) \
-print \
-exec ln -s {} ./keys/ \;
2 changes: 1 addition & 1 deletion missions-split-hc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ do
fi
fi

if [[ $(find ${dir} -maxdepth 2 -iname "Mission.sqm" -exec grep -c -i "forceHeadlessClient" {} \;) -gt 0 ]]
if [[ $(find ${dir} -maxdepth 2 -type f -iname "Mission.sqm" -exec grep -c -i "forceHeadlessClient" {} \;) -gt 0 ]]
then
ln -s ${MISSIONS}/"${i}" ${MISSIONS_HC}/
fi
Expand Down
15 changes: 13 additions & 2 deletions missions-symlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,23 @@ do
for file in $(find ${IN} -type f -iname "*.${map}.pbo")
do
v_bn=$(basename "${file}")
ln -s "${file}" "${OUT}"/"${v_bn}"
# ln: не удалось создать символьную ссылку '': Файл существует
if [[ ! -f "${OUT}"/"${v_bn}" ]]
then
ln -sv "${file}" "${OUT}"/"${v_bn}"
fi
done

for dir in $(find ${IN} -type d -iname "*.${map}")
do
v_bn=$(basename "${dir}")
ln -s "${dir}" "${OUT}"/"${v_bn}"
# find: File system loop detected; '' is part of the same file system loop as ''
if [[ ! -d "${OUT}"/"${v_bn}" ]]
then
if [[ -n $(find ${dir} -maxdepth 1 -type f -iname "Mission.sqm") ]]
then
ln -sv "${dir}" "${OUT}"/"${v_bn}"
fi
fi
done
done
84 changes: 84 additions & 0 deletions server-renice.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/bin/bash

IFS=$'\n'


PORTS=$(seq 2302 12 2362)

NICE_NORMAL=0
NICE_LOW=19
IONICE_CLASS_NORMAL=0
IONICE_CLASS_LOW=3
prefix_nft="user_counter"
prefix_difference="prefix_difference"
sleep=20
bytes_idle=$((5 * 1000 * ${sleep}))

fnc_port_getReNice () {
if [[ $(ssh mikrotik ip/firewall/connection/print | egrep -c "d udp.*:${port}") -gt 0 ]]
then
renice=${NICE_NORMAL}
else
bytes=$(nft -a list chain inet filter output | grep ${prefix_nft} | grep ${port} | awk '{ print $11 }' | head -n 1)
if [[ -z ${bytes} ]]
then
renice=${NICE_LOW}
ionice_class=${IONICE_CLASS_LOW}
else
str="${prefix_difference}_${port}"
bytes_old=${!str}
if [[ -z ${bytes_old} ]]
then
bytes_old=${bytes}
fi

difference=$((${bytes} - ${bytes_old}))
eval ${prefix_difference}_${port}=${bytes}

if [[ ${difference} -gt ${bytes_idle} ]]
then
renice=${NICE_NORMAL}
ionice_class=${NICE_NORMAL}
else
renice=${NICE_LOW}
ionice_class=${IONICE_CLASS_LOW}
fi
fi
fi
}

fnc_renice () {
if [[ ${renice} -ge 5 ]]
then
chrt --pid --idle 0 ${pid}
else
chrt --pid --other 0 ${pid}
fi

pgid=$(awk '{print $5}' /proc/${pid}/stat)
renice -n ${renice} --pgrp ${pgid}
ionice --class ${ionice_class} --pgid ${pgid}

children=$(cat /proc/${pid}/task/*/children)
for i in ${children[@]}
do
renice -n ${renice} --pid ${i}
ionice --class ${ionice_class} --pid ${i}
done
}

while sleep ${sleep}
do
for port in ${PORTS}
do
pids=$(lsof -t -n -i :${port} -a -c ^wineserver)
if [[ -n ${pids} ]]
then
fnc_port_getReNice
for pid in ${pids[@]}
do
fnc_renice
done
fi
done
done