开发者

Make an install package for a Linux daemon

I'm using Ubuntu 11.04.

I'm working on a Linux daemon that will monitor my servers and send information to a central server. It will basically take a snapshot of key metrics every 5 minutes, redirect the output into a text file, and then put or post the data using CURL.

I'm writing this as a daemon using info I got from here: h开发者_运维问答ttp://kevin.vanzonneveld.net/techblog/article/create_daemons_in_php/. I was going to just write a CRONed shell script, but I'm going for broke, and besides PHP is a lot more familiar to me.

However, I want to go further and develop something that I can install using apt-get. I guess it would work as follows:

  1. I update my sources.list file
  2. I do something like apt-get install myservermonitor
  3. It installs my daemon in usr/bin/myservermonitor
  4. It installs an init.d script at /etc/init.d/myservermonitor
  5. It starts the daemon

I don't have any experience with this and would like to know how to go about it.

Regards,


Just get debhelper, it will create an example debian/ directory with templates for all the parts you need. Your daemon should probably go in /usr/sbin though. The postinst script is what you'd typically use to run the init script after successful configuration and installation.

If you need to configure something (say, the polling or reporting interval, or where to send reports) you also need to understand debconf, and create a configuration script.

To distribute your package, you need to set up your own repo, or find someone to host one for you. If your target is Ubuntu, I would suggest registering an account at Launchpad.net, and using their built-in PPA facility.

The intarwebs are shock full of tutorials; hopefully this is sufficient for a few Google searches to get you started.

Note that a .deb package will only work on Debian-compatible distros. If you want to target Linux generally, you should also offer an RPM package.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜