Last active
July 8, 2017 15:31
-
-
Save Monsterovich/ed2a01128279d0fd4c137441d16210a6 to your computer and use it in GitHub Desktop.
This script runs scgb groups (v4)
This file contains hidden or 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
#!/bin/bash | |
scgbdir='/mnt/srvdata/server/scgb-hosts/' | |
botexe=$scgbdir'main/scgb.py' | |
config='/config.py' | |
groupsfile='groups.txt' | |
time=120 | |
txtpath=$scgbdir''$groupsfile | |
function update_groups { | |
cp $txtpath $txtpath'.tmp' | |
readarray -t clients < $txtpath'.tmp' | |
} | |
update_groups | |
update_num=true | |
while true | |
do | |
if [ "$update_num" = true ] ; then | |
n=$(wc -l < $txtpath) | |
n=$((n+1)) | |
echo 'Amount of groups:'$n | |
update_num=false | |
fi | |
for ((index=0;index<n;index++)) | |
do | |
if comm -3 <(sort $txtpath) <(sort $txtpath'.tmp') | grep -q '.*'; then | |
update_groups | |
update_num=true | |
echo 'Group list updated! Restarting...' | |
break | |
fi | |
if [ "${clients[index]}" == "" ]; | |
then | |
echo "Skipping client #${index}" | |
sleep $(bc -l <<< $time'/'$n) | |
continue | |
fi | |
client=$scgbdir''${clients[index]} | |
cd $client | |
echo 'Processing client: '${clients[index]} | |
#echo $client'/updates.log' | |
timeout -s 10 60s python3 $botexe $client''$config >> $client'/updates.log' | |
echo 'Done! (Status:'$?')' | |
sleep $(bc -l <<< $time'/'$n) | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment