| 1 |
#!/bin/sh |
| 2 |
Ver=0.9h |
| 3 |
# ifpoll, poll my boss node or the node given as argument 1 |
| 4 |
# |
| 5 |
# i start this shell script every day by "crond", but you can |
| 6 |
# start it also by hand :) start it as the owner of ifcico. |
| 7 |
# rasca, berlin 1993,97 (Rasca Gmelch, 2:2410/305.4) |
| 8 |
# |
| 9 |
|
| 10 |
# configuration part, change this to reflect your installation |
| 11 |
|
| 12 |
# where "ifcico" and "ifpack" reside |
| 13 |
FIDOPATH=/usr/local/lib/fnet |
| 14 |
|
| 15 |
# ifcico config file |
| 16 |
# IFCONFIG=$FIDOPATH/config |
| 17 |
IFCONFIG=/etc/fido/ifmail.cfg |
| 18 |
|
| 19 |
# logfile of ifcico |
| 20 |
IFLOG=/var/log/fido/iflog |
| 21 |
|
| 22 |
# where to log processing - file or tty/console |
| 23 |
# LOGGING=/var/log/fido/ifpoll.log |
| 24 |
LOGGING=/dev/tty1 |
| 25 |
|
| 26 |
# protected inbound directory |
| 27 |
PINBOUND=`grep ^protinbound $IFCONFIG | cut -c 13-` |
| 28 |
|
| 29 |
# owner of "ifcico" |
| 30 |
IFCICO_OWNER=uucp |
| 31 |
|
| 32 |
# who should be informed when the calling failed |
| 33 |
IFCICO_SYSOP=rasca@lupo |
| 34 |
|
| 35 |
# my boss node (default address to poll) |
| 36 |
NODE="f305.n2410.z2.fidonet.org" |
| 37 |
|
| 38 |
# how often should i try to call NODE? |
| 39 |
MaxTry=4 |
| 40 |
|
| 41 |
# delay between outgoing calls in seconds |
| 42 |
DELAY=240 |
| 43 |
|
| 44 |
# end of configuration part ------------------- |
| 45 |
|
| 46 |
|
| 47 |
echo "`date \"+%b %d %T\"` ifpoll[$$]: starting (ifpoll v$Ver)" >> $LOGGING |
| 48 |
|
| 49 |
# remember me, not to run as root.. |
| 50 |
# |
| 51 |
if [ `whoami` != "$IFCICO_OWNER" ]; then |
| 52 |
echo "*** run $0 as the owner of ifcico ***" |
| 53 |
echo "`date \"+%b %d %T\"` ifpoll[$$]: wrong uid (rc 2)" >> $LOGGING |
| 54 |
exit 2 |
| 55 |
fi |
| 56 |
# |
| 57 |
# argv[1] is the optional node to call |
| 58 |
# |
| 59 |
if [ "$1" != "" ]; then |
| 60 |
if [ "$1" = "-?" ] || [ "$1" = "-h" ]; then |
| 61 |
echo -e "\nusage: ifpoll [<node>]" |
| 62 |
echo -e "default node: $NODE\n" |
| 63 |
exit 3 |
| 64 |
else |
| 65 |
NODE=$1 |
| 66 |
fi |
| 67 |
fi |
| 68 |
# |
| 69 |
# first let's pack the fido stuff.. |
| 70 |
# |
| 71 |
$FIDOPATH/ifpack # -I$IFCONFIG |
| 72 |
|
| 73 |
# |
| 74 |
# loop until ifcico could connect the node or MaxTry is encountered |
| 75 |
# |
| 76 |
i=1; errlv=1 |
| 77 |
while (expr $i \<= $MaxTry && expr $errlv != 0 ) >/dev/null |
| 78 |
do |
| 79 |
echo -n "`date \"+%b %d %T\"` ifpoll[$$]: $i. try ($NODE) " >> $LOGGING |
| 80 |
# |
| 81 |
# start ifcico in master mode .. |
| 82 |
# |
| 83 |
if [ "$NODE" != "-" ]; then |
| 84 |
$FIDOPATH/ifcico -I$IFCONFIG -r 1 $NODE |
| 85 |
errlv=$? |
| 86 |
else |
| 87 |
errlv=0 |
| 88 |
fi |
| 89 |
if [ $errlv != "0" ]; then |
| 90 |
echo "failed" >> $LOGGING |
| 91 |
if [ $i != $MaxTry ]; then |
| 92 |
sleep $DELAY |
| 93 |
fi |
| 94 |
i=`expr $i + 1` |
| 95 |
else |
| 96 |
echo "ok :)" >> $LOGGING |
| 97 |
fi |
| 98 |
done |
| 99 |
# |
| 100 |
# if the poll was fine, let's unpacking.. |
| 101 |
# |
| 102 |
if [ $errlv = "0" ]; then |
| 103 |
# |
| 104 |
echo "`date \"+%b %d %T\"` ifpoll[$$]: unpacking.. " >> $LOGGING |
| 105 |
$FIDOPATH/ifunpack -I$IFCONFIG |
| 106 |
# |
| 107 |
if [ $NODE = "f305.n2410.z2.fidonet.org" ] || \ |
| 108 |
[ "$NODE" = "-" ]; then |
| 109 |
# |
| 110 |
# do this only when calling my boss node |
| 111 |
# |
| 112 |
# adjust the system time |
| 113 |
# /usr/local/sbin/fnet/trxset >> $LOGGING |
| 114 |
# |
| 115 |
if [ -s "$PINBOUND/22410305.lzh" ]; then |
| 116 |
chmod 644 $PINBOUND/22410305.lzh |
| 117 |
fi |
| 118 |
# |
| 119 |
# nodelist stuff |
| 120 |
# |
| 121 |
for pl in 4dpoint.bln pointlst.bln |
| 122 |
do |
| 123 |
if [ -s "$PINBOUND/$pl" ]; then |
| 124 |
mv -f $PINBOUND/$pl /usr/fido/nodelist |
| 125 |
fi |
| 126 |
done |
| 127 |
# |
| 128 |
cd $PINBOUND && { |
| 129 |
if find nodediff.a[0-9][0-9] 2> /dev/null |
| 130 |
then |
| 131 |
for diff in nodediff.a[0-9][0-9] |
| 132 |
do |
| 133 |
arc -ie $diff >> $LOGGING && { |
| 134 |
mv $diff ../Nodelist/ |
| 135 |
} |
| 136 |
done |
| 137 |
nice /usr/local/sbin/fnet/differ.sh >> $LOGGING |
| 138 |
nice $FIDOPATH/ifindex |
| 139 |
fi |
| 140 |
} |
| 141 |
fi |
| 142 |
else |
| 143 |
# write me a mail about the failed poll |
| 144 |
tail --lines=20 $IFLOG | elm -s "ifpoll: failed" $IFCICO_SYSOP >/dev/null |
| 145 |
fi |
| 146 |
|
| 147 |
echo "`date \"+%b %d %T\"` ifpoll[$$]: finished (rc $errlv)" >> $LOGGING |
| 148 |
|
| 149 |
# return the errorlevel of ifcico |
| 150 |
exit $errlv |
| 151 |
|