I'm trying to write a simple script to add some configuration at the top of of the file, and that's how I do this:
#! /bin/bash
sudo apt-get install monit
# BELOW IS THE CODE THAT I'M INTERESTING TO CHANGE
echo '
set eventqueue basedir /etc/monit/eventqueue/ slots 1000
set mmonit http://monit:monit@xxx.xxx.xxx.xxx:8080/collector
set httpd port 2812 and use address ec2-xxx.xxx.xx.xx.com
allow localhost
allow 0.0.0.0/0.0.0.0
allow admin:swordfish
' | sudo tee -a /etc/monit/monitrc_tmp
sudo cat /etc/monit/monitrc >> /etc/monit/monitrc_tmp
sudo rm /etc/monit/monitrc
sudo mv /etc/monit/monitrc_tmp /etc/monit/monitrc
# UP TO THIS POINT
sudo sed -i 's/set daemon 120/set daemon 20/' /etc/monit/monitrc
exit 0
As you can see I 'm trying to add some configuration at the top of the file. And just want to know is there any flag
or command
that will help me do this without creating a tmp
file.