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.
 
 
 
 

37 lines
985 B

  1. #!/bin/bash
  2. #
  3. # Cron-driven bot to start a rrqnet cables or switch unless already up
  4. RRQNET=/usr/sbin/rrqnet
  5. function start-switch() {
  6. . $1
  7. exec $RRQNET $VERBOSE -4 $PORT ${VPN[@]}
  8. }
  9. function start-cable() {
  10. . $1
  11. ip link show dev $TAP > /dev/null || \
  12. { ip tuntap add $TAP mode tap ; ip link set dev $TAP up ; }
  13. [ -z "$MAC" ] || ifconfig $TAP | grep -q "ether $MAC" || \
  14. ifconfig $TAP hw ether $MAC
  15. [ -z "$IP" ] || ip addr show dev $TAP | grep -q $IP || \
  16. ifconfig $TAP $IP up
  17. [ -z "$BR" ] || brctl show | grep -q $TAP || \
  18. brctl addif $BR $TAP
  19. exec $RRQNET $VERBOSE -4 ${OPTIONS[@]} -t $TAP $PORT ${VPN[@]}
  20. }
  21. for CABLE in $* ; do
  22. CONF=/etc/rrqnet/conf.d/$CABLE.conf
  23. eval $(grep ^PORT= $CONF)
  24. lsof -i :$PORT > /dev/null && continue
  25. eval $(grep ^TAP= $CONF)
  26. LOG=/tmp/$CABLE.log
  27. if [ -z "$TAP" ] ; then
  28. ( start-switch $CONF < /dev/null >> $LOG 2>&1 & )
  29. else
  30. ( start-cable $CONF /dev/null >> $LOG 2>&1 & )
  31. fi
  32. done