Adding a service for a custom program in Solaris 10


Download PDF

dnmasqservice

 

 

This is another thing that I managed to forget, and then I had to remember what I was looking at all over again. Instead of init scripts, Solaris 10 uses services, or SMF. It uses a combination of XML and Shell scripts to start and stop services. In practice, it’s actually really slick and I enjoy using it. When Debian and most other Linux flavors adopted something similar it was a welcome change for me. Now if someone could just write a good service editor we’d be good to go. Hmm, maybe a future project if I find the time 😉

The reason this came up this time was for dnsmasq. The opencsw distribution has dnsmasq, but no service for it installs when you install the package. They have been pretty good about keeping up with this sort of thing however apparently with once that is not the case. It’s actually really easy to add a service when you use what you find on line as a template. Since I’m posting my files here as well as the links I used as a reference you’ll be able to spot the differences and modify my scripts for yourself.

First off is the reference material that I used to complete this. The first thing I found this time and last time was this post here: http://www.unix.com/solaris/32936-solaris-10-add-new-svc.html  Just a little bit down, a gentleman was kind enough to really break down the process. His downfall was when I tried to copy and paste his scripts for me to just quickly modify there was some typographical errors that cause the svcadm command to be unable to parse the file, and complain without a detailed error message. Basically there were a couple of 0’s that should have been ) ‘s ..

I also found this blog later, http://rojanu.wordpress.com/2011/11/28/create-a-new-solaris-10-service/ ,  which helped me get a comparison again of how some things work. If you are reading this page in hopes of putting together a service of your own I feel that you’ll succeed. Looking at these two pages you’ll get an idea of how the requirements work, how to pass messages to the user and so on.

here is my dnsmasq.xml located in /var/svc/manifest/site :

Here is my other script in /lib/svc/method/ :

The only other thing was dont forget to change the pkill user id to the one that matches the user of the process that you’re killing. Since the nobody user handles dnsmasq, that is the nobody user id number after the -u directive in pkill..

Anyways, I hope this helps someone else as well. Thanks for stopping in 😀

Adding a service for a custom program in Solaris 10
2 other peeps rated this an average of 4.

Leave a Reply

Your email address will not be published. Required fields are marked *