Merge the cups-enable and cups-disable scripts into the rc script.

idea from and ok robert@
This commit is contained in:
ajacoutot 2010-10-28 15:12:49 +00:00
parent ee3b6095aa
commit 5abca94db5
5 changed files with 49 additions and 178 deletions

View File

@ -1,11 +1,11 @@
# $OpenBSD: Makefile,v 1.81 2010/10/27 15:42:06 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.82 2010/10/28 15:12:49 ajacoutot Exp $
COMMENT= Common Unix Printing System
VERSION= 1.4.4
DISTNAME= cups-${VERSION}-source
PKGNAME= cups-${VERSION}
REVISION= 4
REVISION= 5
CATEGORIES= print sysutils
@ -133,11 +133,6 @@ post-configure:
post-install:
ln -sf ${LOCALBASE}/bin/smbspool \
${PREFIX}/libexec/cups/backend/smb
.for file in cups-enable cups-disable
cp ${FILESDIR}/${file} ${WRKBUILD}
${SUBST_CMD} ${WRKBUILD}/${file}
${INSTALL_SCRIPT} ${WRKBUILD}/${file} ${PREFIX}/sbin
.endfor
# Create a link to foomatic drivers database ; we do it here instead of
# using --enable-ppds-to-cups in the foomatic-db port so that we don't

View File

@ -1,81 +0,0 @@
#!/bin/sh
#
# $OpenBSD: cups-disable,v 1.4 2010/10/12 12:53:15 ajacoutot Exp $
#
# This script disables CUPS by removing links created by cups-enable.
_PREFIX=${TRUEPREFIX}
_BINDIR=/usr/bin
_SBINDIR=/usr/sbin
if [ "`id -u`" -ne 0 ]; then
echo "You must be root to run this script."
exit 1
fi
echo "This script will remove CUPS links from ${_BINDIR} and ${_SBINDIR}"
echo ""
echo -n "Are you sure you want to do this (y/[n])? "
read answer
echo ""
case "${answer}" in
y|Y)
;;
*)
echo "Exiting..."
exit 1
;;
esac
if [ ! -L /usr/sbin/lpc ]; then
echo "CUPS not enabled, exiting..."
exit 0
fi
echo "Removing CUPS links:"
for link in lpq lpr lprm; do
if [ -L ${_BINDIR}/${link} ]; then
echo " ${link}"
fi
rm -f ${_BINDIR}/${link}
done
for link in lpc; do
if [ -L ${_SBINDIR}/${link} ]; then
echo " ${link}"
fi
rm -f ${_SBINDIR}/${link}
done
echo done.
if [ ! -e /usr/sbin/lpd.pre-cups ]; then
echo "Couldn't find saved lpd files, saved files not restored."
else
echo "Trying to restore lpd files:"
for file in \
/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 \
/etc/printcap
do
if [ -e ${file}.pre-cups ]; then
echo " ${file}"
mv ${file}.pre-cups ${file}
fi
done
echo done.
echo ""
fi

View File

@ -1,83 +0,0 @@
#!/bin/sh
#
# $OpenBSD: cups-enable,v 1.4 2010/10/12 12:53:15 ajacoutot Exp $
#
# This script replaces OpenBSD lpd files with the corresponding ones from CUPS.
_PREFIX=${TRUEPREFIX}
_BINDIR=/usr/bin
_SBINDIR=/usr/sbin
if [ "`id -u`" -ne 0 ]; then
echo "You must be root to run this script."
exit 1
fi
echo "This script will replace OpenBSD lpd with CUPS."
echo ""
echo -n "Are you sure you want to do this (y/[n])? "
read answer
echo ""
case "${answer}" in
y|Y)
;;
*)
echo "Exiting..."
exit 1
;;
esac
if [ -e /usr/sbin/lpd.pre-cups -a ! -f /usr/sbin/lpd -a -L /usr/sbin/lpc ]; then
echo "lpd already preserved, not saving old files."
echo ""
elif [ ! -e /usr/sbin/lpd ]; then
echo "Couldn't find lpd files, not saving old files."
echo ""
else
echo "Trying to save lpd files:"
for file in \
/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
do
if [ -f ${file} -a ! -L ${file} ]; then
echo " ${file}"
mv -f ${file} ${file}.pre-cups
fi
done
if [ -f /etc/printcap -a ! -f /etc/printcap.pre-cups ]; then
echo " /etc/printcap"
cp -f /etc/printcap /etc/printcap.pre-cups
fi
echo done.
echo ""
fi
echo "Creating soft links for binaries:"
for file in lpq lpr lprm; do
echo " ${_BINDIR}/${file} -> ${_PREFIX}/bin/${file}"
rm -f ${_BINDIR}/${file}
ln -s ${_PREFIX}/bin/${file} ${_BINDIR}/${file}
done
for file in lpc; do
echo " ${_SBINDIR}/${file} -> ${_PREFIX}/sbin/${file}"
rm -f ${_SBINDIR}/${file}
ln -s ${_PREFIX}/sbin/${file} ${_SBINDIR}/${file}
done
echo done.
echo ""

View File

@ -1,4 +1,4 @@
@comment $OpenBSD: PLIST,v 1.26 2010/10/27 15:42:06 ajacoutot Exp $
@comment $OpenBSD: PLIST,v 1.27 2010/10/28 15:12:50 ajacoutot Exp $
@conflict LPRng-*
@newgroup _cups:541
@newuser _cups:541:541:daemon:CUPS printer spooler daemon:/var/empty:/sbin/nologin
@ -144,10 +144,6 @@ libexec/cups/notifier/
@man man/man8/lpmove.8
@man man/man8/reject.8
sbin/accept
@mode 700
sbin/cups-disable
sbin/cups-enable
@mode
@bin sbin/cupsaccept
@bin sbin/cupsaddsmb
@bin sbin/cupsctl

View File

@ -5,14 +5,58 @@
daemon="${TRUEPREFIX}/sbin/cupsd"
pexp="${daemon} -C ${SYSCONFDIR}/cups/cupsd.conf"
_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() {
chown _cups /dev/ulpt[0-1]
chown _cups /dev/lp[a,t][0-2]
echo y | ${TRUEPREFIX}/sbin/cups-enable >/dev/null
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() {
echo y | ${TRUEPREFIX}/sbin/cups-disable >/dev/null
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 $i.pre-cups $i
fi
done
fi
fi
chown root /dev/lp[a,t][0-2]
chown root /dev/ulpt[0-1]
}