Tuesday, March 17, 2020

The script to start and stop wordpress using docker

<code>
#!/bin/bash
netexist=$(docker network ls --format "{{.Name}}" -f "name=rccc")
if [[ $1 == "start" ]]; then
  if [[ -z $netexist ]]; then
    docker network create rccc
  fi
  docker run -d --name mysql --network rccc \
    -v $(pwd)/data:/var/lib/mysql \
    -e MYSQL_ROOT_PASSWORD=mysecret \
    -e MYSQL_DATABASE=wordpress \
    -e MYSQL_USER=tongli -e MYSQL_PASSWORD=secret \
    mysql:latest mysqld --default-authentication-plugin=mysql_native_password

  sleep 3

  while : ; do
    res=$(docker logs mysql 2>&1 | grep 'ready for connections')
      if [[ ! -z $res ]]; then
        break
      fi
      echo 'Waiting for mysql to be ready...'
      sleep 3
  done

  docker run -d --name rcccsite --network rccc \
    -v $(pwd)/content:/var/www/html \
    -e WORDPRESS_DB_HOST=mysql \
    -e WORDPRESS_DB_USER=tongli \
    -e WORDPRESS_DB_PASSWORD=secret \
    -e WORDPRESS_DB_NAME=wordpress \
    -p 8080:80 wordpress:latest

elif [[ $1 == "stop" ]]; then
  docker rm -f rcccsite mysql
  if [[ $netexist == "rccc" ]]; then
    docker network rm rccc
  fi
fi
</code>

Wednesday, March 11, 2020

IBM Blockchain Platform vscode extension wallet structure

File directory structure:

<root>/
    Admin/
        <hashcode>-priv
        <hashcode>-pub
        Admin -- this is a json file with the following structure
           {"name":"Admin",
             "mspid":"org0examplecom",
             "role": null, "affiliation": "",
             "enrollmentSecret": "",
             "enrollment": {
                  "signingIdentity": <hash, which used as the priv and pub name>,
                  "identity": {"certificate": "The plan new line contained certificate"}
             }
           }

Monday, March 9, 2020

New Go chaincode header import

import (
    "encoding/base64"
    "encoding/json"
    "fmt"
    "github.com/golang/protobuf/proto"
    "github.com/hyperledger/fabric-chaincode-go/shim"
    "github.com/hyperledger/fabric-protos-go/common"
    "github.com/hyperledger/fabric-protos-go/msp"
    pb "github.com/hyperledger/fabric-protos-go/peer"
    "math/rand"
    "time"
)