1#!/bin/sh 2PREFIX=/usr/local 3LPD_PATH="/usr/local/sbin/lpd" 4INSTALL="/usr/bin/install -c -o root -g wheel" 5LPD_PERMS_PATH="/usr/local/etc/lpd/lpd.perms" 6LPD_CONF_PATH="/usr/local/etc/lpd/lpd.conf" 7PRINTCAP_PATH="/usr/local/etc/printcap" 8SYSCONFDIR=/usr/local/etc 9SBINDIR=/usr/local/sbin 10FILTER_DIR=/usr/local/libexec/filters 11LOCKFILE="/var/run/lpd" 12PSHOWALL="-ax" 13VERSION=3.8.22 14INIT= 15MANDIR=/usr/local/man 16# 17# -- START -- 18# postinstall.freebsd.sh,v 1.1 2001/08/21 20:33:16 root Exp 19# 20# If you are building a PORT, see the 21# DISTRIBUTIONS/Freebsd directory for a complete port 22# building package. 23# 24# This is the shell script that does the postinstall 25# dynamic fixup 26# It needs to be massaged with the information for 27# various paths. 28# If you are building a package, then you do NOT want 29# to have this executed - it will put the sample files 30# in place. You need to do this during the postinstall 31# step in the package installation. 32# 33echo RUNNING postinstall.freebsd.sh parms "'$0 $@'" MAKEPACKAGE="$MAKEPACKAGE" MAKEINSTALL="$MAKEINSTALL" PREFIX="$PREFIX" INIT="$INIT" cwd `pwd` 34if [ "$VERBOSE_INSTALL" != "" ] ; then set -x; fi 35fix () { 36 v=`echo $1 | sed -e 's/[:;].*//'`; 37 p=`echo $2 | sed -e 's/:.*//'`; d=`dirname $p`; 38 if expr "$p" : "\|" >/dev/null ; then 39 echo "$v is a filter '$p'" 40 return 0 41 fi 42 echo "Putting $p in $d, using $v.sample" 43 if [ ! -d "$d" ] ; then 44 echo "Directory $d does not exist!" 45 mkdir -p $d 46 fi 47 if [ -f $v.sample ] ; then 48 if [ $v.sample != $p.sample ] ; then ${INSTALL} $v.sample $p.sample; fi 49 elif [ -f $v ] ; then 50 if [ $v != $p.sample ] ; then ${INSTALL} $v $p.sample; fi 51 else 52 echo "Do not have $v.sample or $v" 53 fi 54 if [ ! -f $p.sample ] ; then 55 echo "Do not have $p.sample" 56 elif [ ! -f $p ] ; then 57 ${INSTALL} -m 644 $p.sample $p; 58 fi; 59} 60# we use the /usr/local/etc/rc.d method to start 61# lpd 62# we have to take them from one place and put in another 63if [ "X$MAKEPACKAGE" = "XYES" ] ; then 64 hold=${DESTDIR}${PREFIX}/etc/lpd 65 echo "Setting up configuration files path for package" ${hold} 66 # we put files into the destination 67 if [ ! -d ${hold} ] ; then mkdir -p ${hold} ; fi; 68 ${INSTALL} lpd.perms ${hold}/lpd.perms.sample 69 ${INSTALL} lpd.conf ${hold}/lpd.conf.sample 70 ${INSTALL} printcap ${hold}/printcap.sample 71 if [ "$INIT" != no ] ; then 72 ${INSTALL} -m 755 init.freebsd ${hold}/lprng.sh 73 fi 74elif [ "X$MAKEINSTALL" = XYES ] ; then 75 # we have the port pre-install operation 76 if [ "$MANDIR" = "/usr/man" -a ! -d ${DESTDIR}/usr/man ] ; then 77 # we have the dreaded standard installation 78 # try to make a symbolic link to 79 echo "Creating symbolic link from /usr/man to /usr/share/man" 80 v=`ln -s ${DESTDIR}/usr/share/man ${DESTDIR}/usr/man`; 81 fi 82 hold=${DESTDIR}${PREFIX}/etc/lpd 83 echo "Setting up configuration files path for installation" ${hold} 84 if [ ! -d ${hold} ] ; then mkdir -p ${hold} ; fi; 85 ${INSTALL} lpd.perms ${hold}/lpd.perms.sample 86 ${INSTALL} lpd.conf ${hold}/lpd.conf.sample 87 ${INSTALL} printcap ${hold}/printcap.sample 88 89 fix ${hold}/lpd.perms "${DESTDIR}${LPD_PERMS_PATH}" 90 fix ${hold}/lpd.conf "${DESTDIR}${LPD_CONF_PATH}" 91 fix ${hold}/printcap "${DESTDIR}${PRINTCAP_PATH}" 92 93 if [ "$INIT" != no ] ; then 94 if [ -f /etc/rc.conf ] ; then 95 perl -spi.bak -e 's/^lpd_enable/#lpd_enable/;' ${DESTDIR}/etc/rc.conf 96 fi 97 ${INSTALL} -m 755 init.freebsd ${hold}/lprng.sh 98 init=${DESTDIR}/usr/local/etc/rc.d/lprng.sh 99 echo "Setting up init script $init using init.freebsd" 100 if [ ! -d `dirname $init` ] ; then mkdir -p `dirname $init ` ; fi; 101 rm -f $init 102 ${INSTALL} -m 755 init.freebsd $init 103 104 echo "Stopping LPD" 105 kill -INT `ps ${PSHOWALL} | awk '/lpd/{ print $1;}'` >/dev/null 2>&1 106 sleep 2; 107 # check the printcap information 108 echo "Checking Printcap Info and fixing permissions" 109 ${SBINDIR}/checkpc -f 110 # restart the server 111 echo "Restarting server" 112 sh $init start 113 fi 114elif [ "X$2" = "XPOST-INSTALL" ] ; then 115 # when doing an install from a package we get the file from the package 116 hold=etc/lpd 117 if [ -f ${hold}/lpd.perms.sample ] ; then 118 fix ${hold}/lpd.perms "${LPD_PERMS_PATH}" 119 fix ${hold}/lpd.conf "${LPD_CONF_PATH}" 120 fix ${hold}/printcap "${PRINTCAP_PATH}" 121 if [ "$INIT" != no ] ; then 122 init=/usr/local/etc/rc.d/lprng.sh 123 ${INSTALL} -m 755 ${hold}/lprng.sh $init; 124 if [ -f /etc/rc.conf ] ; then 125 perl -spi.bak -e 's/^lpd_enable/#lpd_enable/;' /etc/rc.conf 126 fi 127 fi 128 else 129 echo "WARNING: configuration files missing from package! CWD " `pwd` 130 ls 131 exit 1 132 fi 133elif [ "X$2" = "XPRE-INSTALL" ] ; then 134 # we have the port pre-install operation 135 if [ "$MANDIR" = "/usr/man" -a ! -d /usr/man ] ; then 136 # we have the dreaded standard installation 137 # try to make a symbolic link to 138 echo "Creating symbolic link from /usr/man to /usr/share/man" 139 v=`ln -s /usr/share/man /usr/man`; 140 fi 141fi 142exit 0 143