diff --git a/automt b/automt index 46d574696..9fd48ff98 100755 --- a/automt +++ b/automt @@ -10,6 +10,7 @@ chatlogdir=~/.wschat mtpid=0 mtpath=$(dirname $0) dbg=1 +quit=1 if [ ! -z $4 ]; then dbg=0; fi mkdir -p $chatlogdir if [ -f $pwf ]; then pas=$(cat $pwf); fi @@ -22,21 +23,31 @@ check_host() { startmt() { $mtpath/bin/minetest --go --address $srv --port $prt --name $usr --password $passwd 2>&1 | while read l; do - if [ "$(echo $l |grep '\[cchat\]')" != "" ]; then + if [ "$(echo $l |grep '\[cchat\]')" != "" ]; then srvstr=$(echo $l|cut -d ' ' -f 5) lgstr=$(echo $l|sed 's/ACTION\[Main\]: \[cchat\] //'|sed "s/$srvstr//") if [ "$(echo $l |grep '\[sent\]')" != "" ]; then continue; fi echo $lgstr >> $chatlogdir/$srvstr.txt - else echo $l >> $logfile; fi - + else + echo $l >> $logfile; + if [ "$(echo $l|grep 'AUTOMT Actually Quit')" != "" ]; then + quit=0; + kill $mtpid + fi + fi if [ $dbg -eq 0 ]; then echo $l; fi done & mtpid=$! } while true; do + if [ $quit -eq 0 ]; then + kill -9 $mtpid + exit + fi + sleep 1 if check_host $srv $prt; then - if ! ps $mtpid >/dev/null 2>&1; then startmt; fi - else echo host is down. waiting 10...; sleep 10; fi + if ! ps $mtpid >/dev/null 2>&1 && [ $quit -eq 1 ]; then startmt; fi + fi sleep 1 done diff --git a/clientmods/automt/init.lua b/clientmods/automt/init.lua new file mode 100644 index 000000000..33073d8ac --- /dev/null +++ b/clientmods/automt/init.lua @@ -0,0 +1,7 @@ +minetest.register_chatcommand('mtq', { + description = 'automt-quit', + func = function(param) + minetest.log("AUTOMT Actually Quit") + minetest.disconnect() + end +}) diff --git a/clientmods/mods.conf b/clientmods/mods.conf index c244fac99..8141b07a2 100644 --- a/clientmods/mods.conf +++ b/clientmods/mods.conf @@ -36,3 +36,4 @@ load_mod_speedlimit = true load_mod_frenemies = true load_mod_autocraft = true load_mod_quint = true +load_mod_automt = true