mirror of
https://git.FreeBSD.org/ports.git
synced 2025-01-24 09:25:01 +00:00
6cd2cdf89a
- replace a silly find construct in Makefile - rewrite pkg-install - include PATCH from PR 151078 PR: 150576 Submitted by: Jason <jgh _at_ experts-exchange.com> (maintainer) Approved by: glarkin (mentor)
108 lines
2.6 KiB
Bash
108 lines
2.6 KiB
Bash
#!/bin/sh
|
|
#
|
|
# Checks if the '%%USER%%' user and '%%GROUP%%' group exist. If they don't, then
|
|
# an attempt is made to create both.
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
PATH=/usr/bin:/bin:/usr/sbin:/usr/local/bin
|
|
|
|
# Set some constants
|
|
UID=%%UID%%
|
|
GID=${UID}
|
|
USER=%%USER%%
|
|
GROUP=%%GROUP%%
|
|
APP_HOME=%%APP_HOME%%
|
|
JAVA_HOME=%%JAVA_HOME%%
|
|
LOG_DIR=%%LOG_DIR%%
|
|
STDOUT_LOG=%%STDOUT_LOG%%
|
|
STDERR_LOG=%%STDERR_LOG%%
|
|
|
|
uidgid() {
|
|
if ! pw groupshow "${GROUP}" 2>/dev/null 1>&2; then
|
|
|
|
# If not, try to create it
|
|
if pw groupadd "${GROUP}" -g ${GID}; then
|
|
echo "Added group \"${GROUP}\"."
|
|
elif pw groupadd "${GROUP}"; then
|
|
echo "Added group \"${GROUP}\"."
|
|
else
|
|
echo "Adding group \"${GROUP}\" failed..."
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "You already have a group \"${GROUP}\", so I will use it."
|
|
fi
|
|
|
|
# See if the user already exists
|
|
if ! pw usershow "${USER}" 2>/dev/null 1>&2; then
|
|
|
|
# If not, try to create it
|
|
if pw useradd "${USER}" -u ${UID} -g "${GROUP}" -h - \
|
|
-s "/usr/sbin/nologin" -d "/nonexistent" \
|
|
-c "World Wide Web Owner";
|
|
then
|
|
echo "Added user \"${USER}\"."
|
|
elif pw useradd "${USER}" -g "${GROUP}" -h - \
|
|
-s "/usr/sbin/nologin" -d "/nonexistent" \
|
|
-c "World Wide Web Owner";
|
|
then
|
|
echo "Added user \"${USER}\"."
|
|
else
|
|
echo "Adding user \"${USER}\" failed..."
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "You already have a user \"${USER}\", so I will use it."
|
|
fi
|
|
}
|
|
|
|
|
|
post() {
|
|
echo -n ">> Creating destination directory..."
|
|
mkdir -p ${APP_HOME}
|
|
mkdir -p ${LOG_DIR}
|
|
echo " [ DONE ]"
|
|
|
|
echo ">> Copying files to destination directory..."
|
|
|
|
echo " [ DONE ]"
|
|
|
|
echo -n ">> Creating log files..."
|
|
install -m 664 -o ${USER} -g ${GROUP} /dev/null ${STDOUT_LOG}
|
|
install -m 664 -o ${USER} -g ${GROUP} /dev/null ${STDERR_LOG}
|
|
echo " [ DONE ]"
|
|
|
|
echo -n ">> Creating symlink to tools.jar..."
|
|
ln -sf ${JAVA_HOME}/lib/tools.jar ${APP_HOME}/common/lib/tools.jar
|
|
echo " [ DONE ]"
|
|
|
|
echo -n ">> Fixing ownership settings..."
|
|
chown -R ${USER}:${GROUP} ${APP_HOME}/conf ${APP_HOME}/logs \
|
|
${APP_HOME}/temp ${APP_HOME}/work ${APP_HOME}/webapps
|
|
chmod -R a+r ${APP_HOME}/common ${APP_HOME}/server ${APP_HOME}/bin
|
|
echo " [ DONE ]"
|
|
|
|
echo -n ">> Fixing permissions..."
|
|
find ${APP_HOME} -type d -exec chmod 755 {} \;
|
|
echo " [ DONE ] "
|
|
}
|
|
|
|
|
|
# PACKAGE_BUILDING is only defined on the build cluster or tinderbox!
|
|
# No interactive parts, there is no one who can answer!
|
|
if [ "x${PACKAGE_BUILDING}" != "x" ]; then
|
|
uidgid
|
|
post
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$2" = "POST-INSTALL" ]; then
|
|
uidgid
|
|
post
|
|
exit 0
|
|
fi
|
|
|
|
exit 0
|