better ban/stop

This commit is contained in:
SkyperTHC 2023-09-22 09:34:02 +01:00
parent d81f383aa1
commit f7bec92c59
No known key found for this signature in database
GPG Key ID: A9BD386DF9113CD6
2 changed files with 18 additions and 4 deletions

@ -6,12 +6,19 @@
source .env_hosts || exit
for h in "${HOSTS[@]}"; do
echo "Syncing ${h} DOWN"
# Reverse order so that first in HOSTS has master priority
i=${#HOSTS[@]}
while [[ $i -gt 0 ]]; do
((i--))
h="${HOSTS[$i]}"
echo "#${i} Syncing ${h} DOWN"
rsync -ral "${h}":/sf/config/db/banned "${h}":/sf/config/db/token "${h}":/sf/config/db/limits .
done
echo "===================================================="
i=0
for h in "${HOSTS[@]}"; do
echo "Syncing ${h} UP"
echo "#$i Syncing ${h} UP"
rsync -ral banned token limits "${h}":'/sf/config/db'
((i++))
done

@ -108,13 +108,17 @@ _sfcg_forall()
local a
local ts
local fn
local skip_token
local -
skip_token="$1"
set -o noglob
IFS=$'\n' arr=($(docker ps --format "{{.Names}}" --filter 'name=^lg-'))
for l in "${arr[@]}"; do
ts=2147483647
[[ -n $skip_token ]] && [[ -e "${_sf_dbdir}/user/${l}/token" ]] && continue
fn="${_sf_dbdir}/user/${l}/created.txt"
[[ -f "$fn" ]] && ts=$(date +%s -u -r "$fn")
a+=("$ts $l")
@ -528,6 +532,7 @@ lgstop()
[[ -n $2 ]] && {
lgwall "${1}" "$2"
echo -e "$2" >"${_sf_dbdir}/user/${1}/syscop-msg.txt"
docker top "$1" -e -o pid,ppid,%cpu,rss,start_time,exe,comm,cmd | cut -c -512 >"${_sf_dbdir}/user/${1}/syscop-ps.txt"
}
docker stop "${1}"
}
@ -586,13 +591,15 @@ lgx()
{
local lglid
local match
local skip_token
local IFS
match="$1"
skip_token="$2"
_sf_init
[[ -z $match ]] && return
IFS=$'\n' arr=($(_sfcg_forall))
IFS=$'\n' arr=($(_sfcg_forall "$skip_token"))
for lglid in "${arr[@]}"; do
_sfcg_psarr "$lglid" "$match" >/dev/null && continue
echo "$lglid "