Use USERS and GROUPS.
PR: ports/157596 Submitted by: Chris Rees <utisoft__at__gmail.com>
This commit is contained in:
parent
6f41245cd6
commit
c76287d412
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=275392
@ -21,9 +21,10 @@ USE_BZIP2= yes
|
||||
USE_RC_SUBR= tiarra
|
||||
NO_BUILD= yes
|
||||
|
||||
SUB_FILES= pkg-install pkg-deinstall pkg-message
|
||||
SUB_LIST= TIARRA_USER=${TIARRA_USER} \
|
||||
TIARRA_GROUP=${TIARRA_GROUP}
|
||||
USERS= ${TIARRA_USER}
|
||||
GROUPS= ${TIARRA_GROUP}
|
||||
|
||||
SUB_FILES= pkg-message
|
||||
|
||||
PLIST_SUB= TIARRA_USER=${TIARRA_USER} \
|
||||
TIARRA_GROUP=${TIARRA_GROUP}
|
||||
@ -32,7 +33,6 @@ TIARRA_USER= tiarra
|
||||
TIARRA_GROUP= tiarra
|
||||
|
||||
do-install:
|
||||
@${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
|
||||
@${MKDIR} ${PREFIX}/tiarra
|
||||
@${TAR} cfC - ${WRKSRC} . | ${TAR} xfC - ${PREFIX}/tiarra
|
||||
@if [ ! -f ${PREFIX}/tiarra/tiarra.conf ]; then \
|
||||
|
@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
TIARRA_USER=${TIARRA_USER:=%%TIARRA_USER%%}
|
||||
TIARRA_GROUP=${TIARRA_GROUP:=%%TIARRA_GROUP%%}
|
||||
|
||||
delete_user() {
|
||||
if pw usershow ${TIARRA_USER} 2>/dev/null 1>&2; then
|
||||
echo "To delete tiarra user permanently, use 'pw userdel ${TIARRA_USER}'"
|
||||
fi
|
||||
if pw groupshow ${TIARRA_GROUP} 2>/dev/null 1>&2; then
|
||||
echo "To delete tiarra group permanently, use 'pw groupdel ${TIARRA_GROUP}'"
|
||||
fi
|
||||
}
|
||||
|
||||
case $2 in
|
||||
POST-DEINSTALL)
|
||||
delete_user
|
||||
;;
|
||||
esac
|
@ -1,71 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
TIARRA_USER=${TIARRA_USER:=%%TIARRA_USER%%}
|
||||
TIARRA_GROUP=${TIARRA_GROUP:=%%TIARRA_GROUP%%}
|
||||
|
||||
UID=398
|
||||
GID=398
|
||||
|
||||
#
|
||||
# create 'tiarra' user and group before installing
|
||||
#
|
||||
|
||||
create_user() {
|
||||
USER=${TIARRA_USER}
|
||||
GROUP=${TIARRA_GROUP}
|
||||
PW=/usr/sbin/pw
|
||||
|
||||
if [ -x /usr/sbin/nologin ]; then
|
||||
shell=/usr/sbin/nologin
|
||||
elif [ -x /sbin/nologin ]; then
|
||||
shell=/sbin/nologin
|
||||
else
|
||||
shell=/nonexistent
|
||||
fi
|
||||
uhome="/nonexistent"
|
||||
|
||||
if ! ${PW} show group ${GROUP} -q >/dev/null; then
|
||||
gid=${GID}
|
||||
while ${PW} show group -g ${gid} -q >/dev/null; do
|
||||
gid=`expr ${gid} + 1`
|
||||
done
|
||||
if ! ${PW} add group ${GROUP} -g ${gid}; then
|
||||
e=$?
|
||||
echo "*** Failed to add group \`${GROUP}'. Please add it manually."
|
||||
exit ${e}
|
||||
fi
|
||||
echo "*** Added group \`${GROUP}' (id ${gid})"
|
||||
else
|
||||
gid=`${PW} show group ${GROUP} 2>/dev/null | cut -d: -f3`
|
||||
fi
|
||||
|
||||
if ! ${PW} show user ${USER} -q >/dev/null; then
|
||||
uid=${UID}
|
||||
while ${PW} show user -u ${uid} -q >/dev/null; do
|
||||
uid=`expr ${uid} + 1`
|
||||
done
|
||||
if ! ${PW} add user ${USER} -u ${uid} -g ${gid} -d "${uhome}" \
|
||||
-c "Tiarra IRC Proxy" -s "${shell}" -p "*" \
|
||||
; then
|
||||
e=$?
|
||||
echo "*** Failed to add user \`${USER}'. Please add it manually."
|
||||
exit ${e}
|
||||
fi
|
||||
echo "*** Added user \`${USER}' (id ${uid})"
|
||||
else
|
||||
if ! ${PW} mod user ${USER} -g ${gid}; then
|
||||
e=$?
|
||||
echo "*** Failed to update user \`${USER}'."
|
||||
exit ${e}
|
||||
fi
|
||||
echo "*** Updated user \`${USER}'."
|
||||
fi
|
||||
}
|
||||
|
||||
case $2 in
|
||||
PRE-INSTALL)
|
||||
create_user
|
||||
;;
|
||||
esac
|
Loading…
Reference in New Issue
Block a user