2

NAME "Raspbian GNU/Linux" VERSION_ID "7" VERSION "7 (wheezy)"</p>

Linux raspberrypi 3.18.7+ #755 PREEMPT Thu Feb 12 17:14:31 GMT 2015 armv6l GNU/Linux

我已经用 Canoscan LIDA 210 安装了 SANE 和 scanbd。从这里的说明中,我放入了一个 /etc/init.d 脚本,该脚本是从 scanbd 附带的示例脚本复制而来的。唯一的修改是路径,我在Required-Start:'中添加了'$ALL'。

问题是:在我以 root 身份使用“service scanbd restart”从命令行手动重新启动 scanbd 进程之前,扫描仪按钮将不起作用。那么一切都很好。该服务似乎仍在正常运行。

但这是一个没有头脑的项目……所以从长远来看这是行不通的。我一直在假设启动过程中启动可能发生得太早,但这可能不是问题。

请看下面的代码。

===重启后,服务重启前===

root@raspberrypi:/home/pi# ps -ef  | grep -i scan
saned     3119     1  0 09:40 ?        00:00:00 /usr/local/sbin/scanbd -c /usr/local/etc/scanbd/scanbd.conf
root      3242  3239  0 09:41 pts/0    00:00:00 grep -i scan

===服务扫描重启===

root@raspberrypi:/etc/init.d# service scanbd restart
[ ok ] Restarting SANE scanner button daemon: scanbd.
root@raspberrypi:/etc/init.d# 

===(服务重启后)===

root@raspberrypi:/etc/init.d# ps -ef | grep -i scan
saned     3352     1  0 09:35 ?        00:00:00 /usr/local/sbin/scanbd -c /usr/local/etc/scanbd/scanbd.conf
root      3371  3243  0 09:37 pts/0    00:00:00 grep -i scan

=== /etc/init.d/scanbd ===

#! /bin/sh
#
# $Id: scanbd.debian 203 2015-02-04 08:05:20Z wimalopaan $
#
#  scanbd - KMUX scanner button daemon
#
#  Copyright (C) 2008 - 2015  Wilhelm Meier (wilhelm.meier@fh-kl.de)
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ...Required-Start:    $local_fs $remote_fs $network $syslog $named networking bootlogs saned cups dbus
### BEGIN INIT INFO
# Provides:          scanbd
# Required-Start:    $ALL 
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Scanner button events daemon
# Description:       scanbd associates actions to scanner buttons
### END INIT INFO

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="SANE scanner button daemon"
NAME=scanbd
DAEMON=/usr/local/sbin/$NAME
DAEMON_ARGS="-c /usr/local/etc/scanbd/scanbd.conf"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
    # Return
    #   0 if daemon has been started
    #   1 if daemon was already running
    #   2 if daemon could not be started

        export SANE_CONFIG_DIR=/usr/local/etc/scanbd
    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
        || return 1
    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
        $DAEMON_ARGS \
        || return 2
}

#
# Function that stops the daemon/service
#
do_stop()
{
    # Return
    #   0 if daemon has been stopped
    #   1 if daemon was already stopped
    #   2 if daemon could not be stopped
    #   other if a failure occurred
    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
    RETVAL="$?"
    [ "$RETVAL" = 2 ] && return 2
    # Wait for children to finish too if this is a daemon that forks
    # and if the daemon is only ever run from this initscript.
    # If the above conditions are not satisfied then add some other code
    # that waits for the process to drop all resources that could be
    # needed by services started subsequently.  A last resort is to
    # sleep for some time.
    start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
    [ "$?" = 2 ] && return 2
    # Many daemons don't delete their pidfiles when they exit.
    rm -f $PIDFILE
    return "$RETVAL"
}

#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
    #
    # If the daemon can reload its configuration without
    # restarting (for example, when it is sent a SIGHUP),
    # then implement that here.
    #
    start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
    return 0
}

case "$1" in
  start)
    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
    do_start
    case "$?" in
        0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
        2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
    esac
    ;;
  stop)
    [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
    do_stop
    case "$?" in
        0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
        2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
    esac
    ;;
  #reload|force-reload)
    #
    # If do_reload() is not implemented then leave this commented out
    # and leave 'force-reload' as an alias for 'restart'.
    #
    #log_daemon_msg "Reloading $DESC" "$NAME"
    #do_reload
    #log_end_msg $?
    #;;
  restart|force-reload)
    #
    # If the "reload" option is implemented then remove the
    # 'force-reload' alias
    #
    log_daemon_msg "Restarting $DESC" "$NAME"
    do_stop
    case "$?" in
      0|1)
        do_start
        case "$?" in
            0) log_end_msg 0 ;;
            1) log_end_msg 1 ;; # Old process is still running
            *) log_end_msg 1 ;; # Failed to start
        esac
        ;;
      *)
        # Failed to stop
        log_end_msg 1
        ;;
    esac
    ;;
  status)
    status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
    ;;
  *)
    echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
    exit 3
    ;;
esac

:

=== insserv -s ===

K:01:0 1 6:fail2ban
K:09:0 6:umountfs
K:05:0 6:umountnfs.sh
K:03:0 6:sendsigs
K:07:0 6 S:hwclock.sh
K:07:0 6:networking
K:04:0 1 6:rsyslog
K:01:0 1 6:ifplugd
K:10:0 6:umountroot
K:01:0 1 6:fake-hwclock
K:01:0 1 6:scanbd
K:01:0 6:plymouth
K:11:0:halt
K:01:0 1 6:saned
K:02:0 1 6:avahi-daemon
K:06:0 1 2 3 4 5 6 S:nfs-common
K:06:0 1 6:rpcbind
K:01:0 1 6:cgroup-bin
K:01:0 6:urandom
K:08:0 1 6:iptables-persistent
K:01:0 1 6:lightdm
K:01:0 1 6:exim4
K:11:6:reboot
K:01:0 1 6:triggerhappy
K:01:0 1 6:xinetd
K:01:0 1 6:alsa-utils
K:01:0 1 6:nfs-kernel-server
K:01:1:cups
S:02:S:udev
S:03:S:keyboard-setup
S:16:S:console-setup
S:02:2 3 4 5:fail2ban
S:08:S:mountall.sh
S:09:S:mountall-bootclean.sh
S:13:S:mountnfs.sh
S:14:S:mountnfs-bootclean.sh
S:11:S:networking
S:01:2 3 4 5:rsyslog
S:01:2 3 4 5:ifplugd
S:01:S:fake-hwclock
S:05:S:checkroot.sh
S:14:2 3 4 5:scanbd
S:14:2 3 4 5:plymouth
S:04:2 3 4 5:saned
S:02:2 3 4 5:dbus
S:03:2 3 4 5:avahi-daemon
S:12:2 3 4 5 S:rpcbind
S:01:2 3 4 5:cgroup-bin
S:01:S:mountkernfs.sh
S:10:S:urandom
S:01:2 3 4 5:iptables-persistent
S:03:2 3 4 5:lightdm
S:17:S:x11-common
S:15:S:kbd
S:02:2 3 4 5:exim4
S:04:S:mountdevsubfs.sh
S:01:2 3 4 5:triggerhappy
S:02:2 3 4 5:xinetd
S:17:S:alsa-utils
S:13:2 3 4 5:nfs-kernel-server
S:01:1:killprocs
S:04:2 3 4 5:cups
S:01:1 2 3 4 5:motd
S:01:S:hostname.sh
S:01:1 2 3 4 5:bootlogs
S:02:1:single
S:02:2 3 4 5:ntp
S:02:2 3 4 5:dphys-swapfile
S:02:2 3 4 5:cron
S:14:2 3 4 5:rmnologin
S:01:2 3 4 5:sudo
S:14:2 3 4 5:rc.local
S:02:2 3 4 5:ssh
S:02:2 3 4 5:rsync
S:07:S:checkfs.sh
S:06:S:mtab.sh
S:17:S:bootmisc.sh
S:06:S:kmod
S:06:S:checkroot-bootclean.sh
S:17:S:plymouth-log
S:17:S:raspi-config
S:10:S:procps
S:10:S:udev-mtab

=== /etc/xinetd.d/sane-port ===

service sane-port
{
        port        = 6566
        socket_type = stream
        wait        = no
        user        = saned
        group       = scanner
        server      = /usr/local/sbin/scanbm
        server_args = scanbm -c /usr/local/etc/scanbd/scanbd.conf
        disable     = no
}

=== /etc/default/saned ===

# Defaults for the saned initscript, from sane-utils

# Set to yes to start saned
RUN=no

# Set to the user saned should run as
RUN_AS_USER=saned

=== /etc/sane.d/dll.conf ===

## /etc/sane.d/dll.conf - Configuration file for the SANE dynamic backend loader
##
## Backends can also be enabled by configuration snippets under
## /etc/sane.d/dll.d directory -- packages providing backends should drop
## a config file similar to dll.conf in this directory, named after the package.
##
#
## The next line enables the network backend; comment it out if you don't need
## to use a remote SANE scanner over the network - see sane-net(5) and saned(8)
net

=== /etc/sane.d/net.conf ===

# This is the net backend config file.

## net backend options
# Timeout for the initial connection to saned. This will prevent the backend
# from blocking for several minutes trying to connect to an unresponsive
# saned host (network outage, host down, ...). Value in seconds.
# connect_timeout = 60

## saned hosts
# Each line names a host to attach to.
# If you list "localhost" then your backends can be accessed either
# directly or through the net backend.  Going through the net backend
# may be necessary to access devices that need special privileges.
# localhost
connect_timeout = 3
localhost # scanbm is listening on localhost

=== /usr/local/etc/scanbd/dll.conf ===

# /etc/sane.d/dll.conf - Configuration file for the SANE dynamic backend loader
#
# Backends can also be enabled by configuration snippets under
# /etc/sane.d/dll.d directory -- packages providing backends should drop
# a config file similar to dll.conf in this directory, named after the package.
#

# The next line enables the network backend; comment it out if you don't need
# to use a remote SANE scanner over the network - see sane-net(5) and saned(8)
#net
abaton
agfafocus
apple
avision
artec
artec_eplus48u
as6e
bh
canon
canon630u
canon_dr
#canon_pp
cardscan
coolscan
#coolscan2
coolscan3
#dc25
#dc210
#dc240
dell1600n_net
dmc
epjitsu
#epson
epson2
fujitsu
#gphoto2
genesys
gt68xx
hp
hp3900
hpsj5s
hp3500
hp4200
hp5400
hp5590
hpljm1005
hs2p
ibm
kodak
kvs1025
kvs20xx
leo
lexmark
ma1509
magicolor
matsushita
microtek
microtek2
mustek
#mustek_pp
mustek_usb
mustek_usb2
nec
niash
#p5
pie
pixma
plustek
#plustek_pp
#pnm
qcam
ricoh
rts8891
s9036
sceptre
sharp
sm3600
sm3840
snapscan
sp15c
#st400
#stv680
tamarack
teco1
teco2
teco3
#test
u12
umax
#umax_pp
umax1220u
v4l
xerox_mfp

=== /usr/local/etc/scanbd/saned.conf ===

# saned.conf
# Configuration for the saned daemon

## Daemon options
# Port range for the data connection. Choose a range inside [1024 - 65535].
# Avoid specifying too large a range, for performance reasons.
#
# ONLY use this if your saned server is sitting behind a firewall. If your
# firewall is a Linux machine, we strongly recommend using the
# Netfilter nf_conntrack_sane connection tracking module instead.
#
# data_portrange = 10000 - 10100


## Access list
# A list of host names, IP addresses or IP subnets (CIDR notation) that
# are permitted to use local SANE devices. IPv6 addresses must be enclosed
# in brackets, and should always be specified in their compressed form.
#
# The hostname matching is not case-sensitive.

#scan-client.somedomain.firm
#192.168.0.1
#192.168.0.1/29
#[2001:7a8:185e::42:12]
#[2001:7a8:185e::42:12]/64

# NOTE: /etc/inetd.conf (or /etc/xinetd.conf) and
# /etc/services must also be properly configured to start
# the saned daemon as documented in saned(8), services(4)
# and inetd.conf(4) (or xinetd.conf(5)).
192.168.178.0/24
4

0 回答 0