Wednesday, May 31, 2017

gopath, goroot and path

I got quite confused about gopath, path and goroot when I started working on a project based on golang. Here is how I setup the environment

In ~/.profile, assume that golang was installed at /usr/local/go, your own project is at /home/ubuntu/hl, add the following

export GOPATH="/home/ubuntu/hl"
export GOROOT="/usr/local/go"
PATH="$GOROOT/bin:$GOPATH/bin:$PATH"

Monday, May 29, 2017

Disable Ubuntu automatic periodic updates


Change /etc/apt/apt.conf.d/10periodic and make that value to be 0 like below
APT::Periodic::Update-Package-Lists "0";
Then disable the following services:
systemctl disable apt-daily.timer
systemctl disable apt-daily.service

make ssh-agent run automatically

1. Start up the agent by adding the following in .profile, assume key file is called interop:

if [ -z "$SSH_AUTH_SOCK" ] ; then
  eval `ssh-agent -s`
  ssh-add ~/.ssh/interop
fi
2. Kill the agent when log out by adding the following in .bash_logout:
trap 'test -n "$SSH_AGENT_PID" && eval `/usr/bin/ssh-agent -k`' 0

Friday, May 26, 2017

what does g stand for in gRPC?



Each version of gRPC gets a new description of what the 'g' stands for, since we've never really been able to figure it out.
Below is a list of already-used definitions (that should not be repeated in the future), and the corresponding version numbers that used them:
1.0 'g' stands for 'gRPC'
1.1 'g' stands for 'good'
1.2 'g' stands for 'green'
1.3 'g' stands for 'gentle'
1.4 'g' stands for 'gregarious'

Wednesday, May 24, 2017

show git last commit changed files


The following command shows last commit changed files:

aa=$(git diff-tree --no-commit-id --name-only -r $(git log -2 --pretty=format:"%h") | sed 's%/[^/]*$%/%'| sort -u | awk '{print "github.com/hyperledger/fabric/"$1"..."}' | grep -v gitignore | while read kkk; do go list $kkk; done | sort -u)

git diff-tree --no-commit-id --name-only -r $(git log -2 --pretty=format:"%h")

Tuesday, May 23, 2017

Docker Docker Docker

Some useful docker commands:

Install docker
sudo apt-get install docker.io
Remove all docker images
docker rmi $(docker images -a -q)
Remove all exited containers and dangling images
docker rm $(docker ps -a -f status=exited -q)
docker rmi -f $(docker images -f "dangling=true" -q)
Stop all running containers
docker stop $(docker ps -a -q)
Connect to a running container
docker exec -it ContaineridOrName bash
Run a docker container and interact with the container
docker run -it --rm busybox
Normally a regular user can not run docker because of the permissions, the following command assume that a use group named "docker" has been created during the docker install, then you can the following command to add the current logged in user to the docker group, then refresh the group, the current user will be able to manipulate docker as the root user:
sudo gpasswd -a $USER docker
newgrp docker 
sudo chmod 666 /var/run/docker.sock 


Friday, May 19, 2017

how to build hyperledger fabric on Ubuntu

Here is the process to setup environment on ubuntu 16.04 to build Hyperledger fabric:

Highlight of the process
  • Install tools and dependencies such as git, pip, docker-composer, dev libraries etc.
  • Go - 1.7 or later (for releases before v1.0, 1.6 or later)
  • Docker - 1.12 or later
  • Docker Compose - 1.8.1 or later
  • Setup environment and extract hyperledger fabric code
  • Run the build
1.Install some dependencies first:
sudo apt-get update
sudo apt-get -y install python-dev python-pip libtool libltdl-dev
sudo pip install --upgrade pip
sudo pip install behave nose docker-compose protobuf couchdb==1.0
2.Install golang 1.7 or later from https://golang.org/doc/install by first download a version matching your environment, then run the command below:
tar -C /usr/local -xzf go1.8.1.linux-amd64.tar.gz

Do not forget adding the path to your PATH env.

PATH="/usr/local/go/bin:$PATH"
3.Install docker engine:
sudo apt-get install docker.io
4.Create a working directory and setup GOPATH:
mkdir -p ~/gopath/src/github.com/hyperledger
export GOPATH=~/gopath
5.Extract the source code to direct created in step 4:
git clone http://gerrit.hyperledger.org/r/fabric 
6.Build fabric binaries:
cd $GOPATH/src/github.com/hyperledger

make dist-clean all

or make individual target like this:

make peer

Wednesday, May 17, 2017

Getting Behave working on Ubuntu

Run the following commands to install behave on ubuntu:
sudo apt-get update
sudo apt-get install python-dev python-pip
sudo pip install --upgrade pip 
sudo pip install behave

Tuesday, May 16, 2017

How to install Jenkins on Ubuntu

Before you start, please make sure that you have java installed. If you do not have java already, please refer this link to install. http://idroot.net/linux/install-oracle-java-ubuntu-17-10/

1. First add the key to your system:
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key \
| sudo apt-key add - 
2. Then add the following entry in your /etc/apt/sources.list:
deb https://pkg.jenkins.io/debian binary/
3. Run the following two commands to install Jenkins:
sudo apt-get update
sudo apt-get install jenkins
4. If no errors during the above steps, you can find the generated admin password here:
/var/lib/jenkins/secrets/initialAdminPassword
5. Point a browser to the following URL and use the admin password found in step 4 to config Jenkins:
http://<<IP_Address_of_server>>:8080
6. Select some plugins to install from the Jenkins dashboard.
7. Create first admin username and password from the Jenkins dashboard.