#!/bin/bash

# Basic paths
SHELL_API=/bin/cli-shell-api
vyatta_sbindir=/opt/vyatta/sbin
dhcp_map_file=/config/dhcpd_static.map

# Basic commands
SET=${vyatta_sbindir}/my_set
DELETE=${vyatta_sbindir}/my_delete
COPY=${vyatta_sbindir}/my_copy
MOVE=${vyatta_sbindir}/my_move
RENAME=${vyatta_sbindir}/my_rename
ACTIVATE=${vyatta_sbindir}/my_activate
DEACTIVATE=${vyatta_sbindir}/my_activate
COMMENT=${vyatta_sbindir}/my_comment
COMMIT=${vyatta_sbindir}/my_commit
DISCARD=${vyatta_sbindir}/my_discard
SAVE=${vyatta_sbindir}/vyatta-save-config.pl

# Init session
session_env=$($SHELL_API getSessionEnv $PPID)
eval $session_env
$SHELL_API setupSession

# Check session
$SHELL_API inSession
if [ $? -ne 0 ]; then
        echo "Can not init session"
        exit 1
fi


br0_ip=$(/sbin/ifconfig br0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}')

subnet_base=`echo $br0_ip | cut -d"." -f1-3`

gateway_ip=$subnet_base".254"




$DELETE protocols static route 80.10.117.120/31
$DELETE protocols static route 81.253.206.0/24
$DELETE protocols static route 81.253.210.0/23
$DELETE protocols static route 81.253.214.0/23
$DELETE protocols static route 172.19.20.0/23
$DELETE protocols static route 172.20.224.167/32
$DELETE protocols static route 172.23.12.0/22
$DELETE protocols static route 193.253.67.88/29
$DELETE protocols static route 193.253.153.227/32
$DELETE protocols static route 193.253.153.228/32


$SET protocols static route 80.10.117.120/31 next-hop $gateway_ip
$SET protocols static route 81.253.206.0/24 next-hop $gateway_ip
$SET protocols static route 81.253.210.0/23 next-hop $gateway_ip
$SET protocols static route 81.253.214.0/23 next-hop $gateway_ip
$SET protocols static route 172.19.20.0/23 next-hop $gateway_ip
$SET protocols static route 172.20.224.167/32 next-hop $gateway_ip
$SET protocols static route 172.23.12.0/22 next-hop $gateway_ip
$SET protocols static route 193.253.67.88/29 next-hop $gateway_ip
$SET protocols static route 193.253.153.227/32 next-hop $gateway_ip
$SET protocols static route 193.253.153.228/32 next-hop $gateway_ip

$COMMIT
$SAVE
