Note: don't bump PORTREVISION, won't take effect before the next reinstallation. PR: 88621 Submitted by: Heinrich Rebehn <rebehn (at) ant.uni-bremen.de>
117 lines
2.5 KiB
Bash
117 lines
2.5 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
# Copied from databases/phpmyadmin.
|
|
# Used if WITH_SUPHP has been defined.
|
|
|
|
PATH=/usr/sbin:/usr/bin:/bin ; export PATH
|
|
|
|
WITH_SUPHP=%%WITH_SUPHP%%
|
|
|
|
hordedir=%%HORDEDIR%%
|
|
hordeusr=%%HORDEADMUSR%%
|
|
hordegrp=%%HORDEGRP%%
|
|
|
|
hordegcos="Horde Owner"
|
|
hordehome=/nonexistent
|
|
hordeshell=/sbin/nologin
|
|
|
|
create_group() {
|
|
local user group gcos home shell
|
|
|
|
user=$1
|
|
group=$2
|
|
gcos=$3
|
|
home=$4
|
|
shell=$5
|
|
|
|
if pw groupadd -n $group ; 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
|
|
pw useradd -n $user -g $group -c "$gcos" \\
|
|
-d $home -s $shell -h -
|
|
|
|
and retry installing this package.
|
|
EOERRORMSG
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
|
|
create_user() {
|
|
local user group gcos home shell
|
|
|
|
user=$1
|
|
group=$2
|
|
gcos=$3
|
|
home=$4
|
|
shell=$5
|
|
|
|
if pw useradd -n $user -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 -g $group -c "$gcos" \\
|
|
-d $home -s $shell -h -
|
|
|
|
and retry installing this package.
|
|
EOERRORMSG
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
|
|
case $2 in
|
|
PRE-INSTALL)
|
|
|
|
if [ $WITH_SUPHP != "yes" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
# Create the horde user and group if they do not already exist
|
|
|
|
if pw user show -n $hordeusr >/dev/null 2>&1 ; then
|
|
echo "===> Using pre-existing user $hordeusr"
|
|
else
|
|
if ! pw group show -n $hordegrp >/dev/null 2>&1 ; then
|
|
create_group $hordeusr $hordegrp "$hordegcos" $hordehome \
|
|
$hordeshell
|
|
fi
|
|
create_user $hordeusr $hordegrp "$hordegcos" $hordehome $hordeshell
|
|
fi
|
|
;;
|
|
POST-INSTALL)
|
|
|
|
if [ $WITH_SUPHP = "yes" ]; then
|
|
# Change ownership of the Horde directory
|
|
|
|
echo "===> Adjusting file ownership in $hordedir"
|
|
chown -R $hordeusr:$hordegrp $hordedir || exit 1
|
|
fi
|
|
|
|
if [ -z "${PACKAGE_BUILDING}" ]; then
|
|
# Don't reset the config to default (PR ports/88621)
|
|
|
|
for cf in `ls %%HORDEDIR%%/config/*php`; do
|
|
if [ -f $cf.previous ]; then
|
|
mv $cf $cf.new
|
|
echo "---> $cf not installed ***"
|
|
echo "---> please copy from $cf.previous ***"
|
|
echo "---> or from $cf.new ***"
|
|
fi
|
|
done
|
|
fi
|
|
;;
|
|
esac
|