【问题标题】:How to override AWS Elastic Beanstalk default "Message of the day"如何覆盖 AWS Elastic Beanstalk 默认的“每日消息”
【发布时间】:2019-06-19 08:17:58
【问题描述】:

Elastic beanstalk 用于在 ec2 实例中部署 docker 容器。因此 ec2 实例由弹性 beantalk 控制。

使用 .ebextensions 设置,我可以在我的 ec2 实例中更改文件 /var/lib/update-motd/motd。

使用:

files: 
      /var/lib/update-motd/motd: 
        content: |

            The Custom Message
            # Menu
            > app   [open docker info]
            > logs  [Print logs from Rails app]

        group: root
        mode: "000644"
        owner: root

但是每天这都会被清除,并且 EB 默认消息在那里! 如何确保我的自定义 motd 保留在那里??

【问题讨论】:

  • /var/lib/update-motd/motd 是您应该覆盖的文件吗?对我来说,目录名称意味着update-motd 子系统可能会覆盖它。
  • 谢谢@Michael-sqlbot,你的回答让我在 /etc/update-motd.d/ 中找到了 10eb-banner 现在我的设置仍然存在,因为我正在更改它而不是 motd /等

标签: amazon-ec2 amazon-elastic-beanstalk


【解决方案1】:

我认为使这个 motd 持久化的一种方法是在 motd 中添加一些东西,然后远程更新包 update-motd。
创建文件 .ebextension/000update-motd.config

files:
  "/home/ec2-user/updatemotd.sh" :
    mode: "000777"
    owner: root
    group: root
    content: |
      #!/bin/bash
      yum erase -y update-motd ; unlink /etc/motd
      yum install -y figlet 
      echo `{"Ref": "AWSEBEnvironmentName" }` | figlet -f standard > /etc/motd

commands:
  updatemotd:
    command: "/home/ec2-user/updatemotd.sh"

【讨论】:

  • 感谢您的回答。我发现源文件在:/etc/update-motd.d/。通过直接更改它们 motd-changes 被持久化。
【解决方案2】:

https://blog.eq8.eu/til/elasticbeanstalk-update-ssh-welcome-message-motd.html

创建文件.ebextensions/91_update_motd_welcome_message_after_ssh.config

添加内容

files:
  "/tmp/20-custom-welcome-message":
    mode: "000755"
    owner: root
    group: root
    content: |
      cat << EOF
      THIS WILL BE YOUR WELCOME MESSAGE
      EOF

commands:
  80_tell_instance_to_regenerate_motd:
    command: mv /tmp/20-custom-welcome-message /etc/update-motd.d/20-custom-welcome-message

  99_tell_instance_to_regenerate_motd:
    command: /usr/sbin/update-motd

这将在 ElasticBeanstalk 消息后添加额外消息

如果您想覆盖原始消息,请将文件名从 20-custom-welcome-message 更改为 10eb-banner

【讨论】:

    猜你喜欢
    • 2019-01-23
    • 1970-01-01
    • 2014-06-01
    • 2020-01-17
    • 2022-08-19
    • 2019-03-20
    • 2014-03-05
    • 2014-04-04
    • 1970-01-01
    相关资源
    最近更新 更多