Title: [opsview-base] [302] Solaris: Allow for admin providing GID's and UID's
Revision
302
Author
dferguson
Date
2013-07-08 13:38:50 +0100 (Mon, 08 Jul 2013)

Log Message

Solaris: Allow for admin providing GID's and UID's

Allow for use of a pkgask file on Solaris to specify the GID and UID used for groups and user created (group: nagios. cagcmd, user: nagios) in the Opsview agent

Modified Paths

Modified: trunk/solaris_pkg/preinstall.ALTovagent
===================================================================
--- trunk/solaris_pkg/preinstall.ALTovagent	2013-07-03 12:31:33 UTC (rev 301)
+++ trunk/solaris_pkg/preinstall.ALTovagent	2013-07-08 12:38:50 UTC (rev 302)
@@ -1,19 +1,32 @@
 
 die() { echo $1; exit 1; }
 
+if [ "x$GID_NAGIOS" != "x" ]; then
+	GID_NAGIOS="-g $GID_NAGIOS"
+fi
+
+if [ "x$GID_NAGCMD" != "x" ]; then
+	GID_NAGCMD="-g $GID_NAGCMD"
+fi
+
+if [ "x$UID_NAGIOS" != "x" ]; then
+	UID_NAGIOS="-u $UID_NAGIOS"
+fi
+
 /usr/sbin/chroot $BASEDIR /usr/bin/getent group nagios 1>/dev/null
 if [ $? != 0 ]; then
-	/usr/sbin/chroot $BASEDIR /usr/sbin/groupadd nagios || die "Unable to add group 'nagios'"
+	/usr/sbin/chroot $BASEDIR /usr/sbin/groupadd $GID_NAGIOS nagios || die "Unable to add group 'nagios'"
 fi
 
 /usr/sbin/chroot $BASEDIR /usr/bin/getent group nagcmd 1>/dev/null
 if [ $? != 0 ]; then
-	/usr/sbin/chroot $BASEDIR /usr/sbin/groupadd nagcmd || die "Unable to add group 'nagcmd'"
+	/usr/sbin/chroot $BASEDIR /usr/sbin/groupadd $GID_NAGCMD nagcmd || die "Unable to add group 'nagcmd'"
 fi
 
 /usr/sbin/chroot $BASEDIR /usr/bin/getent passwd nagios 1>/dev/null
 if [ $? != 0 ]; then
-	/usr/sbin/chroot $BASEDIR /usr/sbin/useradd -g nagios -d /var/log/nagios -c "Nagios user" -s /usr/bin/bash -m nagios
+	/usr/sbin/chroot $BASEDIR /usr/sbin/useradd $UID_NAGIOS -g nagios -d /var/log/nagios -c "Nagios user" -s /usr/bin/bash -m nagios || die "
+Unable to add user 'nagios'"
 	/usr/sbin/chroot $BASEDIR /usr/bin/passwd -N nagios
 fi
 

Modified: trunk/solaris_pkg/request.ALTovagent
===================================================================
--- trunk/solaris_pkg/request.ALTovagent	2013-07-03 12:31:33 UTC (rev 301)
+++ trunk/solaris_pkg/request.ALTovagent	2013-07-08 12:38:50 UTC (rev 302)
@@ -1,4 +1,49 @@
+#!/bin/sh
 #
+# If nagios and nagcmd groups do not exist and if nagios user doesn't exist
+# ask the admin what GID's and UID to use in case the sysadmin doesnt want 
+# to use system generated defaults
+
+GID_NAGIOS=""
+GID_NAGCMD=""
+UID_NAGIOS=""
+
+# Check the system to see if the information is already set
+GID_NAGIOS=`/usr/sbin/chroot $BASEDIR /usr/bin/getent group nagios | awk -F: '{print $3}'`
+
+if [ "x$GID_NAGIOS" = "x" ]; then
+	echo "Enter GID for new group 'nagios' (blank means use system default): "
+	read GID_NAGIOS
+else
+	echo "Group 'nagios' GID already set to: $GID_NAGIOS"
+fi
+
+
+GID_NAGCMD=`/usr/sbin/chroot $BASEDIR /usr/bin/getent group nagcmd | awk -F: '{print $3}'`
+
+if [ "x$GID_NAGCMD" = "x" ]; then
+	echo "Enter GID for new group 'nagcmd' (blank means use system default): "
+	read GID_NAGCMD
+else
+	echo "Group 'nagcmd' GID already set to: $GID_NAGCMD"
+fi
+
+UID_NAGIOS=`/usr/sbin/chroot $BASEDIR /usr/bin/getent passwd nagios | awk -F: '{print $3}'`
+
+if [ "x$UID_NAGIOS" = "x" ]; then
+	echo "Enter UID for new user 'nagios' (blank means use system default): "
+	read UID_NAGIOS
+else
+	echo "User 'nagios' UID already set to: $UID_NAGIOS"
+fi
+
+# Make the variables available to the rest of the install
+cat >> $1 << EOT
+GID_NAGIOS=${GID_NAGIOS}
+GID_NAGCMD=${GID_NAGCMD}
+UID_NAGIOS=${UID_NAGIOS}
+EOT
+
 # postinstall script to handle package upgrade
 #
 #

_______________________________________________
Opsview-checkins mailing list
Opsview-checkins@lists.opsview.org
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to