Packet tunneling over UDP, multiple channels
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

36 lines
985 B

#!/bin/bash
#
# Cron-driven bot to start a rrqnet cables or switch unless already up
RRQNET=/usr/sbin/rrqnet
function start-switch() {
. $1
exec $RRQNET $VERBOSE -4 $PORT ${VPN[@]}
}
function start-cable() {
. $1
ip link show dev $TAP > /dev/null || \
{ ip tuntap add $TAP mode tap ; ip link set dev $TAP up ; }
[ -z "$MAC" ] || ifconfig $TAP | grep -q "ether $MAC" || \
ifconfig $TAP hw ether $MAC
[ -z "$IP" ] || ip addr show dev $TAP | grep -q $IP || \
ifconfig $TAP $IP up
[ -z "$BR" ] || brctl show | grep -q $TAP || \
brctl addif $BR $TAP
exec $RRQNET $VERBOSE -4 ${OPTIONS[@]} -t $TAP $PORT ${VPN[@]}
}
for CABLE in $* ; do
CONF=/etc/rrqnet/conf.d/$CABLE.conf
eval $(grep ^PORT= $CONF)
lsof -i :$PORT > /dev/null && continue
eval $(grep ^TAP= $CONF)
LOG=/tmp/$CABLE.log
if [ -z "$TAP" ] ; then
( start-switch $CONF < /dev/null >> $LOG 2>&1 & )
else
( start-cable $CONF /dev/null >> $LOG 2>&1 & )
fi
done