0

I have a script that automatically sets up an emailing server based off what I enter for the following

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

It then later installs Postfix DKIM key and asks me all the questions like secret password, name, email etc. How can I predetermine the text I will enter before the script starts?

Normally I just paste the following for the first script

daveis.com
5.196.24.211
yes
noreply@daveis.com

And then when Postfix command shows to create the key (openssl req -new -key smtpd.key -out smtpd.csr) I paste the following

somepass
somepass
somepass
GB
Berkshire
Newbury
DomainLLC
DomainLLC
mail.daveis.com
noreply@daveis.com
somepass
DomainLLC
somepass
somepass
somepass
somepass
GB
Berkshire
Newbury
DomainLLC
DomainLLC
mail.daveis.com
noreply@daveis.com
0

1 Answer 1

1

Use input from a file:

./your_script.sh < your_file_with_four_lines_of_input

or use a here document:

./your_script.sh << EOF
daveis.com
5.196.24.211
yes
noreply@daveis.com
EOF

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.