freebsd-ports/textproc/sphinxsearch-devel/files/pkg-install.in
Edwin Groothuis 96c3c9822a Development version of textproc/sphinxsearch
Sphinx is a full-text search engine, distributed under GPL version
    2. Commercial license is also available for embedded use.

    Generally, it's a standalone search engine, meant to provide fast,
    size-efficient and relevant fulltext search functions to other
    applications. Sphinx was specially designed to integrate well with SQL
    databases and scripting languages. Currently built-in data sources
    support fetching data either via direct connection to MySQL, or from
    an XML pipe.

    As for the name, Sphinx is an acronym which is officially decoded as
    SQL Phrase Index.

    WWW: http://www.sphinxsearch.com/

Submitted by:	Daniel Gerzo <danger@FreeBSD.org>
2008-01-19 11:53:15 +00:00

123 lines
2.7 KiB
Bash

#!/bin/sh
#
# $FreeBSD$
#
PATH=/usr/sbin:/usr/bin:/bin ; export PATH
sphinx_dir=%%SPHINX_DIR%%
sphinx_usr=%%SPHINX_USR%%
sphinx_uid=%%SPHINX_UID%%
sphinx_grp=%%SPHINX_GRP%%
sphinx_gid=%%SPHINX_GID%%
sphinx_run=%%SPHINX_RUN%%
sphinx_log=%%SPHINX_LOG%%
sphinx_name=%%PORTNAME%%
sphinx_gcos="Sphinxsearch Owner"
sphinx_home=/nonexistent
sphinx_shell=/sbin/nologin
create_group() {
local user uid group gid gcos home shell
user=$1
uid=$2
group=$3
gid=$4
gcos=$5
home=$6
shell=$7
if pw groupadd -n $group -g $gid ; then
echo "===> Group $group created"
else
cat <<-EOERRORMSG
*** Failed to create the $group group.
Please add the $user user and $group group
manually with the commands:
pw groupadd -n $group -g $gid
pw useradd -n $user -u $uid -g $group -c "$gcos" \\
-d $home -s $shell -h -
and retry installing this package.
EOERRORMSG
exit 1
fi
}
create_user() {
local user uid group gid gcos home shell
user=$1
uid=$2
group=$3
gid=$4
gcos=$5
home=$6
shell=$7
if pw useradd -n $user -u $uid -g $group -c "$gcos" -d $home \
-s $shell -h - ; then
echo "===> Created $user user"
else
cat <<-EOERRORMSG
*** Failed to create the $user user.
Please add the $user user manually with the command:
pw useradd -n $user -u $uid -g $group -c "$gcos" \\
-d $home -s $shell -h -
and retry installing this package.
EOERRORMSG
exit 1
fi
}
case $2 in
PRE-INSTALL)
# Create the sphinx user and group if they do not already exist
if pw user show -n $sphinx_usr >/dev/null 2>&1 ; then
echo "===> Using pre-existing user $sphinx_usr"
else
if ! pw group show -n $sphinx_grp >/dev/null 2>&1 ; then
create_group $sphinx_usr $sphinx_uid $sphinx_grp $sphinx_gid \
"$sphinx_gcos" $sphinx_home $sphinx_shell
fi
create_user $sphinx_usr $sphinx_uid $sphinx_grp $sphinx_gid \
"$sphinx_gcos" $sphinx_home $sphinx_shell
fi
;;
POST-INSTALL)
# Create and set ownership of the Sphinx working directory
if [ -d $sphinx_dir ]; then
echo "==> Using pre-existing directory $sphinx_dir"
else
echo "==> Creating the Sphinx working directory: $sphinx_dir"
mkdir -m 755 $sphinx_dir || exit 1
fi
# Create and set ownership of the Sphinx data directory
if [ -d $sphinx_dir/data ]; then
echo "==> Using pre-existing directory $sphinx_dir/data"
else
echo "==> Creating the Sphinx data directory: $sphinx_dir/data"
mkdir -m 755 $sphinx_dir/data || exit 1
fi
echo "===> Adjusting file ownership in $sphinx_dir"
chown -R $sphinx_usr:$sphinx_grp $sphinx_dir || exit 1
;;
esac
#
# That's All Folks!
#