[csw-devel] SF.net SVN: gar:[3223] csw/mgar/pkg/cswclassutils/trunk

bonivart at users.sourceforge.net bonivart at users.sourceforge.net
Wed Feb 18 18:52:56 CET 2009


Revision: 3223
          http://gar.svn.sourceforge.net/gar/?rev=3223&view=rev
Author:   bonivart
Date:     2009-02-18 17:52:56 +0000 (Wed, 18 Feb 2009)

Log Message:
-----------
cswclassutils: added usergroup scripts

Modified Paths:
--------------
    csw/mgar/pkg/cswclassutils/trunk/Makefile
    csw/mgar/pkg/cswclassutils/trunk/checksums
    csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.README.CSW
    csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.prototype

Added Paths:
-----------
    csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.i.cswusergroup
    csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswusergroup

Modified: csw/mgar/pkg/cswclassutils/trunk/Makefile
===================================================================
--- csw/mgar/pkg/cswclassutils/trunk/Makefile	2009-02-18 17:23:47 UTC (rev 3222)
+++ csw/mgar/pkg/cswclassutils/trunk/Makefile	2009-02-18 17:52:56 UTC (rev 3223)
@@ -1,5 +1,5 @@
 GARNAME = cswclassutils
-GARVERSION = 1.3
+GARVERSION = 1.4
 CATEGORIES = utils
 
 DESCRIPTION = CSW class action utilities
@@ -17,6 +17,8 @@
 WORKSRC = $(WORKDIR)
 SPKG_SOURCEURL = http://www.opencsw.org
 
+CASLIST = cswcpsampleconf cswpreserveconf cswinitsmf cswusergroup
+
 install-custom:
 	@echo " ==> Installing $(GARNAME) (custom)"
 	@rm -rf $(DESTDIR)
@@ -28,10 +30,5 @@
 	@cp $(FILEDIR)/CSW$(GARNAME).csw.smf.sample $(DESTDIR)/etc/opt/csw/init.d/csw.smf.sample
 	@cp $(FILEDIR)/CSW$(GARNAME).README.CSW $(DESTDIR)$(docdir)/$(GARNAME)/README.CSW
 	@cp $(FILEDIR)/CSW$(GARNAME).copyright $(DESTDIR)$(docdir)/$(GARNAME)/LICENSE
-	@cp $(FILEDIR)/CSW$(GARNAME).i.cswcpsampleconf $(DESTDIR)/usr/sadm/install/scripts/i.cswcpsampleconf
-	@cp $(FILEDIR)/CSW$(GARNAME).r.cswcpsampleconf $(DESTDIR)/usr/sadm/install/scripts/r.cswcpsampleconf
-	@cp $(FILEDIR)/CSW$(GARNAME).i.cswpreserveconf $(DESTDIR)/usr/sadm/install/scripts/i.cswpreserveconf
-	@cp $(FILEDIR)/CSW$(GARNAME).r.cswpreserveconf $(DESTDIR)/usr/sadm/install/scripts/r.cswpreserveconf
-	@cp $(FILEDIR)/CSW$(GARNAME).i.cswinitsmf $(DESTDIR)/usr/sadm/install/scripts/i.cswinitsmf
-	@cp $(FILEDIR)/CSW$(GARNAME).r.cswinitsmf $(DESTDIR)/usr/sadm/install/scripts/r.cswinitsmf
+	@$(foreach CAS,$(CASLIST),cp $(FILEDIR)/CSW$(GARNAME).i.$(CAS) $(DESTDIR)/usr/sadm/install/scripts/i.$(CAS);cp $(FILEDIR)/CSW$(GARNAME).r.$(CAS) $(DESTDIR)/usr/sadm/install/scripts/r.$(CAS);)
 	@$(MAKECOOKIE)

Modified: csw/mgar/pkg/cswclassutils/trunk/checksums
===================================================================
--- csw/mgar/pkg/cswclassutils/trunk/checksums	2009-02-18 17:23:47 UTC (rev 3222)
+++ csw/mgar/pkg/cswclassutils/trunk/checksums	2009-02-18 17:52:56 UTC (rev 3223)
@@ -1,2 +1,2 @@
 15e48f60e16862b94755b3205b666ab8  download/CSWcswclassutils.gspec
-847abc46521d2e324518456d783f9235  download/CSWcswclassutils.prototype
+4527cc9b2dc1458845b55edff5b381bb  download/CSWcswclassutils.prototype

Modified: csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.README.CSW
===================================================================
--- csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.README.CSW	2009-02-18 17:23:47 UTC (rev 3222)
+++ csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.README.CSW	2009-02-18 17:52:56 UTC (rev 3223)
@@ -28,3 +28,11 @@
   directory when a package is removed, and restores it on the next pkgadd.
   Read more in /usr/sadm/install/scripts/i.cswpreserveconf and
   r.cswpreserveconf.
+
+- cswusergroup
+
+  This class creates users and/or groups needed for packages. It supports
+  users, groups, gcos, home directory and shell. You can also decide if you want
+  the home directories to be created and/or removed during install/remove.
+
+Read more on the wiki: http://wiki.opencsw.org/cswclassutils-package.

Added: csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.i.cswusergroup
===================================================================
--- csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.i.cswusergroup	                        (rev 0)
+++ csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.i.cswusergroup	2009-02-18 17:52:56 UTC (rev 3223)
@@ -0,0 +1,86 @@
+#!/bin/sh
+#
+# i.cswusergroup - Class action script for creating users and groups
+#
+# Written by Peter Bonivart
+#
+# 2009-02-10 First release
+#
+# Documentation: http://wiki.opencsw.org/cswclassutils-package
+
+DEBUG=		# clear to disable debug, set to anything to enable
+
+if [ "$DEBUG" ]; then
+  echo PACKAGE: $PKGINST
+fi
+
+# Copy files
+echo "Installing class <cswusergroup> ..."
+
+while read src dest; do
+  if [ "$DEBUG" ]; then
+    echo SRC: $src DEST: $dest
+  fi
+
+  # Copy the conf-file
+  /usr/bin/cp $src $dest || exit 2
+
+  for i in `cat $dest | sed 's/ /_/g'`; do
+    user=`echo $i | awk -F':' '{print $1}'`
+    group=`echo $i | awk -F':' '{print $2}'`
+    gcos=`echo $i | awk -F':' '{print $3}'`
+    dir=`echo $i | awk -F':' '{print $4}'`
+    shell=`echo $i | awk -F':' '{print $5}'`
+    create=`echo $i | awk -F':' '{print $6}'`
+    if [ -n "$group" ]; then
+      /bin/getent group $group > /dev/null
+      if [ $? -ne 0 ]; then
+        /usr/sbin/groupadd $group > /dev/null
+        if [ $? -eq 0 ]; then
+          echo Group $group has been added
+        else
+          echo ERROR: Failed to add group $group
+        fi
+      else
+        echo Group $group already exists
+      fi
+    else
+      echo No group to create
+    fi
+
+    if [ -n "$user" ]; then
+      /bin/getent passwd $user > /dev/null
+      if [ $? -ne 0 ]; then
+        if [ -n "$group" ]; then
+          group="-g $group"
+        fi
+        if [ -n "$gcos" ]; then
+          gcos="-c $gcos"
+        fi
+        if [ -n "$dir" ]; then
+          dir="-d $dir"
+        fi
+        if [ -n "$shell" ]; then
+          shell="-s $shell"
+        fi
+        if [ -n "$create" ]; then
+          create="-m"
+        fi
+        /usr/sbin/useradd $gcos $group $create $dir $shell $user > /dev/null
+        if [ $? -eq 0 ]; then
+          echo User $user has been added
+        else
+          echo ERROR: Failed to add user $user
+        fi
+      else
+        echo User $user already exists
+      fi
+    else
+      echo No user to create
+    fi
+    echo
+  done
+
+done
+
+exit 0

Modified: csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.prototype
===================================================================
--- csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.prototype	2009-02-18 17:23:47 UTC (rev 3222)
+++ csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.prototype	2009-02-18 17:52:56 UTC (rev 3223)
@@ -7,6 +7,8 @@
 d none /var/opt/csw/svc 0755 root bin
 d none /var/opt/csw/svc/manifest 0755 root bin
 d none /var/opt/csw/svc/method 0755 root bin
+f none /usr/sadm/install/scripts/i.cswusergroup 0555 root sys
+f none /usr/sadm/install/scripts/r.cswusergroup 0555 root sys
 f none /usr/sadm/install/scripts/i.cswinitsmf 0555 root sys
 f none /usr/sadm/install/scripts/r.cswinitsmf 0555 root sys
 f none /usr/sadm/install/scripts/i.cswcpsampleconf 0555 root sys

Added: csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswusergroup
===================================================================
--- csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswusergroup	                        (rev 0)
+++ csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswusergroup	2009-02-18 17:52:56 UTC (rev 3223)
@@ -0,0 +1,84 @@
+#!/bin/sh
+#
+# r.cswusergroup - Class action script for removing users and groups
+#
+# Written by Peter Bonivart
+#
+# 2009-02-10 First release
+#
+# Documentation: http://wiki.opencsw.org/cswclassutils-package
+
+DEBUG=		# clear to disable debug, set to anything to enable
+
+# Source csw.conf, if it exists
+if [ -f $PKG_INSTALL_ROOT/opt/csw/etc/csw.conf ] ; then
+  . $PKG_INSTALL_ROOT/opt/csw/etc/csw.conf
+fi
+if [ -f $PKG_INSTALL_ROOT/etc/opt/csw/csw.conf ] ; then
+  . $PKG_INSTALL_ROOT/etc/opt/csw/csw.conf
+fi
+
+if [ "$DEBUG" ]; then
+  echo PACKAGE: $PKGINST
+fi
+
+# Copy files
+echo "Removing class <cswusergroup> ..."
+
+while read dest; do
+  if [ "$DEBUG" ]; then
+    echo DEST: $dest
+  fi
+
+  if [ "$usergroup_remove" = "yes" ]; then
+    for i in `cat $dest | sed 's/ /_/g'`; do
+      user=`echo $i | awk -F':' '{print $1}'`
+      group=`echo $i | awk -F':' '{print $2}'`
+      remove=`echo $i | awk -F':' '{print $7}'`
+
+      if [ -n "$user" ]; then
+        /bin/getent passwd $user > /dev/null
+        if [ $? -eq 0 ]; then
+          if [ -n "$remove" ]; then
+            remove="-r"
+          fi
+          /usr/sbin/userdel $remove $user > /dev/null
+          if [ $? -eq 0 ]; then
+            echo User $user has been removed
+          else
+            echo ERROR: Failed to remove user $user
+          fi
+        else
+          echo User $user does not exist
+        fi
+      else
+        echo No user to remove
+      fi
+
+      if [ -n "$group" ]; then
+        /bin/getent group $group > /dev/null
+        if [ $? -eq 0 ]; then
+          /usr/sbin/groupdel $group > /dev/null
+          if [ $? -eq 0 ]; then
+            echo Group $group has been removed
+          else
+            echo ERROR: Failed to remove group $group
+          fi
+        else
+          echo Group $group does not exist
+        fi
+      else
+        echo No group to remove
+      fi
+      echo
+    done
+  else
+    echo Not removing users/groups due to usergroup_remove not set to yes in csw.conf
+  fi
+
+  # Remove conf-file
+  /usr/bin/rm -f $dest || exit 2
+
+done
+
+exit 0


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list