#!/bin/bash -f
source /opt/CPshrd-R80.40/tmp/.CPprofile.sh
#Script Directory
EXECDIR="/home/admin/PBRPerUser"
#User that will Execute the Scripts and Cron Job
EXECUSER="admin"
echo "First time setup"
echo "Creating all files and Gaia configuration"
echo "Creating Exec Directory"
mkdir $EXECDIR
echo "Creating Files"
touch $EXECDIR/PBRPerUser.log
touch $EXECDIR/PBRPerUserLink1.sh
touch $EXECDIR/PBRPerUserLink1_IPs.txt
touch $EXECDIR/PBRPerUserLink1_Table.txt
touch $EXECDIR/PBRPerUserLink1_Table_To_Compare.txt
touch $EXECDIR/PBRPerUserLink1_ToRemove.txt
touch $EXECDIR/PBRPerUserLink1_Users.txt
touch $EXECDIR/PBRPerUserLink1_Watch.sh
touch $EXECDIR/sid_c.txt
echo "Copying Scripts to $EXECDIR"
cp ./PBRPerUserLink1.sh $EXECDIR/PBRPerUserLink1.sh
cp ./PBRPerUserLink1_Watch.sh $EXECDIR/PBRPerUserLink1_Watch.sh
cp ./PBRPerUserLink1_CronJob.sh $EXECDIR/PBRPerUserLink1_CronJob.sh
echo "Change Permission"
chmod 760 $EXECDIR/PBRPerUserLink1.sh
chmod 760 $EXECDIR/PBRPerUserLink1_Watch.sh
chmod 760 $EXECDIR/PBRPerUserLink1_CronJob.sh
echo "Adding System-Startup Recurrence for PBRPerUserLink1_Watch.sh at Cron Job"
clish -c "add cron job PBRPerUserLink1_CronJob command '$EXECDIR/PBRPerUserLink1_CronJob.sh >> $EXECDIR/PBRPerUser.log 2>&1' recurrence system-startup"
if grep -q PBRPerUserLink1_Watch.sh /var/spool/cron/admin; then
echo "Job already in Cron"
else
echo "Creating Cron Job"
echo "##PBRPerUser" >> /var/spool/cron/$EXECUSER
echo "* * * * * $EXECDIR/PBRPerUserLink1_Watch.sh >> $EXECDIR/PBRPerUser.log 2>&1" >> /var/spool/cron/$EXECUSER
fi
echo "Lock Database Override"
clish -c "lock database override"
### Creating IP Reachability Detection ###
### CHANGE IP TO REFLET YOUR ON ENVIRONMENT ###
echo "Creating IP Reachability Detection"
clish -c "set ip-reachability-detection ping address 200.150.0.100 enable-ping on"
clish -c "set ip-reachability-detection ping address 200.200.0.100 enable-ping on"
### Creating Default Route HA without ISP Redundancy With ICMP Health Checking ###
### CHANGE IP TO REFLET YOUR ON ENVIRONMENT ###
echo "Creating Default Route HA without ISP Redundancy With ICMP Health Checking"
clish -c "set static-route default nexthop gateway address 200.150.0.100 priority 1 on"
clish -c "set static-route default nexthop gateway address 200.150.0.100 monitored-ip 200.150.0.100 on"
clish -c "set static-route default nexthop gateway address 200.150.0.100 monitored-ip-option fail-any"
clish -c "set static-route default nexthop gateway address 200.200.0.100 priority 2 on"
clish -c "set static-route default nexthop gateway address 200.200.0.100 monitored-ip 200.200.0.100 on"
clish -c "set static-route default nexthop gateway address 200.200.0.100 monitored-ip-option fail-any"
### Creating PBR Table ###
### CHANGE IP TO REFLET YOUR ON ENVIRONMENT ###
echo "Creating PBR Table"
clish -c "set pbr table PBRPerUserLink1 static-route default nexthop gateway address 200.200.0.100 on"
echo "Saving Config"
clish -c "save config"
|