2002-02-08 15:04:37 +01:00
|
|
|
#! /bin/sh
|
2003-01-17 13:58:06 +01:00
|
|
|
#
|
|
|
|
# $FreeBSD$
|
2002-02-08 15:04:37 +01:00
|
|
|
|
|
|
|
make_account() {
|
2002-02-11 15:24:46 +01:00
|
|
|
local u uid g gid gcos home shell
|
|
|
|
|
|
|
|
u=$1
|
|
|
|
uid=$2
|
|
|
|
g=$3
|
|
|
|
gid=$4
|
|
|
|
gcos=$5
|
|
|
|
home=$6
|
|
|
|
shell=$7
|
|
|
|
|
|
|
|
if pw group show "${g}" >/dev/null 2>&1; then
|
|
|
|
echo "You already have a group \"${g}\", so I will use it."
|
|
|
|
else
|
|
|
|
echo -n "Adding group \"${g}\" (${gid})... "
|
|
|
|
if which -s pw; then
|
|
|
|
pw groupadd ${g} -g ${gid} || exit
|
|
|
|
echo "done."
|
2002-02-08 15:04:37 +01:00
|
|
|
else
|
2002-02-11 15:24:46 +01:00
|
|
|
exit 1
|
2002-02-08 15:04:37 +01:00
|
|
|
fi
|
2002-02-11 15:24:46 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if pw user show "${u}" >/dev/null 2>&1; then
|
|
|
|
echo "You already have a user \"${u}\", so I will use it."
|
|
|
|
else
|
|
|
|
echo -n "Adding user \"${u}\" (${uid})... "
|
|
|
|
if which -s pw; then
|
|
|
|
pw useradd ${u} -u ${uid} -g ${g} -h - -d ${home} \
|
|
|
|
-s ${shell} -c "${gcos}" || exit
|
|
|
|
echo "done."
|
2002-02-08 15:04:37 +01:00
|
|
|
else
|
2002-02-11 15:24:46 +01:00
|
|
|
exit 1
|
2002-02-08 15:04:37 +01:00
|
|
|
fi
|
2002-02-11 15:24:46 +01:00
|
|
|
fi
|
2002-02-08 15:04:37 +01:00
|
|
|
|
2002-02-11 15:24:46 +01:00
|
|
|
if [ x"$home" != x ]; then
|
|
|
|
if [ ! -d "${home}" ]; then
|
|
|
|
echo -n "Creating ${u}'s home directory (${home})... "
|
|
|
|
(umask 002 && mkdir -p ${home}) || exit
|
|
|
|
chown -R ${u}:${g} ${home} || exit
|
|
|
|
chmod g+s ${home} || exit
|
|
|
|
echo "done."
|
2002-02-08 15:04:37 +01:00
|
|
|
fi
|
2002-02-11 15:24:46 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
create_crontab() {
|
|
|
|
local u file
|
|
|
|
|
|
|
|
u=$1
|
|
|
|
file=$2
|
|
|
|
|
|
|
|
echo -n "Creating crontab(5) file for Mailman user... "
|
|
|
|
crontab -u ${u} ${file} || exit
|
|
|
|
echo "done."
|
|
|
|
|
2002-02-08 15:04:37 +01:00
|
|
|
}
|
|
|
|
|
2002-10-21 17:31:38 +02:00
|
|
|
fix_perms() {
|
|
|
|
echo -n "Checking (and fixing) permissions... "
|
|
|
|
%%MAILMANDIR%%/bin/check_perms -f >/dev/null 2>&1
|
|
|
|
echo "done."
|
|
|
|
}
|
|
|
|
|
2002-02-08 15:04:37 +01:00
|
|
|
case $2 in
|
|
|
|
|
|
|
|
PRE-INSTALL)
|
2002-02-11 15:24:46 +01:00
|
|
|
make_account %%USER%% %%UID%% %%GROUP%% %%GID%% \
|
|
|
|
"Mailman User" "%%MAILMANDIR%%" "/sbin/nologin"
|
|
|
|
;;
|
2002-02-08 15:04:37 +01:00
|
|
|
|
2002-02-11 15:24:46 +01:00
|
|
|
POST-INSTALL)
|
|
|
|
create_crontab %%USER%% "%%MAILMANDIR%%/cron/crontab.in"
|
2002-10-21 17:31:38 +02:00
|
|
|
fix_perms
|
2002-02-11 15:24:46 +01:00
|
|
|
;;
|
2002-02-08 15:04:37 +01:00
|
|
|
esac
|