AWS :: CloudFormation :: Init-无法使用bash脚本配置IPFS

时间:2018-10-29 05:34:45

标签: amazon-web-services amazon-ec2 amazon-cloudformation ipfs

借助AWS区块链模板,我已经在AWS上部署了以太坊区块链网络。 https://docs.aws.amazon.com/blockchain-templates/latest/developerguide/blockchain-templates-ethereum.html

现在,我想在同一以太坊网络上配置IPFS(行星际文件系统),因此我修改了模板,将AWS :: CloudFormation :: Init添加到了自动缩放组模板,并试图通过它执行工作和测试过的bash脚本。

AWS::CloudFormation::Init:
    config:
      files:
        '/tmp/IPFS_install.sh':
          content: |
            #!/bin/bash -e
            sudo yum install wget -y;
            wget https://dist.ipfs.io/go-ipfs/v0.4.17/go-ipfs_v0.4.17_linux-amd64.tar.gz;
            tar -xzvf go-ipfs_v0.4.17_linux-amd64.tar.gz;
            cd /go-ipfs
            sudo ./install.sh;
            ipfs init;
            ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
            ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
            ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["GET", "POST"]'
            ipfs config --json API.HTTPHeaders.Access-Control-Allow-Headers '["Authorization"]'
            ipfs config --json API.HTTPHeaders.Access-Control-Expose-Headers '["Location"]'
            ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials '["true"]'
            ipfs daemon & 
            sleep 20
            ipfs bootstrap rm --all
            exit
          mode: '000755'
          owner: root
          group: root
      commands:
        install_ipfs:
          command: /tmp/IPFS_install.sh

在具有完全相同权限的EC2实例上手动执行时,相同脚本绝对可以正常工作,但是在通过CF模板执行时,@ ipfs init; 失败,并显示错误 ipfs:找不到命令

在下面找到cfn-init日志:

[DEBUG] CloudFormation client initialized with endpoint 
https://cloudformation.us-west-2.amazonaws.com
2018-10-16 07:22:20,288 [DEBUG] Describing resource ABC in stack XYZ
2018-10-16 07:22:20,402 [INFO] -----------------------Starting build-------- 
---------------
2018-10-16 07:22:20,402 [DEBUG] Not setting a reboot trigger as scheduling 
support is not available
2018-10-16 07:22:20,403 [INFO] Running configSets: default
2018-10-16 07:22:20,404 [INFO] Running configSet default
2018-10-16 07:22:20,404 [INFO] Running config config
2018-10-16 07:22:20,404 [DEBUG] No packages specified
2018-10-16 07:22:20,405 [DEBUG] No groups specified
2018-10-16 07:22:20,405 [DEBUG] No users specified
2018-10-16 07:22:20,405 [DEBUG] No sources specified
2018-10-16 07:22:20,405 [DEBUG] Writing content to /tmp/IPFS_install.sh
2018-10-16 07:22:20,405 [DEBUG] Setting mode for /tmp/IPFS_install.sh to 000755
2018-10-16 07:22:20,405 [DEBUG] Setting owner 0 and group 0 for /tmp/IPFS_install.sh
2018-10-16 07:22:20,405 [DEBUG] Running command install_ipfs
2018-10-16 07:22:20,406 [DEBUG] No test for command install_ipfs
2018-10-16 07:22:25,301 [ERROR] Command install_ipfs (/tmp/IPFS_install.sh) failed
2018-10-16 07:22:25,301 [DEBUG] Command install_ipfs output: Loaded plugins: priorities, update-motd, upgrade-helper
.
.
.
.
2018-10-16 07:22:24 (10.5 MB/s) - ‘go-ipfs_v0.4.17_linux-amd64.tar.gz’ saved [10726868/10726868]
go-ipfs/build-log
go-ipfs/install.sh
go-ipfs/ipfs
go-ipfs/LICENSE
go-ipfs/README.md
Moved ./ipfs to /usr/local/bin
/tmp/IPFS_install.sh: line 7: ipfs: command not found
2018-10-16 07:22:25,301 [ERROR] Error encountered during build of config: Command install_ipfs failed

尝试将所有者和组设置为ec-user,但输出相同。另外,我在某处读到cfn-init以root用户身份运行,因此决定将所有者和组作为root用户使用。

我真的希望它能正常工作,解决该问题的任何帮助都将受到赞赏。

预先感谢您的支持。

0 个答案:

没有答案