Skip to content

Instantly share code, notes, and snippets.

@jandahl
Created September 6, 2012 07:23
Show Gist options
  • Save jandahl/3652552 to your computer and use it in GitHub Desktop.
Save jandahl/3652552 to your computer and use it in GitHub Desktop.
Remove a line from Really Awesome New Cisco Config Differ (RANCID)
function removecpe {
if [ $# -ne 1 ]; then
echo "$0 ip"
exit 1
fi
if [[ $(id -un) != rancid ]]; then
echo "Must be rancid user to run this script"
exit 1
fi
ip=$1
if `grep -q $ip router.db`
then
date=$(date +%Y%m%d)
cp /usr/local/var/rancid/rancid-cpe/router.db /usr/local/var/rancid/rancid-cpe/router.db.$date
removedline=`sed -n "/^$ip:/p" /usr/local/var/rancid/rancid-cpe/router.db | sed -e "s/:cisco:up://"`
sed -e "/^$ip:/d" /usr/local/var/rancid/rancid-cpe/router.db.$date > /usr/local/var/rancid/rancid-cpe/router.db
echo "$removedline solgt til stanglakrids."
exit 0
else
echo "IP-adressen $ip ikke fundet"
exit 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment