~/.bashrc
==========
show_code()
{
cd /ws/code/$view/apic-em-core/services
find apic-em-pki-broker -name "*.java" > cscope.files
find apic-em-pki-broker -name "*.py" >> cscope.files
find apic-em-pki-broker -name start >> cscope.files
find apic-em-pki-broker -name status >> cscope.files
find apic-em-pki-broker -name "*.sh" >> cscope.files
find apic-em-pki-broker -name "*.xml" >> cscope.files
find apic-em-pki-ca -name "*.java" >> cscope.files
find apic-em-pki-ca -name "*.py" >> cscope.files
find apic-em-pki-ca -name start >> cscope.files
find apic-em-pki-ca -name status >> cscope.files
find apic-em-pki-ca -name "*.sh" >> cscope.files
find apic-em-pki-ca -name "*.xml" >> cscope.files
cscope -b
cscope -d
}
set_view()
{
view=$1
if [ -d /ws/code/$view ]
then
cd /ws/code/$view/apic-em-core
else
read -p "Do you want to pull code? (y/n)" input
if [ "$input" == "y" ]
then
su - tapmahes -c "~/.main.sh $view"
cd /ws/code/$view
sudo chown -R enc .
else
ls /ws/code
fi
fi
}
search_code()
{
pattern=$1
str=$2
find . -name "$pattern" -print | xargs grep $str
}
code_diff()
{
if [ $view ]
then
cd /ws/code/$view/apic-em-core
git show --name-only | grep services > /tmp/diff_list
git diff --name-only >> /tmp/diff_list
readarray -t array < /tmp/diff_list
while true
do
var=0
for e in "${array[@]}"
do
echo $var : $e
((var++))
done
read -p "Enter the number:" num
git show HEAD^1:${array[$num]} > /tmp/original
vimdiff /tmp/original ${array[$num]}
done
else
echo Error# View is not set, please set the view using 'code <view_name>'
fi
}
alias code=set_view
alias bro='cd /ws/code/$view/apic-em-core/services/apic-em-pki-broker'
alias ca='cd /ws/code/$view/apic-em-core/services/apic-em-pki-ca'
alias cpg='~/enc.exp cpg $view'
alias cpgb='~/enc.exp cpgb $view'
alias cpgc='~/enc.exp cpgc $view'
alias cs=show_code
alias search=search_code
alias cdiff=code_diff
====================================================
$ cat /home/enc/enc.exp
#!/usr/bin/expect
set timeout 1000
proc setup_grapevine {} {
spawn ssh grapevine@10.78.106.45
expect {
"password:" { send "Grapevine1\r" }
timeout {
send "Error"
exit
}
}
sleep 1
send "mkdir /home/grapevine/tapesh\r"
send "mkdir /home/grapevine/tapesh/broker\r"
send "mkdir /home/grapevine/tapesh/ca\r"
interact
}
proc copy_to_grapevine_broker {obj1} {
spawn scp /ws/code/$obj1/apic-em-core/services/apic-em-pki-broker/pki-broker-service/target/apic-em-pki-broker-service-enc-private-build.tar.gz grapevine@10.78.106.45:/home/grapevine/tapesh/broker/
expect {
"password:" { send "Grapevine1\r" }
timeout {
send "Error"
exit
}
}
interact
spawn scp /ws/code/$obj1/apic-em-core/services/apic-em-pki-broker/pki-broker-service/src/main/config/service-config.json grapevine@10.78.106.45:/home/grapevine/tapesh/broker/
expect {
"password:" { send "Grapevine1\r" }
timeout {
send "Error"
exit
}
}
interact
}
proc copy_to_grapevine_ca {obj1} {
spawn scp /ws/code/$obj1/apic-em-core/services/apic-em-pki-ca/target/apic-em-jboss-ejbca*.tar.gz grapevine@10.78.106.45:/home/grapevine/tapesh/ca/
expect {
"password:" { send "Grapevine1\r" }
timeout {
send "Error"
exit
}
}
interact
spawn scp /ws/code/22jan/apic-em-core/services/apic-em-pki-ca/src/conf/service-config.json grapevine@10.78.106.45:/home/grapevine/tapesh/ca/
expect {
"password:" { send "Grapevine1\r" }
timeout {
send "Error"
exit
}
}
interact
}
if { [string compare [lindex $argv 0 0] "cpg"] == 0 } {
setup_grapevine
}
if { [string compare [lindex $argv 0 0] "cpgb"] == 0 } {
copy_to_grapevine_broker [lindex $argv 1]
}
if { [string compare [lindex $argv 0 0] "cpgc"] == 0 } {
copy_to_grapevine_ca [lindex $argv 1]
}
No comments:
Post a Comment