2004-10-27 19:54:46 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
if [ $2 != "POST-INSTALL" ]
|
2004-10-30 07:47:50 +00:00
|
|
|
then
|
|
|
|
exit
|
2004-10-27 19:54:46 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
varrun=/var/run/bld
|
2004-10-30 07:47:50 +00:00
|
|
|
logfile=/var/log/bld.log
|
2004-10-27 19:54:46 +00:00
|
|
|
user=bld
|
|
|
|
group=bld
|
2004-10-30 07:47:50 +00:00
|
|
|
newsyslog_conf=/etc/newsyslog.conf
|
|
|
|
syslog_conf=/etc/syslog.conf
|
|
|
|
syslog_pid=/var/run/syslog.pid
|
|
|
|
nonexistent=/nonexistent
|
2004-10-27 19:54:46 +00:00
|
|
|
|
|
|
|
ask() {
|
|
|
|
local question default answer
|
|
|
|
|
|
|
|
question=$1
|
|
|
|
default=$2
|
|
|
|
if [ -z "${PACKAGE_BUILDING}" ]; then
|
|
|
|
read -p "${question} [${default}]? " answer
|
|
|
|
fi
|
|
|
|
if [ x${answer} = x ]; then
|
|
|
|
answer=${default}
|
|
|
|
fi
|
|
|
|
echo ${answer}
|
|
|
|
}
|
|
|
|
|
|
|
|
yesno() {
|
|
|
|
local dflt question answer
|
|
|
|
|
|
|
|
question=$1
|
|
|
|
dflt=$2
|
|
|
|
while :; do
|
|
|
|
answer=$(ask "${question}" "${dflt}")
|
|
|
|
case "${answer}" in
|
2004-10-30 07:47:50 +00:00
|
|
|
[Yy]*) return 0;;
|
|
|
|
[Nn]*) return 1;;
|
|
|
|
esac
|
|
|
|
echo "Please answer yes or no."
|
|
|
|
done
|
2004-10-27 19:54:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
make_account() {
|
|
|
|
local u g gcos homeopt home
|
|
|
|
|
|
|
|
u=$1
|
|
|
|
g=$2
|
|
|
|
gcos=$3
|
|
|
|
homeopt=${4:+"-d $4"}
|
|
|
|
|
|
|
|
if pw group show "${g}" >/dev/null 2>&1; then
|
|
|
|
echo "You already have a group \"${g}\", so I will use it."
|
|
|
|
else
|
|
|
|
echo "You need a group \"${g}\"."
|
|
|
|
pw groupadd ${g} || exit
|
|
|
|
echo "Done."
|
|
|
|
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 "You need a user \"${u}\"."
|
|
|
|
pw useradd ${u} -g ${g} -h - ${homeopt} \
|
2004-10-30 07:47:50 +00:00
|
|
|
-s $nonexistent -c "${gcos}" || exit
|
2004-10-27 19:54:46 +00:00
|
|
|
echo "Done."
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ x"$homeopt" = x ]; then
|
|
|
|
eval home=~${u}
|
|
|
|
if [ ! -d "${home}" ]; then
|
2004-10-30 07:47:50 +00:00
|
|
|
mkdir -p ${home}/.cvsup || exit
|
|
|
|
touch ${home}/.cvsup/auth || exit
|
|
|
|
chown -R ${u}:${g} ${home} || exit
|
|
|
|
chmod -R go= ${home} || exit
|
2004-10-27 19:54:46 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ ! -d "${varrun}" ]
|
2004-10-30 07:47:50 +00:00
|
|
|
then
|
|
|
|
mkdir ${varrun} || exit
|
2004-10-27 19:54:46 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo ""
|
2004-10-30 07:47:50 +00:00
|
|
|
make_account ${user} ${group} "Blacklist Daemon" "$nonexistent"
|
2004-10-27 19:54:46 +00:00
|
|
|
chmod 700 ${varrun}
|
|
|
|
chown bld ${varrun}
|
|
|
|
|
2004-10-30 07:47:50 +00:00
|
|
|
if grep -q "^[^#]*${facility}.*$logfile" $syslog_conf; then
|
|
|
|
echo -n "It looks like you already have some logging set up, so I "
|
|
|
|
echo "will use it."
|
2004-10-27 19:54:46 +00:00
|
|
|
else
|
2004-10-30 07:47:50 +00:00
|
|
|
echo "Setting up server logging in \"$syslog_conf\"."
|
|
|
|
cat <<EOF >>$syslog_conf
|
2004-10-27 19:54:46 +00:00
|
|
|
!bld
|
2004-10-30 07:47:50 +00:00
|
|
|
*.* $logfile
|
2004-10-27 19:54:46 +00:00
|
|
|
EOF
|
|
|
|
|
2004-10-30 07:47:50 +00:00
|
|
|
if [ ! -f $logfile ]; then
|
|
|
|
echo "Creating \"$logfile\"."
|
|
|
|
cp /dev/null $logfile
|
|
|
|
fi
|
2004-10-27 19:54:46 +00:00
|
|
|
|
2004-10-30 07:47:50 +00:00
|
|
|
if [ -f $syslog_pid ]; then
|
|
|
|
echo "Giving syslogd a kick in the pants."
|
|
|
|
kill -HUP $(cat $syslog_pid)
|
|
|
|
fi
|
2004-10-27 19:54:46 +00:00
|
|
|
|
2004-10-30 07:47:50 +00:00
|
|
|
echo "Adding bld log entry to \"$newsyslog_conf\"."
|
|
|
|
cat <<EOF >>$newsyslog_conf
|
|
|
|
$logfile 664 7 * 24 Z
|
2004-10-27 19:54:46 +00:00
|
|
|
EOF
|
2004-10-30 07:47:50 +00:00
|
|
|
echo "Done."
|
2004-10-27 19:54:46 +00:00
|
|
|
fi
|
2004-10-30 07:47:50 +00:00
|
|
|
|
|
|
|
# Compatibility from v0.2.4 port
|
|
|
|
for i in bld_acl.conf bld_whitelist.conf
|
|
|
|
do
|
|
|
|
if [ -f ${PKG_PREFIX}/etc/$i ]
|
|
|
|
then
|
|
|
|
if [ -f ${PKG_PREFIX}/etc/bld/$i ]
|
|
|
|
then
|
|
|
|
echo "WARNING: You have a $i configuration file in two directories:"
|
|
|
|
echo "${PKG_PREFIX}/etc and ${PKG_PREFIX}/etc/bld"
|
|
|
|
echo "You must use ${PREFIX}/etc/bld/$i"
|
|
|
|
else
|
|
|
|
echo "You seem to have a $i configuration file in ${PKG_PREFIX}/etc"
|
|
|
|
echo "Copying it to ${PKG_PREFIX}/etc/bld"
|
|
|
|
cp ${PKG_PREFIX}/etc/$i ${PKG_PREFIX}/etc/bld
|
|
|
|
echo "You should clean the old ${PKG_PREFIX}/etc/$i"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|