Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

21.4.5. 使用 guestfish 进行 shell 脚本

熟悉了使用 guestfish 时,根据您的需要以互动方式使用 guestfish,编写带有它的 shell 脚本会很有用。以下是向客户机添加新的 MOTD(日期消息)的简单 shell 脚本:
#!/bin/bash -
 set -e
 guestname="$1"

 guestfish -d "$guestname" -i <<'EOF'
   write /etc/motd "Welcome to Acme Incorporated."
   chmod 0644 /etc/motd
 EOF