[nos-bbs] RPI Raspbian Stretch Jnos autostart and restart automatically
SP2L
SP2L at sp2l.ampr.org
Wed Jan 24 05:52:17 EST 2018
Jose.
This is follow up to my previous message.
In regard subject in question.
Will make story as brief as possible.
Sometime back in 2013 my TNOS-3.01a1 very often was unresponsive.
TNOS process (PID) was present, tun0 interface with assigned IP
was visible but connection to TNOS wasn't possible at all.
Therefore I crafted set of smart (I hope so!) scripts
in order to keep TNOS up&running and being connectible.
1. In crontab I put this line:
*/15 * * * * root /usr/local/tnos301/tnosrst &> /dev/null
2. This is tnosrst script:
#!/bin/sh
#
LOG="/var/log/tnos.log"
TIMESTAMP=`date "+%b %d %X"`
#
/usr/local/tnos301/tnosxpct
sleep 1
#
HANG=`cat /usr/local/tnos301/SP2L.txt | grep -wo "Area:"`
if [ "$HANG" != "Area:" ]; then
echo "$TIMESTAMP TNOS is hung-up - restarting..." >> $LOG
/usr/local/tnos301/startnos
sleep 1
else
echo "O.K!" > /usr/local/tnos301/hang.txt
fi
3. This is tnosxpct script:
#!/usr/bin/expect
#
spawn /usr/bin/telnet 44.165.2.5
expect ":"
send "sp2l\r"
expect ":"
send "<your_password>\r"
log_file -noappend /usr/local/tnos301/SP2L.txt
expect ">"
sleep .1
send "b\r"
sleep .1
log_file
expect eof
4. This is startnos script:
#!/bin/sh
# start NOS on a specific vt 4
BASEDIR=/usr/local
cd $BASEDIR/tnos301
export TERM=konsole
PID=`/bin/pidof -x tnos`
if [ -n "$PID" ]; then
kill -9 $PID
fi
rm -f $BASEDIR/tnos301/spool/mqueue/*.lck
rm -f $BASEDIR/tnos301/spool/mail/*.lck
rm -f $BASEDIR/tnos301/tnos.lock
exec ./tnos -U 0 < /dev/tty4 > /dev/tty4 2>&1 &
That's all, almost all.
Of course scripts have to be modified
to meet local environment requirements.
In order for above to work it is necessary
to install expect package, which is available
in most of linux distributions.
The pros: this is nifty and smart solution, IMHO.
The cons: did not noticed so far.
I use similar set of scripts to keep my
dexspider instance up&running flawlessly.
Although YMMV, Hi!.
Best regards.
Tom - SP2L
More information about the nos-bbs
mailing list