From patchwork Mon Jun 18 17:36:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Purdy X-Patchwork-Id: 165542 X-Patchwork-Delegate: gustavo@zacarias.com.ar Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id 202B2B7008 for ; Tue, 19 Jun 2012 03:38:02 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 489D131D74; Mon, 18 Jun 2012 17:37:59 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kBUouacbgSzH; Mon, 18 Jun 2012 17:37:56 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 601DB31D17; Mon, 18 Jun 2012 17:37:56 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 933988F753 for ; Mon, 18 Jun 2012 17:37:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 41E3AFFE31; Mon, 18 Jun 2012 17:37:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RVgclPaJc4Ed; Mon, 18 Jun 2012 17:37:45 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yw0-f46.google.com (mail-yw0-f46.google.com [209.85.213.46]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 739C410B920; Mon, 18 Jun 2012 17:37:09 +0000 (UTC) Received: by yhmm54 with SMTP id m54so4442612yhm.33 for ; Mon, 18 Jun 2012 10:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=l2EvQuXlZAfFV9hAs2pg4aUN8h688O/tRYdZBfD5Fcg=; b=b3hulwxpHR6DdudMoIR/9XfnYZWUHYCTwIXRTWDWX+9Z5VjtQH4Xiq0MjHU2k8xEj8 /is97hSA1z5ZESpwtgbXBPpDTZvfCvKvN4lg1K+14etGRIUgwe7VUrBjFO7GJbRCtIqb Tla0IeO+nC2vnWrOMrtCc4zpMu4TNNhxgovJQwh7FC+CtWrEO97Lj/aeVmujeYMQp5xQ erHN76AwkjkBbEx0sfAhIqakxuYVcZFI6xExqZy1i7tOA/Bz9mjPXWC5ERGNJoPQwn2M VJSmiJzhbK/F8sQfySp7BvbH0z/LdDl+6biXfd96CXTc7Dqpme3zINlVXyQ42VpPEjGw 7HDg== Received: by 10.50.159.227 with SMTP id xf3mr9400511igb.24.1340041028161; Mon, 18 Jun 2012 10:37:08 -0700 (PDT) Received: from localhost.localdomain (h184-60-70-80.mdsnwi.tisp.static.tds.net. [184.60.70.80]) by mx.google.com with ESMTPS id v17sm16663546igv.7.2012.06.18.10.37.06 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Jun 2012 10:37:07 -0700 (PDT) From: Dave Purdy To: jacmet@uclibc.org, buildroot@uclibc.org, thomas.petazzoni@free-electrons.com, arnout@mind.be Date: Mon, 18 Jun 2012 12:36:29 -0500 Message-Id: <1340040989-19507-1-git-send-email-david.c.purdy@gmail.com> X-Mailer: git-send-email 1.7.0.4 Subject: [Buildroot] [PATCH V2] p910nd: Add p910nd lightweight printserver X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net Changes since V1: -p910nd.mk : Fixed source/site, removed need for patch, decrufted. -S55p910nd initscript: Reworked for start-stop-daemon usage, added some basic sanity checks for config-file, lock-dir & run-dir, cleaned up structure and readability, removed cruft, changed do_stop so that it scans run-dir for pid-files instead of looking at the config file, reworked do_start to ensure that each instance of p910nd has its correct/unique process-name and pid-file, and added a restart option. -p910nd.conf : Added clarifying documentation RE format of args/options -RETESTED: with a fresh rootfs build, with different daemon instances (e.g. p9102d), on various devices (e.g. /dev/usb/lp3) - all successful Signed-off-by: Dave Purdy --- package/Config.in | 1 + package/p910nd/Config.in | 8 +++++ package/p910nd/S55p910nd | 76 ++++++++++++++++++++++++++++++++++++++++++++ package/p910nd/p910nd.conf | 20 +++++++++++ package/p910nd/p910nd.mk | 21 ++++++++++++ 5 files changed, 126 insertions(+), 0 deletions(-) create mode 100644 package/p910nd/Config.in create mode 100644 package/p910nd/S55p910nd create mode 100644 package/p910nd/p910nd.conf create mode 100644 package/p910nd/p910nd.mk diff --git a/package/Config.in b/package/Config.in index 1044e9f..f5056a7 100644 --- a/package/Config.in +++ b/package/Config.in @@ -570,6 +570,7 @@ source "package/openntpd/Config.in" source "package/openssh/Config.in" source "package/openswan/Config.in" source "package/openvpn/Config.in" +source "package/p910nd/Config.in" source "package/portmap/Config.in" source "package/pppd/Config.in" source "package/pptp-linux/Config.in" diff --git a/package/p910nd/Config.in b/package/p910nd/Config.in new file mode 100644 index 0000000..490dace --- /dev/null +++ b/package/p910nd/Config.in @@ -0,0 +1,8 @@ +config BR2_PACKAGE_P910ND + bool "p910nd" + help + p910nd is a small printer daemon intended for diskless + workstations. Using ports 9100-9102, it accepts + print jobs and passes them directly to a USB printer. + + http://p910nd.sourceforge.net/ diff --git a/package/p910nd/S55p910nd b/package/p910nd/S55p910nd new file mode 100644 index 0000000..60b719a --- /dev/null +++ b/package/p910nd/S55p910nd @@ -0,0 +1,76 @@ +#!/bin/sh +# +# /etc/init.d/[S55]p910nd +# initscript to start p910nd printer daemon, with match pid-files and process-names + + +CONFIG=/etc/p910nd.conf +RUN_D=/var/run +P910ND=/usr/sbin/p910nd +SUBSYS=/var/lock/subsys + +# check if /etc/p910nd.conf exists, print message & exit if it doesn't +[ ! -f $CONFIG ] && ( echo "The config file /etc/p910nd.conf is missing... exiting now." && exit 0 ) + +# description of config line format for /etc/p910nd.conf +# each configuration line must have form +# N [-b] -f , where N is the port number [0|1|2], -b enables bidirectional traffic, +# and -f specifies a printer device +# +# examples: +# 0 -b -f /dev/usb/lp0 +# (listen on port 9100, with bidirectional traffic, use /dev/usb/lp0, pid-file p9100d.pid) +# +# 2 -f /dev/usb/lp3 +# (listen on port 9102, use /dev/usb/lp3, pid-file p9102d.pid) + + +# check if /var/run exists, create it if not +[ ! -d $RUN_D ] && mkdir -p $RUN_D + +# check if /var/lock/subsys exists, create it if not +[ ! -d $SUBSYS ] && mkdir -p $SUBSYS + +do_start() { + [ -f $CONFIG ] && ( while read PORT OPTIONS; do + case "$PORT" in + ""|\#*) + continue; + esac + P910XD_PID="p910"$PORT"d.pid" # create the correct pid-filename, e.g. p9102d.pid + P910ND_ARGS=" $OPTIONS $PORT" + start-stop-daemon -m -p $RUN_D/$P910XD_PID -S -x $P910ND -- $P910ND_ARGS + echo "starting p910nd with options" $OPTIONS "on port" $PORT "with pid-file" $P910XD_PID + if [ $? -ne 0 ]; then + exit 1 + fi + done + ) < $CONFIG + exit 0 +} + +do_stop() { + for PID_F in $RUN_D/p910?d.pid; do + start-stop-daemon -q -K -p $PID_F + rm $PID_F && echo "stopping p910nd instance with pid-file" $PID_F + done +} + +case $1 in + start) + do_start + ;; + stop) + do_stop + ;; + restart) + do_stop + sleep 1 + do_start + ;; + *) + echo $"Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $? diff --git a/package/p910nd/p910nd.conf b/package/p910nd/p910nd.conf new file mode 100644 index 0000000..da1b7f0 --- /dev/null +++ b/package/p910nd/p910nd.conf @@ -0,0 +1,20 @@ +# p910nd Version 0.95 Copyright (c) 2010 Ken Yap, GPLv2 +# For additional daemon arguments, see man 8 p910nd +# +# description of config line format for /etc/p910nd.conf +# each configuration line must have form +# N [-b] -f +# +# where: +# N is the port number [0|1|2], +# -b enables (optional) bidirectional traffic, and +# -f specifies a printer device +# +# examples: + 0 -b -f /dev/usb/lp0 +# (listen on port 9100, bidirectional traffic, use /dev/usb/lp0, pid-file p9100d) +# +# 2 -f /dev/usb/lp3 +# (listen on port 9102, use /dev/usb/lp3, pid-file p9102d.pid) + + diff --git a/package/p910nd/p910nd.mk b/package/p910nd/p910nd.mk new file mode 100644 index 0000000..94b0ddb --- /dev/null +++ b/package/p910nd/p910nd.mk @@ -0,0 +1,21 @@ +############################################################# +# +# p910nd +# +############################################################# + +P910ND_VERSION = 0.95 +P910ND_SITE = http://$(BR2_SOURCEFORGE_MIRROR).dl.sourceforge.net/sourceforge/p910nd/$(P910ND_VERSION) +P910ND_SOURCE = p910nd-$(P910ND_VERSION).tar.bz2 + +define P910ND_BUILD_CMDS + $(MAKE) $(TARGET_CONFIGURE_OPTS) $(P910ND_MAKE_OPTS) -C $(@D) +endef + +define P910ND_INSTALL_TARGET_CMDS + $(INSTALL) -D -m 0755 $(@D)/p910nd $(TARGET_DIR)/usr/sbin/p910nd + $(INSTALL) -m 0644 -D package/p910nd/p910nd.conf $(TARGET_DIR)/etc/p910nd.conf + $(INSTALL) -m 0755 -D package/p910nd/S55p910nd $(TARGET_DIR)/etc/init.d/S55p910nd +endef + +$(eval $(call GENTARGETS))