-
Notifications
You must be signed in to change notification settings - Fork 3
/
route_rebuild_gaia.sh
executable file
·35 lines (27 loc) · 1.42 KB
/
route_rebuild_gaia.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
# Written by Craig Dods
echo "Hello, please enter the correct log file to analyze"
ls | grep routes
read logfile
echo "Thank you - Rebuilding the routing table now"
#Multiple DB overrides since GAIA is a little buggy with this right now:
#[Expert@GAIA1]# clish -c "lock database override"
#CLINFR0771 Config lock is owned by admin. Use the command 'lock database override' to acquire the lock.
#[Expert@GAIA1]# clish -c "lock database override"
#CLICMD0201 Config lock is already turned on.
clish -c "lock database override" > /dev/null 2>&1
clish -c "lock database override" > /dev/null 2>&1
# Route commands are split to avoid this (default has /0 which it doesn't like...):
# CLINFR0409 IPv4 unicast bitmask check fails: Invalid bitmask value in 0.0.0.0/0; valid range is 1-32
#set static-route 0.0.0.0/0
#----^^^^^^^^^^^^^^^^^^^^^^
# Add the default route:
cat $logfile | grep 0.0.0.0\/0 | awk '{print "clish -c \"set static-route default nexthop gateway address ",$2" on \""}' | sh > /dev/null 2>&1
# Add all of the routes (excluding default route)
cat $logfile | sed '/0.0.0.0\/0/d' | awk '{print "clish -c \"set static-route ",$1" nexthop gateway address ",$2" on \""}' | sh > /dev/null 2>&1
clish -c "save config" > /dev/null 2>&1
echo "Finished rebuilding the routing table..."
echo " "
echo "Please remember to verify if the routes were rebuilt correctly!!"
echo "Goodbye "
clish -c "unlock database" > /dev/null 2>&1