
# Bourne shell Solaris packaging script (no interpreter line on purpose)

# $Id: HSQLhsqldb.preinstall,v 1.2 2005/07/25 02:42:10 unsaved Exp $

# Do not set path.  Pkgadd sets a safe path, it does not use any inherited path


# Not knowing what name service is in use for groups and passwords, I
# know of no way on the command-line to portably get a list of uids and gids.
# (would be easy enough in C).

# We need this user and group in place before installing the software
# (due to file ownerships)

# If getent isn't installed, we will "attempt" to create the user and
# group.  That won't hurt anything.

getent group hsqldb > /dev/null || {
    # Add group 'hsqldb'
    groupadd hsqldb
}

if getent passwd hsqldb > /dev/null; then
    # If account shell has been disabled by our pkgrm script, then enable it.
    grep '^hsqldb:.*:/bin/false$' /etc/passwd > /dev/null &&
    usermod -s /bin/sh hsqldb
else
    # Add user 'hsqldb'
    # We just set temporary home dir and login shell, because at this
    # point, the intended dir and shell don't exist yet.
    # A real login shell is required due our use of "su hsqldb -c ...".
    # (as opposed to setting to /dev/false or similar for security purposes).
    useradd -d /dev/null -c 'hsqldb owner' hsqldb
fi

exit 0
