[csw-devel] SF.net SVN: gar:[2409] csw/mgar/gar/v1/pkglib

chninkel at users.sourceforge.net chninkel at users.sourceforge.net
Sun Nov 30 22:24:41 CET 2008


Revision: 2409
          http://gar.svn.sourceforge.net/gar/?rev=2409&view=rev
Author:   chninkel
Date:     2008-11-30 21:24:41 +0000 (Sun, 30 Nov 2008)

Log Message:
-----------
mgar: added back csw_usrgrp from Trygve Laugstol

Added Paths:
-----------
    csw/mgar/gar/v1/pkglib/csw_usrgrp.gspec
    csw/mgar/gar/v1/pkglib/csw_usrgrp.preinstall

Added: csw/mgar/gar/v1/pkglib/csw_usrgrp.gspec
===================================================================
--- csw/mgar/gar/v1/pkglib/csw_usrgrp.gspec	                        (rev 0)
+++ csw/mgar/gar/v1/pkglib/csw_usrgrp.gspec	2008-11-30 21:24:41 UTC (rev 2409)
@@ -0,0 +1,3 @@
+%prototype:merge
+i csw_usrgrp_config=CSW%{bitname}.csw_usrgrp_config
+%preinstall:merge       url file://%{PKGLIB}/csw_usrgrp.preinstall

Added: csw/mgar/gar/v1/pkglib/csw_usrgrp.preinstall
===================================================================
--- csw/mgar/gar/v1/pkglib/csw_usrgrp.preinstall	                        (rev 0)
+++ csw/mgar/gar/v1/pkglib/csw_usrgrp.preinstall	2008-11-30 21:24:41 UTC (rev 2409)
@@ -0,0 +1,79 @@
+################################################################################
+# Start csw_usrgrp.postinstall
+################################################################################
+
+# This was once based upon the preinstallation script from vsftpd
+
+set -e
+
+##################################################
+# create the given group if it doesn't exist
+##################################################
+create_group()
+{
+    NAME=$1
+
+    if /usr/sbin/chroot "$PKG_INSTALL_ROOT" /usr/bin/getent group $NAME > /dev/null; then 
+        /usr/bin/echo "Group already exist: $NAME"
+    else 
+        /usr/sbin/chroot "$PKG_INSTALL_ROOT" /usr/sbin/groupadd $NAME
+        /usr/bin/echo "Group created: $NAME"
+    fi
+}
+
+##################################################
+# create the given user if it doesn't exist
+# paramters are: userid gid home shell gecos
+##################################################
+create_user()
+{
+    NAME=$1
+    GROUP=$2
+    HOME=$3
+    SHELL=$4
+    COMMENT="$5"
+
+    if /usr/sbin/chroot "$PKG_INSTALL_ROOT" /usr/bin/getent passwd $NAME > /dev/null; then 
+        /usr/bin/echo "User already exists: $NAME"
+    else 
+        /usr/sbin/chroot "$PKG_INSTALL_ROOT" /usr/sbin/useradd -g "$GROUP" -c "$COMMENT" -d $HOME -s $SHELL $NAME
+        /usr/sbin/chroot "$PKG_INSTALL_ROOT" /usr/bin/pwconv
+        /usr/bin/echo "User created: $NAME"
+    fi
+}
+
+PKG_INSTALL_ROOT=${PKG_INSTALL_ROOT:-/}
+
+CSW_USRGRP_CONFIG="$PKGSAV/../install/csw_usrgrp_config"
+
+# Note to self: do not replace this with a "return" as additional scripts can be merged after this script
+if [ -r "$CSW_USRGRP_CONFIG" ]
+then
+    # Read the csw_usrgrp_config file and make sure that it has the correct version
+    set +e
+    version=`grep "^version=" "$CSW_USRGRP_CONFIG"`
+    set -e
+
+    if [ "$version" != "version=1" ]
+    then
+      echo "ERROR: invalid csw_usrgrp_config file. Expected version=1" 
+      exit 1
+    fi
+
+    OIFS="$IFS"; 
+    IFS=":"
+    sed -n "s/^group=//p" "$CSW_USRGRP_CONFIG" | while read NAME
+    do
+      create_group "$NAME"
+    done
+  
+    sed -n "s/^user=//p" "$CSW_USRGRP_CONFIG" | while read NAME GROUP HOME SHELL COMMENT
+    do
+      create_user "$NAME" "$GROUP" "$HOME" "$SHELL" "$COMMENT"
+    done
+    IFS="$OIFS"
+fi
+
+################################################################################
+# End csw_usrgrp.postinstall
+################################################################################


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