diff options
Diffstat (limited to 'www/wwwoffle/INSTALL')
-rw-r--r-- | www/wwwoffle/INSTALL | 74 |
1 files changed, 58 insertions, 16 deletions
diff --git a/www/wwwoffle/INSTALL b/www/wwwoffle/INSTALL index 6e24b5abcc2..7b823d58dbb 100644 --- a/www/wwwoffle/INSTALL +++ b/www/wwwoffle/INSTALL @@ -1,25 +1,67 @@ #!/bin/sh # -# $NetBSD: INSTALL,v 1.1 2002/03/10 22:14:29 fredb Exp $ +# $NetBSD: INSTALL,v 1.2 2002/08/10 17:03:26 fredb Exp $ -PATH=${PKG_PREFIX+${PKG_PREFIX}/sbin:}${PATH} +if [ X"${2}" != XPOST-INSTALL ] +then + exit 0 +fi + +PKG_PREFIX="${PKG_PREFIX-/usr/pkg}" +PATH="${PKG_PREFIX}/sbin":"${PATH}" +NEW_CONF_EXAMPLE="${PKG_PREFIX}/share/examples/wwwoffle.conf" + +# Allow ${CONFDIR} to be set in the environment, so that this unsubstituted +# script can be run directly from the "pkgsrc" subdirectory via `make finish'. +if [ ! -e "${CONFDIR}"/wwwoffle.conf ] +then + CONFDIR="@PKG_SYSCONFDIR@" +fi -# Make an educated guess: -if [ -e ${PKG_PREFIX-/usr/pkg}/etc/wwwoffle ] +if [ ! -d "${CONFDIR}" ] then - CONFDIR=${PKG_PREFIX-/usr/pkg}/etc/wwwoffle -else - CONFDIR=/etc/wwwoffle + mkdir -p "${CONFDIR}" fi -if [ X"${2}" = XPOST-INSTALL ] +# If there's no configuration file in the new ${PKG_SYSCONFDIR}, search +# possible former locations for the old file. If none found, install a +# fresh one. +if [ ! -e "${CONFDIR}/wwwoffle.conf" ] then - for p in `find /var/wwwoffle/html -name wwwoffle.pac` - do - cd `dirname ${p}` - mv ${p} ${p}.dist - sed /PROXY/s/localhost/`hostname`/ ${p}.dist > ${p} - done - cd ${CONFDIR} && wwwoffle-upgrade-config.pl wwwoffle.conf || true - wwwoffle-convert-cache /var/wwwoffle + if [ -e /etc/wwwoffle.conf ] + then + conf_candidates=/etc/wwwoffle.conf + fi + if [ -e "${PKG_PREFIX}/etc/wwwoffle.conf" ] + then + conf_candidates="${PKG_PREFIX}/etc/wwwoffle.conf" + fi + OLD_CONF="$(ls -rt $conf_candidates | tail -1)" + if [ -n "$OLD_CONF" ] + then + cp "${OLD_CONF}" "${CONFDIR}/wwwoffle.conf" + else + cp "${NEW_CONF_EXAMPLE}" "${CONFDIR}/wwwoffle.conf" + fi fi + +# The "wwwoffle-upgrade-config" script needs the template to be in ${CONFDIR}. +if [ ! -e "${CONFDIR}/wwwoffle.conf.install" ] +then + cp "${NEW_CONF_EXAMPLE}" "${CONFDIR}/wwwoffle.conf.install" +fi + +# Put the real hostname in the "wwwoffle.pac" file. +for p in `find /var/wwwoffle/html -name wwwoffle.pac` +do + cd `dirname ${p}` + mv ${p} ${p}.dist + sed /PROXY/s/localhost/`hostname`/ ${p}.dist > ${p} +done + +# Now utilize the install utilities to upgrade the configuration file and +# convert the cache format. Don't require "perl" just to upgrade the config, +# as there may not even be an old config file, and worst case, the user will +# get warnings in "syslog" about deprecated options. +cd ${CONFDIR} && wwwoffle-upgrade-config.pl wwwoffle.conf || true +wwwoffle-convert-cache /var/wwwoffle |