chiark / gitweb /
contrib/: New directory for random occasionally-useful stuff.
[tripe] / contrib / ipif-peers
1 #! /bin/sh
2 ###
3 ### Start up peers registered in tripe-ipif's table
4 ###
5 ### (c) 2012 Mark Wooding
6 ###
7
8 ###----- Licensing notice ---------------------------------------------------
9 ###
10 ### This file is part of Trivial IP Encryption (TrIPE).
11 ###
12 ### TrIPE is free software; you can redistribute it and/or modify
13 ### it under the terms of the GNU General Public License as published by
14 ### the Free Software Foundation; either version 2 of the License, or
15 ### (at your option) any later version.
16 ###
17 ### TrIPE is distributed in the hope that it will be useful,
18 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 ### GNU General Public License for more details.
21 ###
22 ### You should have received a copy of the GNU General Public License
23 ### along with TrIPE; if not, write to the Free Software Foundation,
24 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26 ###--------------------------------------------------------------------------
27 ### Instructions.
28 ###
29 ### This script will tell a tripe server to associate with all of the peers
30 ### named in the $TRIPEDIR/ipif.tab file.  See `tripe-ipif' for a description
31 ### of the configuration file.
32
33 set -e
34 quis=${0##*/}
35 case ${TRIPEDIR+t} in
36   t) ;;
37   *) echo >&2 "$quis: \`TRIPEDIR' unset"; exit 1 ;;
38 esac
39
40 ## Trundle through the table.
41 while read name remote_ext local_int remote_int routes; do
42
43   ## Ignore comments, and unknown remote-external addresses.
44   case "$name" in "" | "#"*) continue ;; esac
45   case "$remote_ext" in -) continue ;; esac
46
47   ## Parse the address.
48   fam=INET port=4070
49   case "$remote_ext" in
50     *:*) port=${remote_ext#*:}; addr=${remote_ext%:*} ;;
51     *) addr=$remote_ext ;
52   esac
53
54   ## Add the peer.
55   tripectl ADD "$name" "$fam" "$addr" "$port"
56
57 done <$TRIPEDIR/ipif.tab
58
59 ###----- That's all, folks --------------------------------------------------