Understand the Script

  1. The script starts by displaying a menu to choose a deployment option (Local or Server) and reads the user's choice.

+ echo 'Choose deployment option:'
Choose deployment option:
+ echo '1. Local'
1. Local
+ echo '2. Server'
2. Server
+ read -p 'Enter your choice (1/2): ' choice
Enter your choice (1/2): 
  1. The script creates a directory named "zus-repos" and navigates into it.

mkdir zus-repos
+ cd zus-repos
  1. The script declares an associative array named "arr" to store deployment commands.

 declare -A arr
  1. The script then populates the "arr" array with various Docker commands for pulling, tagging, and removing images for different services. These services include "sharder," "miner," "blobber," and "validator," and they are tagged with the "staging" version.

+ arr[0,0]='pull 0chaindev/sharder:staging'
+ arr[0,1]='tag 0chaindev/sharder:staging sharder'
+ arr[0,2]='image rm 0chaindev/sharder:staging'
+ arr[1,0]='pull 0chaindev/miner:staging'
+ arr[1,1]='tag 0chaindev/miner:staging miner'
+ arr[1,2]='image rm pull 0chaindev/miner:staging'
+ arr[2,0]='pull 0chaindev/blobber:staging'
+ arr[2,1]='tag 0chaindev/blobber:staging blobber'
+ arr[2,2]='image rm 0chaindev/blobber:staging'
+ arr[3,1]='pull 0chaindev/validator:staging'
+ arr[3,2]='tag 0chaindev/validator:staging validator'
+ arr[3,3]='image rm 0chaindev/validator:staging'
  1. The script then enters two nested loops with counters "i" and "j" to iterate through the "arr" array. These loops seem to be set up to execute the Docker commands stored in the array. Inside the loops, the script executes "docker pull" commands to pull Docker images for the specified services from the Docker Hub. After each "docker pull" command, it increments the "i" counter to move to the next command in the array and checks if it has completed all the commands for the current service.

+ docker pull 0chaindev/sharder:staging
staging: Pulling from 0chaindev/sharder
9621f1afde84: Pull complete
a2b0fab95789: Pull complete
77b50bae27c3: Pull complete


+ docker pull 0chaindev/miner:staging
staging: Pulling from 0chaindev/miner
951e1e941ca: Pull complete
3f67f767ac07: Pull complete
Digest: sha256:0d70ef0f24dd8bccd58e9553f30014aa5a259e92b5ba10ca2310b53a21ae4534
Status: Downloaded newer image for 0chaindev/miner:staging
docker.io/0chaindev/miner:staging

+ docker pull 0chaindev/blobber:staging
staging: Pulling from 0chaindev/blobber
96526aa774ef: Pull complete
97574bc8a632: Pull complete
92333ca1ae6e38728cf1ee53004bbebc36545c67be533b051Status: Downloaded newer image for 0chaindev/blobber:staging
docker.io/0chaindev/blobber:staging

What's Next?
  View a summary of image vulnerabilities.
+ (( i++ ))
+ (( i<=3 ))
+ docker
  1. Inside the loop, the script uses git clone to clone Git repositories specified in the repo array. It creates local copies of these repositories in the current working directory.

['1']='https://github.com/0chain/blobber.git' 
['2']='https://github.com/0chain/0dns.git')
+ git clone https://github.com/0chain/0chain.git
Cloning into '0chain'...
Cloning into 'blobber
+ git clone https://github.com/0chain/0dns.git
Cloning into '0dns'...
  1. The script changes the current working directory to a directory named 0dns.

if [ 1 == 1 ]: This appears to be a conditional statement, but it always evaluates to true since it compares the integer 1 with itself.

CONFIG_FILE=docker.local/config/0dns.yaml: A variable CONFIG_FILE is assigned a file path.

sed -i 's/use_https.*/use_https: false/' docker.local/config/0dns.yaml: This line uses the sed command to perform an in-place (in the file) search and replace operation in the 0dns.yaml file. It replaces a line containing "use_https" with "use_https: false."

sed -i 's/use_path.*/use_path: false/' docker.local/config/0dns.yaml: Similar to the previous line, this one replaces a line containing "use_path" with "use_path: false" in the same file.

+ cd 0dns
+ '[' 1 == 1 ']'
+ CONFIG_FILE=docker.local/config/0dns.yaml
+ sed -i 's/use_https.*/use_https: false/' docker.local/config/0dns.yaml
+ sed -i 's/use_path.*/use_path: false/' docker.local/config/0dns.yaml
  1. The script then build the 0dns container.

echo ' docker build'
docker.local/bin/build.sh 
docker.local/bin  
  1. The script then changes the current working directory to 0chain and executes various Docker-related scripts like 0dns start.sh script. setup.network.sh and init.setup.sh. These scripts are used for setting up and initializing a network related to the project.

+ cd ../0chain
docker:default+ docker.local/bin/setup.network.sh
ecacd3253b4bd7810fbe2444ce569c2f003bf21b1fc689964e6bd72096b8f105
+ cd ../0dns
+ docker.local/bin/start.sh                                                                              0.0s
+ cd ../0chain
+ docker.local/bin/init.setup.sh
  1. The script then automates the installation and setup of various tools and processes. Let's break it down step by step: echo 'Mocks Installation and Creation Phase': This line simply prints the text "Mocks Installation and Creation Phase" to the standard output.

  • echo '': This line prints an empty line, likely for formatting purposes.

  • curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh: This line uses the curl command to download a script and install Homebrew, a package manager for macOS and Linux.

  • /bin/bash -c ...: This line executes the downloaded script using the Bash shell. The script appears to install Homebrew and provides information about the installation, including its success and some additional details about Homebrew.

  • /home/linuxbrew/.linuxbrew/bin/brew shellenv: This line seems to run the brew shellenv command, which is likely setting up the environment for Homebrew.

  • brew doctor: This command checks the system's configuration and environment to ensure that it is ready to use Homebrew.

  • echo 'Install Mockery In Progress': This line prints the text "Install Mockery In Progress."

  • brew install mockery: This command uses Homebrew to install a tool or package called "mockery."

  • echo 'Install Mockery In Completed': This line prints the text "Install Mockery In Completed."

  • echo 'Build-Mocks in progress': This line prints the text "Build-Mocks in progress."

  • make build-mocks: This command likely invokes a make target called "build-mocks" to build something, presumably related to mock objects or mock data.

  • echo 'Build-Mocks completed': This line prints the text "Build-Mocks completed."

+ echo ' Mocks Installtion and Creation Phase'
 Mocks Installtion and Creation Phase
+ echo ''
++ curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
+ /bin/bash -c '#!/bin/bash
==> Downloading and installing Homebrew...
HEAD is now at 4e2c9adc2 Merge pull request #16131 from Homebrew/sponsors-maintainers-man-completions
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics data has been sent yet (nor will any be during this install run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations

==> Next steps:
- Install Homebrew's dependencies if you have sudo access:
    sudo apt-get install build-essential
  For more information, see:
    https://docs.brew.sh/Homebrew-on-Linux
- We recommend that you install GCC:
    brew install gcc
- Run brew help to get started
- Further documentation:
    https://docs.brew.sh

++ /home/linuxbrew/.linuxbrew/bin/brew shellenv
+ eval ''
+ brew doctor
Your system is ready to brew.
+ echo 'Install Mockery In Progress'
Install Mockery In Progress
+ brew install mockery
+ echo 'Install Mockery In Completed'
Install Mockery In Completed
+ echo 'Build-Mocks in progress'
Build-Mocks in progress
+ make build-mocks
+ echo ' Build-Mocks completed'
 Build-Mocks completed

Last updated