-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from user-hq/master
pull request #8
- Loading branch information
Showing
5 changed files
with
173 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |