WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [project cancelled] help for my init script if possible  (Read 5286 times)

aus9

  • Guest
[project cancelled] help for my init script if possible
« on: March 17, 2013, 09:47:20 AM »
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: [Select]
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

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: [Select]
#!/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

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
« Last Edit: March 19, 2013, 10:14:11 PM by aus9 »

aus9

  • Guest
Re: help for my init script if possible
« Reply #1 on: March 17, 2013, 08:01:04 PM »
edit (again) looking better

Code: [Select]
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

todo

now looking at top and cups we have
Code: [Select]
11672     1 root     S     2904  0.1   0  0.0 /usr/local/sbin/cupsd -C /usr/local/etc/cups/cupsd.conf

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
« Last Edit: March 18, 2013, 12:19:41 AM by aus9 »

aus9

  • Guest
Re: help for my init script if possible
« Reply #2 on: March 18, 2013, 01:37:53 AM »
the above init may be correct, but arch wiki says cupsd is to be started after avahi

so info file will change

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: help for my init script if possible
« Reply #3 on: March 18, 2013, 10:51:53 AM »
I'm using avahi and cups to share a printer for iPhone/iPad/etc and avahi is started after cups...

aus9

  • Guest
Re: help for my init script if possible
« Reply #4 on: March 18, 2013, 07:02:57 PM »
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)

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
« Last Edit: March 18, 2013, 07:13:38 PM by aus9 »

Offline floppy

  • Hero Member
  • *****
  • Posts: 577
Re: [project cancelled] help for my init script if possible
« Reply #5 on: January 04, 2014, 11:50:28 AM »
cups-browsed is tested? or am I your first tester? http://forum.tinycorelinux.net/index.php/topic,16443.0.html
AMD K6-IIIATZ 550MHz MB DFI K6xv3/+66
P4 HP DC7100 3GB 3GHz
Samsung NC10 boot from SD card port (via USB reader)
.. all TinyCore proofed

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: [project cancelled] help for my init script if possible
« Reply #6 on: January 05, 2014, 01:59:33 AM »
I don't believe that user aus9 still frequents these forums.

In some quick testing the following works for me:

cups server: prints locally - OK
cups client: prints from gtk2/gtk3 apps (and some browsers) to cups server printer using libcups without cups installed - OK
cups client: cannot find cups server printer with cups installed - NOT OK
cups client: finds windows server printer and prints with cups installed (hp printer, hplip not required) - OK
windows client: finds cups server printer (using bonjour) and prints - OK
iPhone: finds cups server printer (using airprint) and prints - OK

It seems that cups-1.6 changed the way cups clients discover cups servers and I have not yet figured out how to make this work. In earlier versions of cups it happened automatically with the default cups client configuration...
« Last Edit: January 05, 2014, 08:19:30 AM by Juanito »

Offline floppy

  • Hero Member
  • *****
  • Posts: 577
Re: [project cancelled] help for my init script if possible
« Reply #7 on: January 08, 2014, 05:08:11 PM »

cups client: cannot find cups server printer with cups installed - NOT OK


Thats my TCL configuration.
For the reason it is not prio A (a Win7 and a notebook with ubuntu works), I will search slowly and carefully a solution and post any result (cupsd.conf & hosts file content; access rights of all installed CUPS-TCE correct.. according advices in the net, because that problem seems to exist for other systems).
AMD K6-IIIATZ 550MHz MB DFI K6xv3/+66
P4 HP DC7100 3GB 3GHz
Samsung NC10 boot from SD card port (via USB reader)
.. all TinyCore proofed

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: [project cancelled] help for my init script if possible
« Reply #8 on: January 08, 2014, 10:46:26 PM »
It should work with the cups-browserd running the default configuration on the cups client, but the machine acting as cups client cannot see the cups server broadcast for some reason...

One other way to make it work might be to run the cups-browserd on the cups server with the depreciated cups broadcast enabled.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: [project cancelled] help for my init script if possible
« Reply #9 on: January 10, 2014, 03:24:58 AM »
I discovered that avahi/cups don't like my connection cups client -> wireless repeater -> wireless access point -> router.

When I make a wired connection directly from the cups client to the router, things improve:
Code: [Select]
$ avahi-browse -at
...
+   eth0 IPv4 AirPrint HPOfficeJetG85 @ macminitc           _ipp._tcp            local
+   eth0 IPv4 HP OfficeJet G85 @ macminitc                  _printer._tcp        local
+   eth0 IPv4 HP OfficeJet G85 @ macminitc                  _ipps._tcp           local
+   eth0 IPv4 HP OfficeJet G85 @ macminitc                  _ipp._tcp            local
...
 

..and once I start cups-browsed on the cups client:
Code: [Select]
$ sudo cups-browsed --debug
cups-browsed: Reading config: BrowseRemoteProtocols dnssd cups
...
cups-browsed: Avahi Browser: NEW: service 'HP OfficeJet G85 @ macminitc' of type '_ipp._tcp' in domain 'local'
...
cups-browsed: Found CUPS queue: HPOfficeJetG85 on host macminitc.
...
cups-browsed: Creating/Updating CUPS queue for HPOfficeJetG85
...

It took a few minutes for the cups browser interface to find the server, but once found the print queue was setup automatically using the cups server queue and the cups client could print. To make it persist across reboots, I believe that only /usr/local/etc/cups/printers.conf would need to be added to your backup and cups-browsed would not be required.

The cups browser interface also proposed other connections using a local queue, which require hplip in my case and didn't want to work:
Code: [Select]
[Connection dnssd://HP%20OfficeJet%20G85%20%40%20macminitc._ipp._tcp.local/cups]
"Unable to locate printer "macminitc.local"."
..you could probably hack printers.conf and replace the cups server name with its ip address to fix this.

Code: [Select]
[Connection ipp://192.168.1.200:631/printers/HPOfficeJetG85]
CreateDevice failed: org.freedesktop.DBus.Error.ServiceUnknown:The name org.freedesktop.ColorManager was not provided by any .service files
..which is odd because the cups server does not have the same problem

Code: [Select]
You tried to access the address ipps://macminitc.local:631/printers/HPOfficeJetG85, which is currently unavailable. Please make sure that the web address (URL) is correctly spelled and punctuated, then try reloading the page...which probably means that it needs a local ssl certificate.
« Last Edit: January 10, 2014, 03:32:28 AM by Juanito »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: [project cancelled] help for my init script if possible
« Reply #10 on: January 10, 2014, 05:36:54 AM »
confirmed - the only file required for the cups client connection to the cups server printer to persist across reboot is /usr/local/etc/cups/printers.conf

After reboot, neither avahi nor cups-browsed are required.

It does however seem that the auto-generated printers.conf is required - it would not work when I manually created a printer using ipp://192.168.1.200:631/printers/HPOfficeJetG85, perhaps due to the uuid below.

Code: [Select]
$ sudo cat /usr/local/etc/cups/printers.conf
# Printer configuration file for CUPS v1.6.4
# Written by cupsd on 2014-01-10 18:26
# DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING
<Printer HPOfficeJetG85>
UUID urn:uuid:a3517379-89df-3a56-6468-8d3d0e3cab07
Info HP OfficeJet G85 @ macminitc
Location macminitc
DeviceURI ipp://192.168.1.200:631/printers/HPOfficeJetG85
State Idle
StateTime 1389352906
Type 6
Accepting Yes
Shared No
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
Option cups-browsed true
</Printer>
« Last Edit: January 10, 2014, 05:40:24 AM by Juanito »

Offline floppy

  • Hero Member
  • *****
  • Posts: 577
Re: [project cancelled] help for my init script if possible
« Reply #11 on: January 11, 2014, 01:12:19 PM »
The automatic created printers.conf on the pc with TCL (not working hp printer) is
Code: [Select]
# Printer configuration file for CUPS v1.6.2
# Written by cupsd on 2014-01-11 18:03
# DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING
<Printer HP_officejet_4100_series>
UUID urn:uuid:a54a4101-d54f-39ba-61cc-7301093a9654
Info HP officejet 4100 series
Location druckerprinterserverraspberrypi.fritz.box
DeviceURI ipp://druckerprinterserverraspberrypi.fritz.box:631/printers/HP_officejet_4100_series
State Idle
StateTime 1389045100
Type 6
Accepting Yes
Shared No
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
Option cups-browsed true
</Printer>
<Printer Virtual_PDF_Printer>
UUID urn:uuid:2f9fcf7e-c1c8-35c3-5b72-da754bacbb80
Info Virtual PDF Printer
Location HP7100TCL
MakeModel Generic CUPS-PDF Printer
DeviceURI cups-pdf:/
State Idle
StateTime 1388855307
Type 8450124
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</Printer>
(pdf printer works). I will now disable cups-browsed and avahi and see what is the effect.

Here the working printers.conf file of the working notebook (ubuntu 12.04)
Code: [Select]
# Printer configuration file for CUPS v1.5.3
# Written by cupsd
# DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING
<DefaultPrinter HP-Officejet-4110v-All-in-one-Printer>
UUID urn:uuid:941aa6ed-7fd5-3923-72eb-a27616764e0a
AuthInfoRequired none
Info HP Officejet 4110v All-in-one Printer
Location xxxxxxxxxxxxxxxxx
DeviceURI dnssd://HP%20officejet%204100%20series%20%40%20raspberrypi._ipp._tcp.local/cups
State Idle
StateTime 1389438056
Type 4
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy retry-job
</Printer>
<Printer PDF>
UUID urn:uuid:e6cfa6fe-ae2c-34a3-7ed3-4f9b5428dcb5
Info PDF
MakeModel Generic CUPS-PDF Printer
DeviceURI cups-pdf:/
State Idle
StateTime 1384638128
Type 8450124
Accepting Yes
Shared No
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy retry-job
</Printer>

I will have a look at the differences, disable cups-browsed and search further.
« Last Edit: January 11, 2014, 02:40:04 PM by floppy »
AMD K6-IIIATZ 550MHz MB DFI K6xv3/+66
P4 HP DC7100 3GB 3GHz
Samsung NC10 boot from SD card port (via USB reader)
.. all TinyCore proofed

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: [project cancelled] help for my init script if possible
« Reply #12 on: January 12, 2014, 01:43:14 AM »
Do you mean something that will print a pdf file or something that will convert a file to pdf (if so, what are you using)?
« Last Edit: January 12, 2014, 01:50:03 AM by Juanito »

Offline netnomad

  • Hero Member
  • *****
  • Posts: 1026
Re: [project cancelled] help for my init script if possible
« Reply #13 on: January 13, 2014, 02:16:10 AM »
hi floppy,

i agree that your example works fine until 4.7.7:
Quote
a pdf CUPS printer (in order to convert text or openoffice files to PDF).
Like mine (see above)

did you also succeed in 5.x?

i noticed missing dependencies like cups-pdf.tcz or ghostscript_common.tcz!

thank you for sharing your experiences.
« Last Edit: January 13, 2014, 02:36:19 AM by netnomad »