#!/bin/bash
#
# Copyright IBM Corp All Rights Reserved
#
# SPDX-License-Identifier: Apache-2.0
#
# This is a collection of bash functions used by different scripts
# imports
. scripts/utils.sh
export CORE_PEER_TLS_ENABLED=true
export ORDERER_CA=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
export PEER0_ORG1_CA=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export PEER0_ORG2_CA=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
export PEER0_ORG3_CA=${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
enVar.sh 是一个由不同脚本使用的Bash函数集合。脚本中的主要变量被设置为默认值,并导入了utils.sh脚本中的其他函数。其中包括设置CORE_PEER_TLS_ENABLED和ORDERER_CA环境变量的默认值,以及设置每个组织的PEER0_CA证书的默认值。这些变量和函数可以帮助在不同的脚本中操作Hyperledger Fabric网络。
# Set environment variables for the peer org
setGlobals() {
这是一个用来设置 peer 节点环境变量的函数,根据传入的参数 $1
来确定要使用的组织的 ID,然后设置相应的环境变量,包括本地 MSP ID、TLS 根证书文件路径、MSP 配置文件路径、节点地址等。在函数最后,如果 VERBOSE
环境变量被设置为 true
,则输出所有与 CORE 相关的环境变量。
local USING_ORG=""
local
是一个关键字,用于声明一个局部变量。这里声明了一个名为USING_ORG
的局部变量,并将其赋值为空字符串。local
关键字使变量的作用域仅限于当前函数中,这意味着其他函数不能访问该变量。
if [ -z "$OVERRIDE_ORG" ];