Tiny Core Extensions > TCE Q&A Forum

[project cancelled] help for my init script if possible

(1/3) > >>

aus9:
Hi

Firstly there is a new executable which does not allow -h or --help to be used for it called /usr/local/sbin/cups-browsed which is a part of an upgrade for cups and will be a part of a tcz called cups-filters

--- Code: ---file /tmp/tcloop/cups-filters/usr/local/sbin/cups-browsed
/tmp/tcloop/cups-filters/usr/local/sbin/cups-browsed: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.22, not stripped

--- End code ---

I am concerned with improving the init script and not whether the executable will work (That will require testing with some kind soul with wireless printing)

1) Initially I had a chain of if then, elif , elif else and cli

Here is my current version of script put in a code box for display purposes only, quote gets too small for my eyesight

--- Code: ---#!/bin/sh
# we need dbus, cups, avahi, avahi-dnsconfd running before
# starting this service. Ideas taken from avahi init
# and dumbed down to my level. Above is put into info file
# this is only to do cups-browsed

start() {
if [ ! -f /var/run/dbus/avahi_flag ] ; then
          /usr/local/etc/init.d/avahi start
        else
            /usr/local/sbin/avahi-dnsconfd -D
        fi
        touch /var/run/dbus/cups-browsed_flag
        /usr/local/sbin/cups-browsed &

}

stop() {
rm -rf /var/run/dbus/cups-browsed_flag
pkill cups-browsed
pkill avahi-dnsconfd
}

status() {
if pidof cups-browsed > 0 ; then
echo -e "\ncups-browsed is running.\n"
exit 0
else
echo -e "\ncups-browsed is not running.\n"
exit 1
fi
}

case $1 in
start) start
;;
stop) stop
;;
status) status
;;
restart) stop; start
;;
*) echo -e "\n$0 [start|stop|restart|status]\n"
;;
esac

--- End code ---

The creation of the flag under /var/run is based on avahi, and might be useful if pidof is not useful but I can't really tell at this stage.

thanks for reading

TODO see if I can get it to see the /usr/local/etc/....config file like cupsd can

aus9:
edit (again) looking better


--- Code: ---root@box:~# bash -x /usr/local/etc/init.d/cups-browsed  stop
+ case $1 in
+ stop
+ rm -rf /var/run/dbus/cups-browsed_flag
+ pkill cups-browsed
+ pkill avahi-dnsconfd
root@box:~# bash -x /usr/local/etc/init.d/cups-browsed  status
+ case $1 in
+ status
+ pidof cups-browsed
+ echo -e '\ncups-browsed is not running.\n'

cups-browsed is not running.

+ exit 1
root@box:~# bash -x /usr/local/etc/init.d/cups-browsed  start
+ case $1 in
+ start
+ '[' '!' -f /var/run/dbus/avahi_flag ']'
+ /usr/local/sbin/avahi-dnsconfd -D
+ touch /var/run/dbus/cups-browsed_flag
+ /usr/local/sbin/cups-browsed
root@box:~# bash -x /usr/local/etc/init.d/cups-browsed  status
+ case $1 in
+ status
+ pidof cups-browsed
+ echo -e '\ncups-browsed is running.\n'

cups-browsed is running.

+ exit 0

--- End code ---

todo

now looking at top and cups we have

--- Code: ---11672     1 root     S     2904  0.1   0  0.0 /usr/local/sbin/cupsd -C /usr/local/etc/cups/cupsd.conf

--- End code ---

but I don't have my product displaying the config pathway----------------I don't have a wireless card
/usr/local/etc/cups/cups-browsed.conf

upstream contents (will change when I know why I am going wrong)

--- Quote ---# Which protocols will we use to discover printers on the network?
# Can use DNSSD and/or CUPS, or 'none' for neither.
BrowseRemoteProtocols none

# Use BrowsePoll to poll a particular CUPS server
# BrowsePoll cups.example.com

--- End quote ---

aus9:
the above init may be correct, but arch wiki says cupsd is to be started after avahi

so info file will change

Juanito:
I'm using avahi and cups to share a printer for iPhone/iPad/etc and avahi is started after cups...

aus9:
thats great to know. But we are talking v 1.4.8 but I don't have wireless so I may have it ass before head

What do you make of this? (some bits culled)


--- Quote ---HELPER DAEMON FOR BROWSING REMOTE CUPS PRINTERS

From version 1.6.0 on in CUPS the CUPS broadcasting/browsing
    facility was dropped, in favour of Bonjour-based broadcasting of
    shared printers. This is done as Bonjour broadcasting of shared
    printers is a standard, established by the PWG (Printing Working
    Group, http://www.pwg.org/), and most other network services
    (shared file systems, shared media files/streams, remote desktop
    services, ...) are also broadcasted via Bonjour.

    Problem is that CUPS only broadcasts its shared printers but does
    not browse broadcasts of other CUPS servers to make the shared
    remote printers available locally without any configuration
    efforts. This is a regression compared to the old CUPS
    broadcasting/browsing.

.....

The solution is cups-browsed, a helper daemon running in parallel
    to the CUPS daemon which listens to Bonjour broadcasts of shared
    CUPS printers on remote machines in the local network via Avahi,
    and can also listen for (and send) CUPS Browsing broadcasts. For
    each reported remote printer it creates a local raw queue pointing
    to the remote printer so that the printer appears in local print
    dialogs and is also available for printing via the command
    line. As with the former CUPS broadcasting/browsing with this
    queue the driver on the server is used and the local print dialogs
    give access to all options of the server-side printer driver.
......
Here is some info on how cups-browsed works internally:

    - Daemon start
      o Wait for CUPS daemon if it is not running
      o Read out all CUPS queues created by this daemon (in former sessions)
      o Mark them unconfirmed and set timeout 10 sec from now
    - Main loop (use avahi_simple_poll_iterate() to do queue list maintenance
                 regularly)
      o Event: New printer shows up
        + Queue for printer is already created by this daemon -> Mark list
          entry confirmed, if discovered printer is ipps but existing queue ipp,
     upgrade existing queue by setting URI to ipps. Set status to
     to-be-created and timeout to now-1 sec to make the CUPS queue be
     updated.
        + Queue does not yet exist -> Mark as to-be-created and set
     timeout to now-1 sec.
      o Event: A printer disappears
        + If we have listed a queue for it, mark the entry as disappeared, set
          timeout to now-1 sec
      o On any of the above events and every 2 sec
        + Check through list of our listed queues
          - If queue is unconfirmed and timeout has passed, mark it as
            disappeared, set timeout to now-1 sec
          - If queue is marked disappered and timeout has passed, check whether
       there are still jobs in it, if yes, set timeout to 10 sec from now,
       if no, remove the CUPS queue and the queue entry in our list. If
       removal fails, set timeout to 10 sec.
     - If queue is to-be-created, create it, if succeeded set to
       confirmed, if not, set timeout to 10 sec fron now. printer-is-shared
       must be set to false.
    - Daemon shutdown
      o Remove all CUPS queues in our list, as long as they do not have jobs.

above is from readme

#######################
below is snippet from changes

- CUPS no longer supports automatic remote printers or implicit classes
     via the CUPS, LDAP, or SLP protocols (STR #3922, STR #3923)

--- End quote ---

now just to show how little I know, cups-browsed seems to be for "other"

but this doc appears to be valid for 1.6.1

http://www.cups.org/documentation.php/network.html

I appreciate any correction in my errors as (a) it means I can tone down my wireless warnings in asking for testers
(b) they can connect without browsed
upgrade should be smoother

Navigation

[0] Message Index

[#] Next page

Go to full version