openbsd-ports/print/cups/pkg/cupsd.rc

68 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
#
# $OpenBSD: cupsd.rc,v 1.9 2011/04/06 16:50:26 ajacoutot Exp $
daemon="${TRUEPREFIX}/sbin/cupsd"
. /etc/rc.d/rc.subr
pexp="${daemon}"
_lpfiles="/usr/bin/lpq /usr/bin/lpr /usr/bin/lprm /usr/sbin/lpc \
/usr/sbin/lpd /usr/share/man/cat1/lpq.0 /usr/share/man/cat1/lpr.0 \
/usr/share/man/cat1/lprm.0 /usr/share/man/cat8/lpc.0 \
/usr/share/man/cat8/lpd.0"
rc_pre() {
[ -e /dev/ulpt0 ] && chown _cups /dev/ulpt[0-1]
[ -e /dev/lpt0 ] && chown _cups /dev/lp[a,t][0-2]
if [ -e /usr/sbin/lpd.pre-cups -a ! -f /usr/sbin/lpd -a -L /usr/sbin/lpc ]; then
return
elif [ ! -e /usr/sbin/lpd ]; then
return
else
for i in ${_lpfiles}; do
if [ -f $i -a ! -L $i ]; then
mv -f $i $i.pre-cups
fi
done
fi
if [ -f /etc/printcap -a ! -f /etc/printcap.pre-cups ]; then
cp -f /etc/printcap /etc/printcap.pre-cups
fi
for i in lpq lpr lprm; do
rm -f /usr/bin/$i
ln -s ${TRUEPREFIX}/bin/$i /usr/bin/$i
done
rm -f /usr/sbin/lpc
ln -s ${TRUEPREFIX}/sbin/lpc /usr/sbin/lpc
}
rc_post() {
if [ ! -L /usr/sbin/lpc ]; then
return
else
for i in lpq lpr lprm; do
rm -f /usr/bin/$i
done
rm -f /usr/sbin/lpc
if [ ! -e /usr/sbin/lpd.pre-cups ]; then
return
else
for i in ${_lpfiles} /etc/printcap; do
if [ -e $i.pre-cups ]; then
mv -f $i.pre-cups $i
fi
done
fi
fi
[ -e /dev/lpt0 ] && chown root /dev/lp[a,t][0-2]
[ -e /dev/ulpt0 ] && chown root /dev/ulpt[0-1]
}
rc_cmd $1