freebsd-ports/news/inn/pkg-install
Shaun Amott d6e813c37c - Fix a few incorrect file permissions after install.
- Check for invalid hostname and set IGNORE, since we know the build
  will fail in this case.
- Ensure pkg-install is called with correct environment.
2006-08-03 14:39:44 +00:00

80 lines
1.7 KiB
Bash

#!/bin/sh
PKGNAME=$1
[ ! -n PKG_PREFIX ] && exit 1
PKG_PREFIX=${PKG_PREFIX:-/usr/local}
case $2 in
PRE-INSTALL)
echo "===> Checking for old database files"
if [ ! -d ${PKG_PREFIX}/news/db ]; then
mkdir -p ${PKG_PREFIX}/news/db.dist
fi
;;
CHECK-CONF)
ETC_DIR=${3}
echo "Checking for configuration files"
for f in $(find ${ETC_DIR} -name "*.dist" -type f)
do
REALFILE=${f%%.dist}
echo -n "Checking if ${REALFILE} exists: "
if [ -e ${REALFILE} ]
then
echo "[YES]"
else
echo "[NO]"
echo " Installing ${f} to ${REALFILE}"
cp -p ${f} ${REALFILE}
fi
done
;;
POST-INSTALL)
NEWSBASE=${PKG_PREFIX}/news
install -d -o news -g news -m 755 \
${NEWSBASE}/run \
${NEWSBASE}/spool \
${NEWSBASE}/spool/archive \
${NEWSBASE}/spool/articles \
${NEWSBASE}/spool/incoming \
${NEWSBASE}/spool/incoming/bad \
${NEWSBASE}/spool/innfeed \
${NEWSBASE}/spool/outgoing \
${NEWSBASE}/spool/overview \
${NEWSBASE}/spool/tmp
if [ ${3:-""} = "PORTMODE" ]; then
fc=`ls ${NEWSBASE}/db.dist/* 2>/dev/null | wc -l`
if [ -d ${NEWSBASE}/db.dist -a $fc -eq 0 ]; then
for f in ${NEWSBASE}/db/*; do
cp -pR ${f} ${NEWSBASE}/db.dist
done
else
mkdir -p ${NEWSBASE}/db.dist
for f in ${NEWSBASE}/db/*; do
touch ${NEWSBASE}/db.dist/${f##*/}
done
fi
# Fix permissions
for f in ${NEWSBASE}/etc/*.ctl ${NEWSBASE}/etc/readers.conf; do
chmod 640 ${f}
done
else
fc=`ls ${NEWSBASE}/db/* 2>/dev/null | wc -l`
if [ -d ${NEWSBASE}/db -a $fc -eq 0 ]; then
for f in ${NEWSBASE}/db.dist/*; do
cp -pR ${f} ${NEWSBASE}/db
done
fi
fi
;;
*)
echo "Unexpected Argument $2!!!"
exit 1
;;
esac
exit 0