Friday, October 15, 2021

हिंदी भजन (Hindi Bhajan)

 

नारायण स्तुति 

भजमन नारायण नारायण हरी हरी ।

लक्ष्मीनारायण नारायण हरी हरी ।

सत्यनारायण नारायण हरी हरी ।

भगवन नारायण नारायण हरी हरी ।

जय जय नारायण नारायण हरी हरी ।

बोलो नारायण नारायण हरी हरी ॥






Sunday, April 9, 2017

VIM Settings which I like

:set nocompatible
:set bs=2
:set expandtab
:set tabstop=4
:set shiftwidth=4
:set showmatch
:set mouse=a
:set virtualedit=all
:set nu
syntax enable
set hlsearch
set incsearch
set ignorecase
set smartcase


set t_Co=128
highlight DiffAdd cterm=NONE ctermfg=Black ctermbg=Green gui=NONE guifg=Black guibg=Green
highlight DiffDelete cterm=NONE ctermfg=Black ctermbg=Red gui=NONE guifg=Black guibg=Red
highlight DiffChange cterm=NONE ctermfg=Black ctermbg=Yellow gui=NONE guifg=Black guibg=Yellow
highlight DiffText cterm=NONE ctermfg=Black ctermbg=Magenta gui=NONE guifg=Black guibg=Magenta

Thursday, February 4, 2016

My BASH and EXPECT Script for APIC-EM


~/.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]
}



Wednesday, August 19, 2015

How install EJBCA and JBOSS


Based on : https://forge.fusiondirectory.org/projects/fd-plugins/wiki/How_install_EJBCA_and_JBOSS

Based on http://www.ejbca.org/docs/installation.html#Ubuntu%20quick%20start
Tip : Install tmux or screen to use two terminals or more
  • Create new user
  • useradd -m ejbca
  • passwd ejbca
  • Install softwares
  • apt-get install openjdk-7-jdk ant ant-optional unzip ntp
  • Download and install jboss and ejbca
  • Configure ejbca (where is jboss and other if you need)
  • echo "appserver.home=/home/ejbca/jboss-as-7.1.1.Final" >> ejbca_ce_6_2_0/conf/ejbca.properties
  • Launch jboss
  • export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-<arch>/jre
  • jboss-as-7.1.1.Final/bin/standalone.sh
  • EJBCA install (answer to question)
  • cd ejbca_ce_6_2_0/
  • export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-<arch>/jre
  • ant deploy
  • (wait little that jboss reload)
  • ant install
  • Restart jboss
  • ctrl + c
  • jboss-as-7.1.1.Final/bin/standalone.sh
  • Import superadmin.p12 in your browser (/home/ejbca/ejbca_ce_6_2_0/p12/superadmin.p12)
  • Configure jboss for logging
  • Run ./bin/jboss-cli.sh
  • connect
  • /system-property=org.jboss.as.logging.per-deployment:add(value=false)
  • /subsystem=logging/logger=org.ejbca:add
  • /subsystem=logging/logger=org.ejbca:write-attribute(name=level, value=DEBUG)
  • /subsystem=logging/logger=org.cesecore:add
  • /subsystem=logging/logger=org.cesecore:write-attribute(name=level, value=DEBUG)
  • exit

Saturday, August 8, 2015

History of linux


Mid 1960 - multics (a time sharing operating system) was getting developed by AT&T Bell but it was too large/complex.... finally AT&T pulled out from project.

In 1969-70,  Ken Thompson and Dennis Ritchie (both of AT&T Bell Laboratories) wrote Unix Operating system (on a much less scaled version).

Later they rewrote it in C, make it portable.

Unix philosophy was to use a large number of software tools, small programs that can be strung together through a command-line interpreter using pipes, as opposed to using a single monolithic program that includes all of the same functionality.

Both Unix and the C programming language were developed by AT&T and distributed to government and academic institutions, which led to both being ported to a wider variety of machine families than any other operating system.

Under Unix, the operating system consists of many utilities along with the master control program, the kernel. The kernel provides services to start and stop programs, handles the file system and other common "low-level" tasks that most programs share, and schedules access to avoid conflicts when programs try to access the same resource or device simultaneously. To mediate such access, the kernel has special rights, reflected in the division between user space and kernel space.

During the late 1970s and early 1980s, the influence of Unix in academic circles led to large-scale adoption of Unix (BSD and System V) by commercial startups, including Sequent, HP-UX, Solaris, AIX, and Xenix. In the late 1980s, AT&T Unix System Laboratories and Sun Microsystems developed System V Release 4 (SVR4), which was subsequently adopted by many commercial Unix vendors.

1983, none of the computer operating systerm was free.

1984, Richard M. Stallman (founder of Free Software Foundation) started developing the GNU operating system (a unix-like operating system)

The GNU Project has developed a comprehensive set of free software tools (cp, rm, vi, gcc) for use with BSD Operating system

By 1991, the GNU mid-level portions of the operating system were almost complete, and the upper level could be supplied by the X Window System, but the lower level (kernel, device drivers, system-level utilities and daemons) was still mostly lacking

GNU developed it's free operating system called 'GNU Hurd' which was an ambitious design, unexpectedly difficult to implement and has only been marginally usable.

At another hand, Tanenbaum started MINIX for educational purpose, and was first released in 1987, with its complete source code made available to universities for study in courses and research, however still licencsed.

1991, Linus Torvalds, who was working for MINIX, almost copy the concept from MINIX (which was more a micro kernel) and made a monolithic kernal called Linux and use GNU free utilities to proivde a 'free operating system'.

As 'hurd' was still not triggering, GNU also adopted Linux as kernal around 1992. Basically Linux was the 'kernal part' and the operating system was 'GNU/Linux' Operating system.







Wednesday, August 5, 2015

How to add disk space into linux VM

In linux console, run 'ls /dev/sd*' and notice how many devices are there

shut the linux vm

Go to VM setting and add a new harddisk of specified size

boot the linux vm

again run 'ls /dev/sd*' and notice a new device (normally first device is called sda, another is sdb, another is sdc and so on )

Create partition using cmd 'sudo fdisk /dev/sdb' ... it will ask for partition... make a single big one.. it's name will be /dev/sdb1  /* n to create new partition, p for primary and w for write */

format the new partition using 'sudo mkfs -t ext3 /dev/sdb1'

Run 'sudo fdisk -l' to see if partition is done properly.

For mounting create a folder first like 'sudo mkdir /ws' (so i created a 'ws' folder under /)
now mount using 'sudo mount -t ext3 /dev/sdb1 /ws'

recheck using 'df -h'

Add this entry '/dev/sdb1 /software ext3 defaults 1 1' to etc/fstab file manually

reboot and see if you can still see your disk  :)

Saturday, June 6, 2015

Understanding RSA

RSA Algorithm



RSA Algorithm for Key-pair generation:

1) Choose 2 distinct prime numbers ‘p’ & ‘q’. Preferably large , random & of same bit size.
2) Compute  modulus  “n = p.q”.
3) Compute  F(n) = (p – 1) (q – 1) where is F(n) is Totient  function.
4) Choose an integer ‘e’ such that  1 < e < F(n) and e and F(n) are co-prime. ‘e’ is the Public key exponent.
5) Determine d multiply e = 1  mod F(n) ,the Private key exponent.

Public Key is modulus ‘n’ & exponent ‘e’ = (n, e).
Private Key is modulus ‘n’ & exponent ‘d’ = (n, d), the secret.

Encryption (Message ‘m’)

m power(e) (mod n) = c, the cipher text.

Decryption (Cipher text ‘c’)

c power(d) (mod n) = m, the original message.


Example:


RSA Algorithm for Key-pair generation:


1) Choose 2 distinct prime numbers ‘7’ & ‘13’. Preferably large , random & of same bit size.
2) Compute  modulus  “n = p . q = 91”.
3) Compute  F(n) = (p – 1) (q – 1) = 72 where is F(n) is Totient function.
4) Choose an integer ‘e’ such that  1 < e < F(n) and e and F(n) are co-prime. ‘e’ is the Public key exponent.
 e = {5,7, 11, 13, 17,...}. Let it be 5.
5) Determine  d multiply e = 1 mod(F(n))
5 multiple d = 1 mod (72)
5d = 1 (mod 72)  equals a set of candidates { …,29, 101, 173, …}. Chose d = 29.
Public Key is modulus ‘n=91’ & exponent ‘e=5’ = (91, 5).   [ Note: e.d = 1 mod (p-1 x q -1) ]
Private Key is modulus ‘n=91’ & exponent ‘d=29’ = (91, 29), the secret.
                        “Note: Factoring ‘n’ to find ‘p, ‘q’, & then ‘d’ is the hardest part(as of today)
                                     and strength of RSA (so far)”

Encryption (Message ‘10’)

10 power(5) (mod 91) = 82, the cipher text.

Decryption (Cipher text ‘82’)

82 power(29) (mod 91) = 10, the cipher text.