mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-04 01:48:54 +00:00
23ade3620a
- Use own uid and gid - Fix sample config install and install messages
93 lines
2.0 KiB
Bash
93 lines
2.0 KiB
Bash
#! /bin/sh
|
|
# $FreeBSD$
|
|
|
|
if [ "$2" != "POST-INSTALL" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
OPENACSBASE="%%OPENACSBASE%%"
|
|
|
|
openacs_user="%%OPENACS_USER%%"
|
|
openacs_uid="%%OPENACS_UID%%"
|
|
openacs_group="%%OPENACS_GROUP%%"
|
|
openacs_gid="%%OPENACS_GID%%"
|
|
openacs_gecos="%%OPENACS_GECOS%%"
|
|
openacs_home="%%OPENACS_HOME%%"
|
|
openacs_shell="%%OPENACS_SHELL%%"
|
|
|
|
CHMOD=%%CHMOD%%
|
|
CHOWN=%%CHOWN%%
|
|
PW=%%PW%%
|
|
|
|
create_group() {
|
|
local group gid
|
|
|
|
group=$1
|
|
gid=$2
|
|
|
|
|
|
if ${PW} group show -n $group >/dev/null 2>&1 ; then
|
|
echo "===> Using existing group $group"
|
|
else
|
|
if ${PW} groupadd -n $group -g $gid ; then
|
|
echo "===> Created group $group"
|
|
else
|
|
cat <<-EOERRORMSG
|
|
*** Failed to create group $group.
|
|
|
|
Please add user $user and group $group
|
|
manually with the following commands:
|
|
|
|
${PW} groupadd -n $group -g $gid
|
|
${PW} useradd -n $user -u $uid -g $group -c "$gecos" \\
|
|
-d $home -s $shell -h -
|
|
|
|
and retry installing this package.
|
|
EOERRORMSG
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
create_user() {
|
|
local user uid group gecos home shell
|
|
|
|
user=$1
|
|
uid=$2
|
|
group=$3
|
|
gecos=$4
|
|
home=$5
|
|
shell=$6
|
|
|
|
if ${PW} user show -n $user >/dev/null 2>&1 ; then
|
|
echo "===> Using existing user $user"
|
|
else
|
|
if ${PW} useradd -n $user -u $uid -g $group -c "$gecos" \
|
|
-d "$home" -s "$shell" -h - ; then
|
|
echo "===> Created user $user"
|
|
else
|
|
cat <<-EOERRORMSG
|
|
*** Failed to create user $user.
|
|
|
|
Please add user $user manually with the following command:
|
|
|
|
${PW} useradd -n $user -u $uid -g $group -c "$gecos" \\
|
|
-d $home -s $shell -h -
|
|
|
|
and retry installing this package.
|
|
EOERRORMSG
|
|
exit 1
|
|
fi
|
|
fi
|
|
}
|
|
|
|
create_group $openacs_group $openacs_gid
|
|
create_user $openacs_user $openacs_uid $openacs_group \
|
|
"$openacs_gecos" "$openacs_home" "$openacs_shell"
|
|
echo "===> Changing ownership of ${OPENACSBASE}"
|
|
${CHOWN} -R ${openacs_user}:${openacs_group} ${OPENACSBASE}
|
|
echo "===> Changing permissions of ${OPENACSBASE}"
|
|
${CHMOD} -R 770 ${OPENACSBASE}
|