Script needed to check then restart application processes
I am trying to come up with a script that will do the
1. Overwrites a word in a text file.
2. Then Stops an Apache server running.
3. Then checks the status of the Apache server to make sure it is stopped
4. If it is stopped then it restarts apache server.
5. Then restores the text file to its original state.
I have been looking at using:
1. sed s/$VARIABLE1/"$VARIABLE2"/g conf.txt
2. apachectl stop
3. apachectl status
4. apachectl start
5. sed s/$VARIABLE2/"$VARIABLE1"/g conf.txt
I'm new to shell scripting so I don't know how to tie this together or if I am even using the correct approach.
Any ideas appreciated.