Files
bash_utils/old/mad-instances.sh
2024-03-22 07:14:52 +01:00

59 lines
1.5 KiB
Bash

#!/bin/bash
maddir="/home/spezi/git/MAD-asyncio"
madinstances=("mad" "mad-wue" "mad-dac" "mad-kg" "mad-hof" "mad-amb" "mad-ip")
# "mad-ip"
# "mad-paris")
madinstances_short=("an" "wue" "dac" "kg" "hof" "amb" "ip")
# "ip"
#"paris")
nginxconf="/etc/nginx/sites-enabled/pogoan.de"
getmadminport () {
grep madmin_port $maddir/configs/scanner_$1.ini | awk '{print $2}'
}
getcsport () {
grep "\[$1\]" $maddir/plugins/commandSocket/plugin.ini -A2 | grep port | cut -d = -f2 | xargs
}
function getlatestold () {
dir="$maddir/logs"
name=$1
# http://mywiki.wooledge.org/BashFAQ/003
unset -v latest
for file in "$dir"/*$name*; do
[[ $file -nt $latest ]] && latest=$file
done
echo $latest
}
function getlatest () {
# $1 = required: instance name
# $2 = optional: number of minutes to look back
dir="$maddir/logs"
name=$1
files=""
if ! [ -z $2 ]; then
i=$2
else
i=0
fi
while [ -z "${files}" ]; do
((i++))
# find all files that contain the supplied name and have bin edited within the given number of minutes - 0 means same minute
files=$(find $dir/ -mmin -$i -type f -name "*_$name*" | sort -r)
done
for file in ${files[@]}; do
# these loglines are characteristical for main start.py instances - filtering out mitmreceiver instances etc.
if grep -e "pluginBase" -e "aiting for data after" -e "screenPath" $file >/dev/null; then
latest=$file
echo $latest
break
fi
done
}