Read a shell scripting tutorial like This one
is very good. I followed it and I started writting scripts right away.
Start writting the script and send specific questions if you get stuck.
You will learn more and may even have fun in the process.
I also recommend as a general good development practice to start small and grow your script from there. Don't try to write all at once. Set a list of 'tasks' to implement and implement and test one by one, e.g.
1. Grep an address from resolve.conf
Write this part test it until it works. Once it's working go to the next item in the list.
2. Based on the grep result execute and echo command (the echo command is just a stub for the real code that will be added later)
Add this part, test your script until this works, then go to the next item in the list
3. Remove the pid files
Add this part, test your script
This approach will allow you to learn the commands and play with them until you get the desired result.
(yes, yes, I know that this post was longer than writing the script, but I'm sure that will help you more)