From 5abca94db5bd66afc05634967f1e41b777c853cd Mon Sep 17 00:00:00 2001 From: ajacoutot Date: Thu, 28 Oct 2010 15:12:49 +0000 Subject: [PATCH] Merge the cups-enable and cups-disable scripts into the rc script. idea from and ok robert@ --- print/cups/Makefile | 9 +--- print/cups/files/cups-disable | 81 ---------------------------------- print/cups/files/cups-enable | 83 ----------------------------------- print/cups/pkg/PLIST | 6 +-- print/cups/pkg/cupsd.rc | 48 +++++++++++++++++++- 5 files changed, 49 insertions(+), 178 deletions(-) delete mode 100644 print/cups/files/cups-disable delete mode 100644 print/cups/files/cups-enable diff --git a/print/cups/Makefile b/print/cups/Makefile index 333c069af47..51a01bf7bc8 100644 --- a/print/cups/Makefile +++ b/print/cups/Makefile @@ -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 diff --git a/print/cups/files/cups-disable b/print/cups/files/cups-disable deleted file mode 100644 index 2306541efab..00000000000 --- a/print/cups/files/cups-disable +++ /dev/null @@ -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 diff --git a/print/cups/files/cups-enable b/print/cups/files/cups-enable deleted file mode 100644 index b50374e8e6e..00000000000 --- a/print/cups/files/cups-enable +++ /dev/null @@ -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 "" diff --git a/print/cups/pkg/PLIST b/print/cups/pkg/PLIST index 94e3e6c9b32..44d67e8e58d 100644 --- a/print/cups/pkg/PLIST +++ b/print/cups/pkg/PLIST @@ -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 diff --git a/print/cups/pkg/cupsd.rc b/print/cups/pkg/cupsd.rc index b7ac9f887ba..15e95ecff02 100755 --- a/print/cups/pkg/cupsd.rc +++ b/print/cups/pkg/cupsd.rc @@ -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] }