脚本介绍

为了方便用户使用,WeCross提供了丰富的脚本,所有脚本编译后都位于dist目录,本章节将对这些脚步做详细介绍。

启动脚本

start.sh

启动脚本start.sh用于启动WeCross服务,启动过程中的完整信息记录在start.out中。

bash start.sh

成功输出:

Wecross start successfully

失败输出:

WeCross start failed 
See logs/error.log for details 

停止脚本

stop.sh

停止脚本stop.sh用于停止WeCross服务。

bash  stop.sh

构建WeCross脚本

build_wecross.sh

生成WeCross跨链路由网络

Usage:
    -n  <network id>                [Required]   set network ID
    -l  <ip:rpc-port:p2p-port>      [Optional]   "ip:rpc-port:p2p-port" e.g:"127.0.0.1:8250:25500"
    -f  <ip list file>              [Optional]   split by line, every line should be "ip:rpc-port:p2p-port". eg "127.0.0.1:8250:25500"
    -c  <ca dir>                    [Optional]   dir of existing ca
    -o  <output dir>                [Optional]   default ./${router_output}/
    -z  <generate tar packet>       [Optional]   default no
    -T  <enable test mode>          [Optional]   default no. Enable test resource.
    -h  call for help
e.g
    bash $0 -n payment -l 127.0.0.1:8250:25500
    bash $0 -n payment -f ipfile
  • -n:指定跨链网络标识

  • -l:指定生成一个跨链路由,与-f二选一,单行,如:192.168.0.1:8250:25500

  • -f:指定生成多个跨链路由,与-l二选一,多行,不可有空行,例如:

    192.168.0.1:8250:25500
    192.168.0.1:8251:25501
    192.168.0.2:8252:25502
    192.168.0.3:8253:25503
    192.168.0.4:8254:25504 
    
  • -o:指定跨链路由生成目录,默认wecross/
  • -z:若设置,则生成跨链路由的压缩包,方便拷贝至其它机器
  • -T:若设置,生成的跨链路由开启测试资源
  • -h:打印Usage

创建FISCO BCOS stub配置文件脚本

脚本create_bcos_stub_config.sh用于快速创建FISCO BCOS stub的配置文件。

可通过-h查看帮助信息:

Usage:
    -r  <root dir>        [Required]    specify the stubs root dir
    -o  <stub name>       [Required]    specify the name of stub
    -d  <conf path>       [Required]    specify the path of conf dir
    -p  <password>        [Optional]    password for p12 a type of FISCO BCOS account, default is null and use pem
    -h  call for help
e.g
    bash create_bcos_stub_config -r stubs -o bcos -d conf -p 123456
  • -r: 指定配置文件根目录,需要和配置文件wecross.toml中的[stubs.path]保存一致。
  • -o: 指定区块链跨链标识,即stub的名字;同时也会在**-r**指定的目录下生成与stub相同名字的目录来保存配置文件。
  • -d: 指定加载配置文件时的classpath路径,所有的配置文件都保存在该路径下,默认为与启动脚本同级的conf目录。
  • -p: 表示使用p.12格式的账户文件,并指定口令。默认是pem格式,无需口令。

例如:

bash create_bcos_stub_config.sh -r stubs -o bcos -d conf -p 123456

执行结果的目录结构如下:

.
├── conf
│   └── stubs
│       └── bcos
│           ├── 0x7c459bb9e35c90cf5a64b562b41c2efa951b9845.p12
│           └── stub.toml

创建Fabric stub配置文件脚本

脚本create_fabric_stub_config.sh用于快速创建Fabric stub的配置文件。

可通过-h查看帮助信息:

Usage:
    -r  <root dir>        [Required]    specify the stubs root dir
    -o  <stub name>       [Required]    specify the name of stub
    -d  <conf path>       [Required]    specify the path of conf dir
    -h  call for help
e.g
    bash create_fabric_stub_config -r stubs -o fabric -d conf
  • -r: 指定配置文件根目录,需要和配置文件wecross.toml中的[stubs.path]保存一致。
  • -o: 指定区块链跨链标识,即stub的名字;同时也会生成相同名字的目录来保存配置文件。
  • -d: 指定加载配置文件时的classpath路径,所有的配置文件都保存在该路径下,默认为与启动脚本同级的conf目录。

例如:

bash create_fabric_stub_config -r stubs -o fabric -d conf

执行结果的目录结构如下:

.
├── conf
│   └── stubs
│       └── fabric
│           └── stub.toml

创建JDChain stub配置文件脚本

脚本create_jdchain_stub_config.sh用于快速创建JDChain stub的配置文件。

可通过-h查看帮助信息:

Usage:
    -r  <root dir>        [Required]    specify the stubs root dir
    -o  <stub name>       [Required]    specify the name of stub
    -d  <conf path>       [Required]    specify the path of conf dir
    -h  call for help
e.g
    bash create_jdchain_stub_config.sh -r stubs -o jd -d conf
  • -r: 指定配置文件根目录,需要和配置文件wecross.toml中的[stubs.path]保存一致。
  • -o: 指定区块链跨链标识,即stub的名字;同时也会生成相同名字的目录来保存配置文件。
  • -d: 指定加载配置文件时的classpath路径,所有的配置文件都保存在该路径下,默认为与启动脚本同级的conf目录。

例如:

bash create_jdchain_stub_config.sh -r stubs -o jd -d conf

执行结果的目录结构如下:

├── conf
│   └── stubs
│       └── jd
│           └── stub.toml

创建P2P证书脚本

create_cert.sh

创建P2P证书脚本create_cert.sh用于创建P2P证书文件。WeCross Router之间通讯需要证书用于认证,只有具有相同ca.crt根证书的WeCross Router直接才能建立连接。

可通过-h查看帮助信息:

Usage:
    -c                                  [Optional] generate ca certificate
    -C <number>                         [Optional] the number of node certificate generated, work with '-n' opt, default: 1
    -D <dir>                            [Optional] the ca certificate directory, work with '-n', default: './'
    -d <dir>                            [Required] generated target_directory
    -n                                  [Optional] generate node certificate
    -t                                  [Optional] cert.cnf path, default: cert.cnf
    -h                                  [Optional] Help
e.g
    bash create_cert.sh -c -d ./ca
    bash create_cert.sh -n -D ./ca -d ./ca/node
    bash create_cert.sh -n -D ./ca -d ./ca/node -C 10
  • c: 生成ca证书,只有生成了ca证书,才能生成节点证书。
  • n: 生成节点证书。
  • C: 配合-n,指定生成节点证书的数量。
  • D: 配合-n,指定ca证书路径。
  • d: 指定输出目录。
  • t: 指定cert.cnf的路径