shell - 已安装软件包时避免 yum 错误

标签 shell amazon-ec2 error-handling yum

我在 Linux 机器上使用 AWS Elastic Beanstalk,需要在 .ebextensions 中安装一些字体:

container_commands:
  01_getfont: 
    command: sudo yum -y install http://somesite.com/rpm/webcore-fonts-3.0-1.noarch.rpm

第一次效果很好,安装了字体。

第二次当我再次部署 EB 时,它现在给了我这个错误:

应用程序更新在 2019-01-28T23:44:14Z 失败,退出状态为 1 和错误:.ebextensions/fonts.config 中的 container_command 01_getfont 失败。
Loaded plugins: priorities, update-motd, upgrade-helper
Examining /var/tmp/yum-root-0Yx1DY/webcore-fonts-3.0-1.noarch.rpm: webcore-fonts-3.0-1.noarch
/var/tmp/yum-root-0Yx1DY/webcore-fonts-3.0-1.noarch.rpm: does not update installed package.
Error: Nothing to do. 

当该软件包第二次安装在同一个 EC2 实例上时,如何避免出现该错误?

最佳答案

后来我找到了这个问题的答案,将其张贴在这里以供其他有类似问题的人受益。

我改用重新安装:

sudo yum -y reinstall http://somesite.com/rpm/webcore-fonts-3.0-1.noarch.rpm

这将在第一次和所有其他部署时间起作用。

编辑:

如果未安装软件包,上述方法不起作用以及重新安装将失败。我最终检测到该软件包是否已安装,如果没有,请安装它,否则重新安装:
command: sudo yum -q list installed webcore-fonts.noarch &>/dev/null && sudo yum -y reinstall http://somesite.com/rpm/webcore-fonts-3.0-1.noarch.rpm || sudo yum -y install http://somesite.com/rpm/webcore-fonts-3.0-1.noarch.rpm

关于shell - 已安装软件包时避免 yum 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54412088/

相关文章:

linux - $?在 shell 脚本中

bash - 在 ksh 中比较字符串是否相等

amazon-web-services - 调用 HeadObject 操作时发生客户端错误 (400) : Bad Request Completed 1 part(s) with . .. 剩余文件

python - 如何在PyQt5中捕获libpng错误错误的自适应滤波器

scala - Scala试试,其他,除 block

unix - 记住 *nix 命令行参数

linux - Jenkins 如何处理交互式 Shell 脚本?

php - 如何在 aws lambda 中将 imagick 与 php 一起使用?

angular - 无法访问在 ubuntu 服务器上的端口上运行的项目

JavaScript try/catch 和 ajax 报告