我有一个使用 cloud init 部署的 bash 脚本,我的 bash 脚本包含以下部分代码
GO111MODULE=on go install . ./cmd/...
当直接在已部署服务器的终端中运行我的 bash 脚本时,它按预期工作。但是当我在云配置中使用 run cmd 运行它时,脚本的这一部分:
GO111MODULE=on go install . ./cmd/...
没有被处决,有人知道为什么吗?
runcmd:
- [ bash, /usr/local/bin/myscript.sh ]
正确的 shell 执行runcmd
将是(如在云配置示例 https://cloudinit.readthedocs.io/en/latest/topics/examples.html):
- [ bash, -c, /usr/local/bin/myscript.sh ]
or:
- [ /usr/local/bin/myscript.sh ]
假设您的脚本以shebang https://en.wikipedia.org/wiki/Shebang_(Unix) #!/bin/bash
另外,您需要在脚本中添加任何环境变量,如下所示云配置示例 https://cloudinit.readthedocs.io/en/latest/topics/examples.html不要包含任何明显的设置方法。
#!/bin/bash
export GO111MODULE=on
export ...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)