2020-10-29 23:27:00 +01:00
|
|
|
#!/bin/sh
|
|
|
|
if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then echo "usage: automat server username password"; exit 1; fi
|
2020-11-14 04:11:08 +01:00
|
|
|
pwf=~/.mtpw
|
2020-10-29 23:27:00 +01:00
|
|
|
srv=$1
|
2020-11-15 04:10:41 +01:00
|
|
|
prt=30000
|
2020-10-29 23:27:00 +01:00
|
|
|
usr=$2
|
2020-11-21 03:16:41 +01:00
|
|
|
passwd=$3
|
2020-11-14 15:54:35 +01:00
|
|
|
logfile=$HOME/.wslog
|
2020-10-29 23:27:00 +01:00
|
|
|
mtpath=$(dirname $0)
|
2020-11-14 04:11:08 +01:00
|
|
|
if [ -f $pwf ]; then pas=$(cat $pwf); fi
|
2020-11-15 04:10:41 +01:00
|
|
|
check_host() {
|
2020-11-21 03:16:41 +01:00
|
|
|
if [ -x $(which nc) ]; then return 0; fi
|
|
|
|
nc -zu $1 $2 && return 0;
|
2020-11-15 04:10:41 +01:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2020-10-29 23:27:00 +01:00
|
|
|
while true; do
|
2020-11-15 04:10:41 +01:00
|
|
|
if check_host $srv $prt; then
|
2020-11-21 03:16:41 +01:00
|
|
|
$mtpath/bin/minetest --go --address $srv --port $prt --name $usr --password $passwd;
|
2020-11-15 04:10:41 +01:00
|
|
|
else echo host is down. waiting 10...; sleep 10
|
|
|
|
fi
|
2020-10-29 23:27:00 +01:00
|
|
|
done
|