Statistics
| Branch: | Tag: | Revision:

root / add-network @ cf51ea5b

History | View | Annotate | Download (411 Bytes)

1 cf51ea5b Dimitris Aragiorgis
#!/bin/bash
2 cf51ea5b Dimitris Aragiorgis
3 cf51ea5b Dimitris Aragiorgis
DIR=/var/lib/snf-network
4 cf51ea5b Dimitris Aragiorgis
SUBNET=$1
5 cf51ea5b Dimitris Aragiorgis
GATEWAY=$2
6 cf51ea5b Dimitris Aragiorgis
TYPE=$3
7 cf51ea5b Dimitris Aragiorgis
NAME=$4
8 cf51ea5b Dimitris Aragiorgis
RT_TABLES=/etc/iproute2/rt_tables
9 cf51ea5b Dimitris Aragiorgis
10 cf51ea5b Dimitris Aragiorgis
11 cf51ea5b Dimitris Aragiorgis
12 cf51ea5b Dimitris Aragiorgis
if [ $# -ne 4 ]; then
13 cf51ea5b Dimitris Aragiorgis
  echo "$0 <subnet> <gateway> <private/public> <name>"
14 cf51ea5b Dimitris Aragiorgis
  exit 1
15 cf51ea5b Dimitris Aragiorgis
fi
16 cf51ea5b Dimitris Aragiorgis
17 cf51ea5b Dimitris Aragiorgis
18 cf51ea5b Dimitris Aragiorgis
19 cf51ea5b Dimitris Aragiorgis
cat > $DIR/networks/$NAME <<EOF
20 cf51ea5b Dimitris Aragiorgis
SUBNET=$SUBNET
21 cf51ea5b Dimitris Aragiorgis
GATEWAY=$GATEWAY
22 cf51ea5b Dimitris Aragiorgis
TYPE=$TYPE
23 cf51ea5b Dimitris Aragiorgis
EOF
24 cf51ea5b Dimitris Aragiorgis
25 cf51ea5b Dimitris Aragiorgis
26 cf51ea5b Dimitris Aragiorgis
IDX=$(ls $DIR/networks | wc -l)
27 cf51ea5b Dimitris Aragiorgis
28 cf51ea5b Dimitris Aragiorgis
# remove old entry
29 cf51ea5b Dimitris Aragiorgis
sed -i '/^'"$IDX"'\ / d' $RT_TABLES
30 cf51ea5b Dimitris Aragiorgis
31 cf51ea5b Dimitris Aragiorgis
echo "$IDX rt_$NAME" >> $RT_TABLES
32 cf51ea5b Dimitris Aragiorgis