#!/bin/sh POLIPOUSER=%%USER%% POLIPOGROUP=%%GROUP%% UID=173 GID=${UID} POLIPOCACHE=%%PCACHEDIR%% POLIPOLOG=%%PLOGFILE%% PPIDDIR=%%PPIDDIR%% POLIPOPID=%%PPIDFILE%% if [ "$2" = "PRE-INSTALL" ]; then if fgrep "polipo" "%%DESTDIR%%/etc/newsyslog.conf" 2>/dev/null 1>&2; then if ! fgrep "polipo.pid" "%%DESTDIR%%/etc/newsyslog.conf" 2>/dev/null 1>&2; then echo "==> ERROR: Previous installation left an invalid entry in %%DESTDIR%%/etc/newsyslog.conf." echo "==> Please remove the polipo line from this file and try again." exit 1 fi fi if ! pw groupshow "$POLIPOGROUP" 2>/dev/null 1>&2; then if pw groupadd $POLIPOGROUP -g ${GID} ; then echo "=> Added group \"$POLIPOGROUP\"." else echo "=> Adding group \"$POLIPOGROUP\" failed..." exit 1 fi fi if ! pw usershow "$POLIPOUSER" 2>/dev/null 1>&2; then if pw useradd $POLIPOUSER -u ${UID} -g $POLIPOGROUP -h - \ -s "/sbin/nologin" -d "/nonexistent" \ -c "polipo web cache"; \ then echo "=> Added user \"$POLIPOUSER\"." else echo "=> Adding user \"$POLIPOUSER\" failed..." exit 1 fi fi elif [ "$2" = "POST-INSTALL" ]; then if [ ! -d "%%DESTDIR%%$PPIDDIR" ]; then mkdir -p "%%DESTDIR%%$PPIDDIR" || exit 1 chgrp "$POLIPOGROUP" "%%DESTDIR%%$PPIDDIR" || exit 1 chmod g+w "%%DESTDIR%%$PPIDDIR" || exit 1 fi if [ ! -f "%%DESTDIR%%$POLIPOLOG" ]; then touch "%%DESTDIR%%$POLIPOLOG" || exit 1 chown "$POLIPOUSER" "%%DESTDIR%%$POLIPOLOG" || exit 1 chmod u=rw,g=r,o= "%%DESTDIR%%$POLIPOLOG" || exit 1 fi if ! fgrep "${POLIPOLOG}" "%%DESTDIR%%/etc/newsyslog.conf" 2>/dev/null 1>&2; then echo "Add a line to /etc/newsyslog.conf (or /usr/local/etc/newsyslog.d/polipo if" echo "supported on your system) to enable automatic log file rotation:" echo echo "${POLIPOLOG} ${POLIPOUSER}: 640 3 100 * J ${POLIPOPID} 30" echo fi fi OSVER=`uname -r | sed -e 's/\..*//'` if [ ${OSVER} = "8" -o ${OSVER} = "9" ]; then CACHEPARENT=`dirname ${POLIPOCACHE}` echo "You will need to manually run:" echo " chmod o+x %%DESTDIR%%$CACHEPARENT" echo "to ensure the cache is useable." fi exit 0