2003-08-13 13:39:38 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2005-09-29 17:08:23 +02:00
|
|
|
# Checks if the '%%USER%%' user and %%GROUP%% group exist. If they don't, then
|
2003-08-13 13:39:38 +02:00
|
|
|
# an attempt is made to create both.
|
|
|
|
#
|
2005-09-29 17:08:23 +02:00
|
|
|
# $FreeBSD: /tmp/pcvs/ports/www/tomcat7/Attic/pkg-install,v 1.3 2005-09-29 15:08:23 hq Exp $
|
2003-08-13 13:39:38 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
# Make sure we're called during the 'make install' process
|
|
|
|
if [ "$2" != "PRE-INSTALL" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Set some constants
|
|
|
|
UID=80
|
|
|
|
GID=${UID}
|
|
|
|
|
|
|
|
# See if the group already exists
|
2005-09-29 17:08:23 +02:00
|
|
|
if ! pw groupshow "%%GROUP%%" 2>/dev/null 1>&2; then
|
2003-08-13 13:39:38 +02:00
|
|
|
|
|
|
|
# If not, try to create it
|
2005-09-29 17:08:23 +02:00
|
|
|
if pw groupadd "%%GROUP%%" -g ${GID}; then
|
|
|
|
echo "Added group \"%%GROUP%%\"."
|
|
|
|
elif pw groupadd "%%GROUP%%"; then
|
|
|
|
echo "Added group \"%%GROUP%%\"."
|
2003-08-13 13:39:38 +02:00
|
|
|
else
|
2005-09-29 17:08:23 +02:00
|
|
|
echo "Adding group \"%%GROUP%%\" failed..."
|
2003-08-13 13:39:38 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# See if the user already exists
|
2005-09-29 17:08:23 +02:00
|
|
|
if ! pw usershow "%%USER%%" 2>/dev/null 1>&2; then
|
2003-08-13 13:39:38 +02:00
|
|
|
|
|
|
|
# If not, try to create it
|
2005-09-29 17:08:23 +02:00
|
|
|
if pw useradd "%%USER%%" -u ${UID} -g "%%GROUP%%" -h - \
|
|
|
|
-s "/sbin/nologin" -d "/nonexistent" \
|
|
|
|
-c "World Wide Web Owner";
|
2003-08-13 13:39:38 +02:00
|
|
|
then
|
2005-09-29 17:08:23 +02:00
|
|
|
echo "Added user \"%%USER%%\"."
|
|
|
|
elif pw useradd "%%USER%%" -g "%%GROUP%%" -h - \
|
|
|
|
-s "/sbin/nologin" -d "/nonexistent" \
|
|
|
|
-c "World Wide Web Owner";
|
|
|
|
then
|
|
|
|
echo "Added user \"%%USER%%\"."
|
2003-08-13 13:39:38 +02:00
|
|
|
else
|
2005-09-29 17:08:23 +02:00
|
|
|
echo "Adding user \"%%USER%%\" failed..."
|
2003-08-13 13:39:38 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
exit 0
|