我正在AWS beanstalk上运行一个应用程序,并对我遇到的问题进行故障排除。部署的一部分将创建并执行shell脚本。当命令执行时,第一行可以正常工作。这只是一个简单的'cat file.txt >> /etc/httpd/file.conf‘命令。
第二行,我需要搜索一个文本字符串并将其放入文件中,但它从未成功运行过。我可以以root用户身份手动运行该脚本,没有任何问题。这是一个文件:
#! /bin/bash
if ! grep -q 'Clickjacking' /etc/httpd/conf/httpd.conf ;
then
cat /home/ec2-user/httpd-update.conf >> /etc/httpd/conf/httpd.conf
fi
# check if wsgi mod exists and insert into wsgi.conf if necessary
if ! grep -q 'TRACE|TRACK' /etc/httpd/conf.d/wsgi.conf;
then
sed -i -e '/WSGIProcessGroup wsgi/r /home/ec2-user/wsgi-update.conf' /etc/httpd/conf.d/wsgi.conf
fi
sudo service httpd reload
有人知道为什么sed
命令在部署Beanstalk时不能在shell脚本中工作吗?
发布于 2016-01-21 23:23:31
所以我没有意识到我们公司有AWS支持计划,于是联系了他们。我试图修改的文件也暂存在beanstalk中。因此,当我的文件在技术上得到更新时,Beanstalk正在将他们的暂存文件推向生产。您可以在beanstalk实例上运行此命令:
[root@ip-10-0-90-168 ~]# /opt/elasticbeanstalk/bin/get-config container | python -mjson.tool
{
"app_base_dir": "/opt/python/current",
"app_deploy_dir": "/opt/python/current/app",
"app_staging_base": "/opt/python/ondeck",
"app_staging_dir": "/opt/python/ondeck/app",
"app_user": "wsgi",
"app_virtual_env": "/opt/python/run/venv",
"base_path_dirs": "/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin",
"bundle_dir": "/opt/python/bundle",
"env_deploy_config": "/opt/python/current/env",
"env_staging_config": "/opt/python/ondeck/env",
"instance_port": "80",
"python_version": "2.7",
"source_bundle": "/opt/elasticbeanstalk/deploy/appsource/source_bundle",
"wsgi_deploy_config": "/etc/httpd/conf.d/wsgi.conf",
"wsgi_staging_config": "/opt/python/ondeck/wsgi.conf"
}
我试图更新的文件是最后一个。我需要对该文件运行我的命令,然后Amazon将推送该文件。
https://stackoverflow.com/questions/34778748
复制相似问题