From ce7d5f1a3afe34c78d15f28930e94688d4eafa0f Mon Sep 17 00:00:00 2001 From: Eric Stanley Date: Fri, 16 Dec 2011 10:25:44 -0600 Subject: Updated Solaris package creation to newer standards The Solaris package creation has been updated to newer standards to match those of the NRPE package. The following changes have been made: - the plugins now install under /opt/nagios - the name of package is now NGOSplugin - the files installed are now owned by the nagios user - the package includes a pre-installation script that creates a nagios user and a nagios group if one did not previously exist --- pkg/solaris/preinstall | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 pkg/solaris/preinstall (limited to 'pkg') diff --git a/pkg/solaris/preinstall b/pkg/solaris/preinstall new file mode 100755 index 00000000..c4cc2690 --- /dev/null +++ b/pkg/solaris/preinstall @@ -0,0 +1,35 @@ +#!/usr/bin/sh + +user="nagios" +uid=-1 +group="nagios" +gid=-1 + +/usr/bin/getent group $group > /dev/null 2> /dev/null +result=$? +if [ $result -eq 2 ] ; then + echo "Group $group does not exist. Creating..." + if [ $gid -ne -1 ] ; then + /usr/sbin/groupadd -g $gid $group + else + /usr/sbin/groupadd $group + fi +elif [ $result -ne 0 ] ; then + echo "An error occurred determining the existence of the groug $group. Terminating." + exit 1; +fi + +/usr/bin/getent passwd $user > /dev/null 2> /dev/null +result=$? +if [ $result -eq 2 ] ; then + echo "User $user does not exist. Creating..." + if [ $uid -ne -1 ] ; then + /usr/sbin/useradd -u $uid -g $group $user + else + /usr/sbin/useradd -g $group $user + fi +elif [ $result -ne 0 ] ; then + echo "An error occurred determining the existence of the user $user. Terminating." + exit 1; +fi + -- cgit v1.2.3-74-g34f1 From 48b42a6d1d43ebae3f9a671148356301d337270e Mon Sep 17 00:00:00 2001 From: Eric Stanley Date: Fri, 16 Dec 2011 10:29:48 -0600 Subject: Commit files which were inadvertently omitted from the previous commit. --- Makefile.am | 1 + pkg/solaris/pkginfo.in | 2 +- pkg/solaris/solpkg | 10 +++++++--- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'pkg') diff --git a/Makefile.am b/Makefile.am index b6e5f2ec..8e2de783 100644 --- a/Makefile.am +++ b/Makefile.am @@ -46,6 +46,7 @@ solpkg: $(MAKE) all $(MAKE) DESTDIR=$$PWD/$(BUILDDIR) install $(INSTALL) pkg/solaris/pkginfo $(BUILDDIR) + $(INSTALL) pkg/solaris/preinstall $(BUILDDIR) cd $(BUILDDIR) && $(PERL) ../$(PKGSCRIPT) ../$(PACKDIR) THANKS: THANKS.in diff --git a/pkg/solaris/pkginfo.in b/pkg/solaris/pkginfo.in index c9dcced0..3bed3464 100644 --- a/pkg/solaris/pkginfo.in +++ b/pkg/solaris/pkginfo.in @@ -1,4 +1,4 @@ -PKG="NAGplugin" +PKG="NGOSplugin" NAME="nagios-plugins" DESC="Nagios network monitoring plugins" ARCH="@PKG_ARCH@" diff --git a/pkg/solaris/solpkg b/pkg/solaris/solpkg index 41d8e177..6307bcd7 100755 --- a/pkg/solaris/solpkg +++ b/pkg/solaris/solpkg @@ -8,6 +8,7 @@ $pkgmk = "/usr/bin/pkgmk"; $pkgtrans = "/usr/bin/pkgtrans"; $prototype = "prototype"; $pkginfo = "pkginfo"; +$preinstall = "preinstall"; $egrep = "/usr/bin/egrep"; # Sanity check @@ -24,17 +25,19 @@ open (PREPROTO,"$find . -print |$egrep -v \"^\.(/usr(/local)?|/opt)?\$\" | $pkgp open (PROTO,">$prototype") || die "Unable to write file prototype ($!)\n"; print PROTO "i pkginfo=./$pkginfo\n"; +print PROTO "i preinstall=./$preinstall\n"; while () { # Read in the prototype information chomp; $thisline = $_; if ($thisline =~ " prototype " - or $thisline =~ " pkginfo ") { + or $thisline =~ " pkginfo " + or $thisline =~ " preinstall ") { # Don't do anything as they aren't important } elsif ($thisline =~ "^[fd] ") { # Change the ownership of files and directories ($dir, $none, $file, $mode, $user, $group) = split / /,$thisline; - print PROTO "$dir $none $file $mode bin bin\n"; + print PROTO "$dir $none $file $mode $user bin\n"; } else { # Symlinks and other stuff should be printed also print PROTO "$thisline\n"; @@ -58,6 +61,7 @@ while () { $thisline = $_; ($var,$value) = split /=/,$thisline; if ("$var" eq "NAME" + or "$var" eq "PKG" or "$var" eq "VERSION" or "$var" eq "ARCH") { $tmp = lc($var); @@ -77,5 +81,5 @@ $packagename = "$name-$version-$os-$arch-local"; print "Building package\n"; system ("$pkgmk -o -r `pwd` -d $pkgdevice"); -system ("(cd $pkgdevice && $pkgtrans -s `pwd` ../$packagename)"); +system ("(cd $pkgdevice && $pkgtrans -s `pwd` ../$packagename $pkg)"); print "Done. ($packagename)\n"; -- cgit v1.2.3-74-g34f1 From 355ad150eb4ba18d1e863c34c85e60a20f7c710d Mon Sep 17 00:00:00 2001 From: Eric Stanley Date: Fri, 20 Jan 2012 06:49:49 -0600 Subject: Added pst3 to Solaris package. --- Makefile.am | 1 + pkg/solaris/solpkg | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'pkg') diff --git a/Makefile.am b/Makefile.am index 8e2de783..ce6ae6ab 100644 --- a/Makefile.am +++ b/Makefile.am @@ -45,6 +45,7 @@ solpkg: if [ ! -d $(PACKDIR) ] ; then mkdir $(PACKDIR); fi $(MAKE) all $(MAKE) DESTDIR=$$PWD/$(BUILDDIR) install + $(INSTALL) plugins-root/pst3 $(BUILDDIR)$(libexecdir) $(INSTALL) pkg/solaris/pkginfo $(BUILDDIR) $(INSTALL) pkg/solaris/preinstall $(BUILDDIR) cd $(BUILDDIR) && $(PERL) ../$(PKGSCRIPT) ../$(PACKDIR) diff --git a/pkg/solaris/solpkg b/pkg/solaris/solpkg index 6307bcd7..a21176e4 100755 --- a/pkg/solaris/solpkg +++ b/pkg/solaris/solpkg @@ -34,6 +34,11 @@ while () { or $thisline =~ " pkginfo " or $thisline =~ " preinstall ") { # Don't do anything as they aren't important + } elsif ($thisline =~ "pst3") { + # Needs to be installed SUID root + ($dir, $none, $file, $mode, $user, $group) = split / /,$thisline; + print PROTO "$dir $none $file 4755 root bin\n"; + } elsif ($thisline =~ "^[fd] ") { # Change the ownership of files and directories ($dir, $none, $file, $mode, $user, $group) = split / /,$thisline; -- cgit v1.2.3-74-g34f1