[quagga-users 13252] vtysh wrapper
André Gustavo N. Lopes <
andre@...>
2013-04-22 23:58:16 GMT
Hi,
I really like the idea of keep track of what is changing on my config
files, specially with quagga.
This is very useful where several people manage the environment, and can
be a lifesaver finding the last working config.
I use SVN to accomplish this, so whenever I remember, I am commiting my
stuff to my svn server.
Whenever I remember is not always good enough, so I decided to code a
vtysh wrapper, to do it automatically.
It's just an idea yet, but it may help someone else, and new ideas can
be sugested.
I spend just a little time coding and reviewing, so please don't be too
strict reading the code =)
See below
#!/bin/bash
# no control-c, control-z
trap '' SIGINT
trap '' SIGQUIT
trap '' SIGTSTP
# execute vtysh command
vt(){
local m="$ <at> "
sudo vtysh -c $m
}
# save
save(){
vt write
echo -e "\tTODO: checkout running-config to svn"
echo -e "\tTODO: checkout saved config to svn"
}
# commit the current status, before change anything
echo -e "TODO: first things first:"
echo -e "\tTODO:checkout running-config to svn"
echo -e "\tTODO:checkout saved config to svn"
echo
# enables history internally (up, down keys) and show prompt
while IFS="" read -r -e -d $'\n' -p "vtysh # " c ; do
# take action
case $c in
"quit")
read -e -p "save config? " save
[ $save == "y" ] && save
exit ;;
# ideas
"compare") ;;
"rollback") ;;
"whatelse?") ;;
# send to vtysh
*)
vt $c
;;
esac
history -s "$c"
done
Cya.
--
--
André Gustavo N. Lopes
Equipe TI Onda Empresas
Tel: +55(41)3331-8282
Fax: +55(41)3331-8256
Onda Empresas
www.ondaempresas.com.br
Serviços e Soluções em Data Center, TI e Telecom
"Este endereço de e-mail se destina exclusivamente ao uso profissional. Todo o conteúdo nele inserido
é de responsabilidade exclusiva de seu remetente e não reflete, necessariamente, a opinião ou o ponto
de vista oficial do Onda Provedor de Serviços S/A.
A mensagem, incluindo seus anexos, pode conter informações legais privilegiadas e/ou confidenciais,
não podendo ser retransmitida, arquivada, divulgada ou copiada sem autorização expressa do
remetente. Caso tenha recebido esta mensagem por engano, por favor, informe o remetente e em seguida
apague-a do seu computador."