From: Timothy L. <ti...@wo...> - 2000-12-19 08:06:27
|
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> <br>David Paschal wrote: <blockquote TYPE=CITE> <pre>I committed ptal-printd to CVS and rewrote large portions of PRINT-HOWTO. The command-line syntax of ptal-printd has changed, and I think I've fixed the security issues to my liking now. Please try it out and let me know ASAP if there are any remaining problems.</pre> </blockquote> <p><br>Hiya, all. <p>I'm using hpoj with RedHat 6.2. Instead of activating ptal-printd from rc.local, I thought it'd be easier to have a separate init script for it. So I've written up the following script to load ptal-printd as a daemon: <blockquote><tt>#!/bin/sh</tt> <br><tt>#</tt> <br><tt># ptal-printd Startup script for the PTAL-print daemon</tt> <br><tt>#</tt> <br><tt># chkconfig: 345 60 60</tt> <br><tt># description: PTAL permits printing on HP OfficeJet printer connected \</tt> <br><tt># to a local parallel port, or remotely to an HP JetDirect \</tt> <br><tt># network print server.</tt> <br><tt># processname: ptal-printd</tt> <br><tt># config: /etc/ptal-printd.conf</tt> <p><tt># Source function library.</tt> <br><tt>. /etc/rc.d/init.d/functions</tt> <p><tt>RETVAL=0</tt> <p><tt># See how we were called</tt> <br><tt>case "$1" in</tt> <br><tt> start)</tt> <br><tt> # Start daemon</tt> <br><tt> if [ ! -f /var/lock/subsys/ptal-printd ]; then</tt> <br><tt> echo -n "Starting ptal-printd: "</tt> <br><tt> eval `sed -n 's@^\([^#].*\)@\(ptal-printd \1 \&\);@p' /etc/ptal-printd.conf`</tt> <br><tt> touch /var/lock/subsys/ptal-printd</tt> <br><tt> success "ptal-printd startup"</tt> <br><tt> echo</tt> <br><tt> fi</tt> <br><tt> ;;</tt> <br><tt> stop)</tt> <br><tt> # Stop daemon</tt> <br><tt> echo -n "Shutting down ptal-printd: "</tt> <br><tt> killproc ptal-printd</tt> <br><tt> RETVAL=$?</tt> <br><tt> [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ptal-printd</tt> <br><tt> echo</tt> <br><tt> ;;</tt> <br><tt> status)</tt> <br><tt> status ptal-printd</tt> <br><tt> RETVAL=$?</tt> <br><tt> ;;</tt> <br><tt> restart|reload)</tt> <br><tt> $0 stop</tt> <br><tt> $0 start</tt> <br><tt> RETVAL=$?</tt> <br><tt> ;;</tt> <br><tt> *)</tt> <br><tt> echo "Usage: $0 {start|stop|restart|reload|status}"</tt> <br><tt> exit 1</tt> <br><tt>esac</tt> <p><tt>exit $RETVAL</tt></blockquote> The script uses a configuration file <b>/etc/ptal-printd.conf</b>, and it is of the form: <blockquote><tt># ptal-printd.conf</tt> <br><tt>#</tt> <br><tt># All lines not starting with a '#' are considered command line parameters</tt> <br><tt># to ptal-printd.</tt> <br><tt>#</tt> <br><tt># Each printer entry should occupy one line.</tt> <br><tt>#</tt> <br><tt>mlc:mlcpp0 -like /dev/lp0</tt> <br><tt>mlc:mlcpp1 -like /dev/lp1</tt></blockquote> On RedHat systems, the script should be copied under <b>/etc/rc.d/init.d</b> as <b>ptal-printd</b> and chmod 744, then a <b>chkconfig --add ptal-printd</b> will enable the daemon for runlevel 3-5. <p>I've tested it on my system and it works. Perhaps some brave soul would like to try it on theirs??? <br> <blockquote>Timothy Lee</blockquote> </html> |