预先确定脚本输入文本

预先确定脚本输入文本

我有一个脚本,可以根据我输入的以下内容自动设置电子邮件服务器

echo "Please enter your main domain: (Ex.: website.com)"
read DOMINIO
if [ $DOMINIO = "" ]; then
    echo "Enter the main domain of your server"
    echo "Run the script again"
    exit
fi
echo "Enter your main IP: (Ex.: 192.1.1.1)"
read SRVIP
if [ $SRVIP = "" ]; then
    echo "Enter main IP"
    echo "Run the script again"
    exit
fi

echo "Install Interspire? (yes/no)"
read INTERSPIRE

echo "Please enter a valid email address:)"
read VEMAIL
if [ $VEMAIL = "" ]; then
    echo "Enter valid email address:)"
    read VEMAIL
fi
echo -e "Script will begin installation in 5 seconds"
echo -e "Use CTRL + C to cancel!"
sleep 5
echo $DOMINIO > /tmp/domain.info
sed -i "s/ //g" /tmp/domain.info
sed -i "/^[ \t]*$/d" /tmp/domain.info

然后它会安装 Postfix DKIM 密钥并询问我所有问题,例如秘密密码、姓名、电子邮件等。我如何在脚本启动之前预先确定要输入的文本?

通常我只是将以下内容粘贴到第一个脚本中

daveis.com
5.196.24.211
yes
[email protected]

然后当 Postfix 命令显示创建密钥 ( openssl req -new -key smtpd.key -out smtpd.csr) 时,我粘贴以下内容

somepass
somepass
somepass
GB
Berkshire
Newbury
DomainLLC
DomainLLC
mail.daveis.com
[email protected]
somepass
DomainLLC
somepass
somepass
somepass
somepass
GB
Berkshire
Newbury
DomainLLC
DomainLLC
mail.daveis.com
[email protected]

答案1

使用文件中的输入:

./your_script.sh < your_file_with_four_lines_of_input

或使用这里的文档:

./your_script.sh << EOF
daveis.com
5.196.24.211
yes
[email protected]
EOF

相关内容