1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-01 05:45:45 +00:00

- Use USERS and GROUPS

- Deprecate -- broken and no volunteers on ports@ after two reminders

PR:		ports/157593
Submitted by:	crees
Approved by:	rene (mentor, implicit)
This commit is contained in:
Chris Rees 2011-07-09 09:47:33 +00:00
parent 8aa9c3f3b6
commit 71ab9b08fa
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=277388
2 changed files with 106 additions and 85 deletions

View File

@ -24,6 +24,9 @@ MASTER_SITES= SF
MAINTAINER= ports@FreeBSD.org
COMMENT= License analysis tool for Open Source software
DEPRECATED= Broken for four months with no-one caring
EXPIRATION_DATE=2011-08-09
BUILD_DEPENDS= bash:${PORTSDIR}/shells/bash \
${SITE_PERL}/Text/Template.pm:${PORTSDIR}/textproc/p5-Text-Template \
svn:${PORTSDIR}/devel/subversion
@ -40,6 +43,8 @@ RUN_DEPENDS= cabextract:${PORTSDIR}/archivers/cabextract \
BROKEN= does not compile
USERS= fossy
GROUPS= ${USERS}
USE_APACHE= 2.0+
USE_CDRTOOLS= yes
USE_GMAKE= yes

View File

@ -1,100 +1,116 @@
--- common/fo-postinstall.in.orig 2009-07-13 21:51:17.000000000 +0000
+++ common/fo-postinstall.in 2009-07-15 00:37:37.000000000 +0000
@@ -8,22 +8,15 @@
--- common/fo-postinstall.in 2011-06-02 15:16:35.611277082 +0100
+++ common/fo-postinstall.in.orig 2011-06-02 15:12:07.679891820 +0100
@@ -7,14 +7,23 @@
# idempotent, meaning that running it repeatedly will still do the
# right thing, regardless of the success of previous runs.
## Options parsing and setup
-# parse options
-OPTS=`getopt -o adwseoh --long agent,database,web,web-only,scheduler,scheduler-only,everything,overwrite,help -n 'fo-postinstall' -- "$@"`
-if [ $? != 0 ]; then
- echo "ERROR: Bad option specified."
- OPTS="--help"
-fi
-
-eval set -- "$OPTS"
+# FIXME: joint options do not work (i.e. "-as" instead of "-a -s")
-# FIXME: joint options do not work (i.e. "-as" instead of "-a -s")
+## Options parsing and setup
+# parse options
+OPTS=`getopt -o adwseoh --long agent,database,web,web-only,scheduler,scheduler-only,everything,overwrite,help -n 'fo-postinstall' -- "$@"`
+
+if [ $? != 0 ]; then
+ echo "ERROR: Bad option specified."
+ OPTS="--help"
+fi
+
+eval set -- "$OPTS"
# if no options or just -o then do everything
-if [ "$OPTS" = " --" -o "$OPTS" = " -o --" ]; then
+if [ $# -eq 0 -o "$1" = "-o" ]; then
-if [ $# -eq 0 -o "$1" = "-o" ]; then
+if [ "$OPTS" = " --" -o "$OPTS" = " -o --" ]; then
EVERYTHING=1
fi
-while true; do
+while [ $# -gt 0 ]; do
-while [ $# -gt 0 ]; do
+while true; do
case "$1" in
-a|--agent) AGENT=1; shift;;
-d|--database) DATABASE=1; shift;;
@@ -105,15 +98,10 @@
echo "*** Creating user and group ***"
@@ -93,12 +102,53 @@
# documentation.
# Make sure the user and group exist, if not then create
-
- # We do this in the port Makefile
-
- #echo "*** Creating user and group ***"
+ echo "*** Creating user and group ***"
# check for group
- if grep -q "^{$PROJECTGROUP}:" /etc/group; then
+ if pw groupshow {$PROJECTGROUP} 2>/dev/null 1>&2; then
echo "NOTE: group '{$PROJECTGROUP}' already exists, good."
else
- # use addgroup if it exists since it supports --system
- if [ -f /usr/sbin/addgroup -a ! -L /usr/sbin/addgroup ]; then
- addgroup --system {$PROJECTGROUP}
- else
- groupadd {$PROJECTGROUP}
- fi
+ pw groupadd {$PROJECTGROUP} -g 901
if [ "$?" != "0" ] ; then
echo "ERROR: Unable to create group '{$PROJECTGROUP}'"
exit 1
@@ -123,25 +111,18 @@
fi
+ if grep -q "^{$PROJECTGROUP}:" /etc/group; then
+ echo "NOTE: group '{$PROJECTGROUP}' already exists, good."
+ else
+ # use addgroup if it exists since it supports --system
+ if [ -f /usr/sbin/addgroup -a ! -L /usr/sbin/addgroup ]; then
+ addgroup --system {$PROJECTGROUP}
+ else
+ groupadd {$PROJECTGROUP}
+ fi
+ if [ "$?" != "0" ] ; then
+ echo "ERROR: Unable to create group '{$PROJECTGROUP}'"
+ exit 1
+ else
+ echo "NOTE: group '{$PROJECTGROUP}' created"
+ fi
+ fi
+
+ # check for user
+ if grep -q "^{$PROJECTUSER}:" /etc/passwd; then
+ echo "NOTE: user '{$PROJECTUSER}' already exists, good."
+ USERSHELL=`grep "^{$PROJECTUSER}:" /etc/passwd |cut -d: -f 7`
+ if [ "$USERSHELL" = "/bin/false" ]; then
+ echo "ERROR: {$PROJECTUSER} shell must be a real shell"
+ exit 1
+ fi
+ else
+ # ensure that the full parent path of the HOME exists first
+ mkdir -p $\{REPO%/*/*\}
+ # use adduser if it exists since it supports --system, but
+ # not if it's a symlink (probably to /usr/sbin/useradd)
+ if [ -f /usr/sbin/adduser -a ! -L /usr/sbin/adduser ]; then
+ adduser --gecos "{$PROJECT}" --ingroup {$PROJECTGROUP} --system \
+ --shell /bin/bash --home "$\{REPO%/*\}" {$PROJECTUSER}
+ else
+ useradd -c "{$PROJECT}" -g {$PROJECTGROUP} -m \
+ -s /bin/bash -d "$\{REPO%/*\}" {$PROJECTUSER}
+ fi
+ if [ "$?" != "0" ] ; then
+ echo "ERROR: Unable to create user '{$PROJECTUSER}'"
+ exit 1
+ else
+ echo "NOTE: user '{$PROJECTUSER}' created"
+ fi
+ fi
# check for user
- if grep -q "^{$PROJECTUSER}:" /etc/passwd; then
+ if pw usershow {$PROJECTUSER} 2>/dev/null 1>&2; then
echo "NOTE: user '{$PROJECTUSER}' already exists, good."
USERSHELL=`grep "^{$PROJECTUSER}:" /etc/passwd |cut -d: -f 7`
- if [ "$USERSHELL" = "/bin/false" ]; then
+ if [ "$USERSHELL" = "/usr/sbin/nologin" ]; then
echo "ERROR: {$PROJECTUSER} shell must be a real shell"
exit 1
fi
else
# ensure that the full parent path of the HOME exists first
mkdir -p $\{REPO%/*/*\}
- # use adduser if it exists since it supports --system, but
- # not if it's a symlink (probably to /usr/sbin/useradd)
- if [ -f /usr/sbin/adduser -a ! -L /usr/sbin/adduser ]; then
- adduser --gecos "{$PROJECT}" --ingroup {$PROJECTGROUP} --system \
- --shell /bin/bash --home "$\{REPO%/*\}" {$PROJECTUSER}
- else
- useradd -c "{$PROJECT}" -g {$PROJECTGROUP} -m \
- -s /bin/bash -d "$\{REPO%/*\}" {$PROJECTUSER}
- fi
+ pw useradd {$PROJECTUSER} -u 901 -g {$PROJECTGROUP} -h - \
+ -s "/bin/bash" -d "$\{REPO%/*\}" -c "FOSSology user"
if [ "$?" != "0" ] ; then
echo "ERROR: Unable to create user '{$PROJECTUSER}'"
exit 1
@@ -284,19 +265,12 @@
echo "*** Setting up the web interface ***"
## check for existance/ownership/permissions of needed directories
echo "*** Making sure needed dirs exist with right ownership/permissions ***"
@@ -230,5 +280,28 @@
# See if web server user exists, if so add to the group.
- # check for www-data (Debian, etc)
- grep -q "^www-data:" /etc/passwd
- if [ $? == 0 ] ; then
- echo "NOTE: Adding user www-data to group {$PROJECTGROUP}"
- # this is smart enough to not add multiple times so it's ok to repeat
- usermod -G {$PROJECTGROUP} -a www-data
- fi
- # check for apache (RHEL/CentOS, etc)
- grep -q "^apache:" /etc/passwd
+ # check for www (FreeBSD)
+ grep -q "^www:" /etc/passwd
if [ $? == 0 ] ; then
- echo "NOTE: Adding user apache to group {$PROJECTGROUP}"
+ echo "NOTE: Adding user www to group {$PROJECTGROUP}"
# this is smart enough to not add multiple times so it's ok to repeat
- usermod -G {$PROJECTGROUP} -a apache
+ pw groupmod {$PROJECTGROUP} -m www
fi
########################################################################
fi # end of WEBONLY
+if [ $WEBONLY ]; then
+ echo "*** Setting up the web interface ***"
+
+ # See if web server user exists, if so add to the group.
+ # check for www-data (Debian, etc)
+ grep -q "^www-data:" /etc/passwd
+ if [ $? == 0 ] ; then
+ echo "NOTE: Adding user www-data to group {$PROJECTGROUP}"
+ # this is smart enough to not add multiple times so it's ok to repeat
+ usermod -G {$PROJECTGROUP} -a www-data
+ fi
+ # check for apache (RHEL/CentOS, etc)
+ grep -q "^apache:" /etc/passwd
+ if [ $? == 0 ] ; then
+ echo "NOTE: Adding user apache to group {$PROJECTGROUP}"
+ # this is smart enough to not add multiple times so it's ok to repeat
+ usermod -G {$PROJECTGROUP} -a apache
+ fi
+
+fi # end of WEBONLY
+
+########################################################################
+
echo "FOSSology postinstall complete, but sure to complete the remaining"
echo " steps in the INSTALL instructions."