# Any extra options go here
EXTRA_CONFIGS='--sysconfdir=/etc --with-initdir=/etc/rc.d --with-lockfile=/var/run/nagios.pid'
# STD_FLAGS='-O2 -march=i486 -mtune=i686'
INSTALL_LINE='make install install-config install-init'
# Get the functions and configs
. /usr/libexec/src2pkg/FUNCTIONS ;
# do_all_processes can substitute these 16 steps:
# see notes
# see notes
chown -R nagios:nagios $PKG_DIR/opt/nagios
When you need to run multiple make rules put them all together as shown for INTALL_LINE. For EXTRA_CONFIGS you might consider adding the options for --with-htmlurl and perhaps for nagios-user/nagios-group and command-user/command-group depending on who you want to allow to run the program. Usually, if the program is a sort of daemon, you'd make the user 'nobody' in Slackware with group users.
Do the chowning after the fix_pkg_perms to 'undo' the regular way, although I think that the normal root:root may be correct in this case.
This should be done after fake_install:
mv $PKG_DIR/etc/rc.d/nagios $PKG_DIR/etc/rc.d/rc.nagios
Usually, these init files need to be hand edited in order to work properly with Slackware, though in this case it looks like it might just work, if you have given enough of the needed extra options to configure and if you have the latest slack init-scripts which include the /etc/rc./init.d/finctions file. For better compatibility with Slack-11 and just for better control, you should consider hand-editing the init file and then copy it into the $PKG_DIR/etc/rc.d directory after fake_install runs, something like:
rm -f $PKG_DIR/etc/rc.d/nagios
cp $CWD/rc.nagios $PKG_DIR/etc/rc.d/
chown root:root $PKG_DIR/etc/rc.d/rc.nagios
chmod 644 $PKG_DIR/etc/rc.d/rc.nagios
#Create User and Group Nagios
useradd nagios -g nagios
The commands to create a new user and group should, most properly go in a doinst.sh file which gets run when the package is installed. Use grep to make sure that the user and group don't already exist, so that you don't get multiple entries if you install the package several times.
if [ $(grep nagios /etc/group) != "" ] ; then
if [ $(grep nagios /etc/passwd) != "" ] ; then
useradd nagios -g nagios
Build the package first without any doinst.sh file to see whether src2pkg produces one. If the 'make install' rules create any links then src2pkg will create a doinst.sh for you with the code for creating the links when the package is installed. You can then add the above code for group/useradd to that doinst.sh. You may also want to add code which echos a couple of lines into /etc/rc.d/rc.local which check to see if /etc/rc.d/rc.nagios is executable and which start the service if it is. Use the example from webmin for code sample.
A little trick: if the package indeed creates links, you can preserve the ability to have src2pkg add them automatically by placing any other code you want added to the doinst.sh in a file named doinst.prepend or doinst.append, depending on whether you want the code before or after the link-creation lines. This is most handy for packages whose link-creation lines change when you build a new version -usually for libs, so that may not be the case here. Once you place a file named doinst.sh in the $CWD it will be added to the package *without changes*.
I won't 'steal your thunder' by doing the whole thing for you this time-you seem to want to learn more and besides, I'm in the middle of adding serious new code to src2pkg so my running version is only semi-functional at the moment. the webmin package should give you some good examples.
One other thing, nagios appears to support using DESTDIR, so if you have any problems getting it to install correctly as shown above, you could always comment out the fake_install line and put this in its' place:
mkdir -p $PKG_DIR/$PRE_FIX
cd $SRC_DIR && make DESTDIR=$PKG_DIR install install-config install-init