blob: 216bff0858312a182ec40c4128057f282569844a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# Packets backup directory - You have to CREATE this directory
BAK=/var/spool/ifmail/BAK
# logfile of ifcico
IFLOG=/var/log/ifmail/sysiflog
# log archive
IFLOGARC=/var/log/ifmail/TheLog
# owner of "ifcico"
IFCICO_OWNER=fnet
# how often should i try to call NODE?
MaxTry=30
# delay between outgoing calls in seconds
DELAY=10
# where to log processing - file or tty/console
INFO_TTY=/dev/console
# Lets backup the log and use a new one
if [ -e $IFLOG ]; then
echo Rearranging logs...
cat $IFLOG >> $IFLOGARC
cp /dev/null $IFLOG
fi
echo "`date \"+%b %d %T\"` ifpoll[$$]: starting" # >> $INFO_TTY
# remember me, not to run as root..
#
if [ `whoami` != "$IFCICO_OWNER" ]; then
echo "*** run $0 as the owner of ifcico ***"
echo "`date \"+%b %d %T\"` ifpoll[$$]: wrong uid (rc 2)" # >> $INFO_TTY
exit 2
fi
# argv[1] is the optional node to call
#
if [ "$1" != "" ]; then
if [ "$1" = "-?" ] || [ "$1" = "-h" ]; then
echo "usage: ifpoll [<node>]"
exit 3
else
NODE=$1
fi
fi
# let's pack the fido stuff..
#
$FIDOPATH/ifpack
# loop until ifcico could connect the node or MaxTry is encountered
#
i=1; errlv=1
while let 'i <= MaxTry' && let 'errlv != 0'
do
echo -n "`date \"+%b %d %T\"` ifpoll[$$]: $i. try ($NODE) " # >> $INFO_TTY
#
# start ifcico in master mode ..
#
$FIDOPATH/ifcico -r 1 $NODE
errlv=$?
if [ $errlv != "0" ]; then
echo "failed" # >> $INFO_TTY
if [ $i != $MaxTry ]; then
sleep $DELAY
fi
let i=i+1
else
echo "ok :)" # >> $INFO_TTY
fi
done
# if the poll was fine, unpacking..
#
if [ $errlv = "0" ]; then
echo "`date \"+%b %d %T\"` ifpoll[$$]: unpacking.. " # >> $INFO_TTY
cp -f /var/spool/ifmail/inb/*.* $BAK
$FIDOPATH/ifunpack
# add here some additional lines for processing tic files or
# incoming file-lists or simular..
else
# write me a mail about the failed poll
tail --lines=20 $IFLOG | elm -s "ifpoll: failed" $IFCICO_SYSOP >/dev/null
fi
echo "`date \"+%b %d %T\"` ifpoll[$$]: finished (rc $errlv)" # >> $INFO_TTY
# Collect some infos...
echo ""
echo "*** Outgoing File Transfer Stats: ***"
grep sent $IFLOG
echo "*** Incoming File Transfer Stats: ***"
grep received $IFLOG
echo ""
echo "---->> New mail: <<-----"
grep echomail $IFLOG
echo "---->> Personal mail: <<-----"
grep "mail from" $IFLOG
echo ""
# return the errorlevel of ifcico
exit $errlv
|