Closed HackXIt closed 1 year ago
I'm even getting this issue without the macvlan network, so I'm clearly missing something
One thing to point out is that dashes (-) in yaml might not be supported: https://stackoverflow.com/questions/57586664/using-dash-as-part-of-key-name-in-parameters
for fun with YAML: https://noyaml.com
Which key are you referring to?
The one for the network? That appears to work, even on my other stacks, without problems. When connecting to the container, I can also see the network interface.
Funny link though
ok, then it seems unrelated. What I do notice is Listening to 127.0.0.1:631 (IPv4)
which means cups is not listening on the public IP. You could check if your cups.conf
has Listen *:631
which should be the case when enabling remote admin: https://github.com/SickHub/docker-cups-airprint/blob/c7558a68a89fdf39577eb1197bcd62d2ca4ee378/start-cups.sh#L41
maybe it also gives some more clues when enabling debug logs: CUPS_ENV_DEBUG. That said, I would set the ENVs explicitly or leave them out. ${CUPS_ADMIN_USER:-"admin"}
just means it sets "admin" if the variable is not set or defined which is already part of the startup script.
It does listen on all interfaces, and I am not using any cups.conf
, so it should be default settings for everything.
That said, I did enable CUPS_ENV_DEBUG
now to see what happens:
_cups-airprint-bridge_airprint-bridge.1.kn56a7gwmaz50qv591w1e2fnm_logs(1).txt
I did notice something odd at the beginning:
++ hostname -i
+ CUPS_IP=10.1.0.224
++ hostname -f
+ CUPS_HOSTNAME=airprint-bridge
declare -x AVAHI_INTERFACES="\"\""
declare -x AVAHI_IPV6="\"no\""
declare -x AVAHI_REFLECTOR="\"no\""
declare -x AVAHI_REFLECT_IPV="\"no\""
declare -x CUPS_ACCESS_LOGLEVEL="\"all\""
declare -x CUPS_ADMIN_PASSWORD="41rpr1nt"
declare -x CUPS_ADMIN_USER="\"admin\""
+ CUPS_ADMIN_USER='"admin"'
+ CUPS_ADMIN_PASSWORD=41rpr1nt
+ CUPS_WEBINTERFACE='"yes"'
+ CUPS_SHARE_PRINTERS='"yes"'
+ CUPS_REMOTE_ADMIN='"yes"'
+ CUPS_ACCESS_LOGLEVEL='"all"'
+ CUPS_LOGLEVEL='"debug"'
+ CUPS_SSL_CERT=
+ CUPS_SSL_KEY=
+ AVAHI_INTERFACES='""'
+ AVAHI_FRIENDLY_DESC=:-no
+ AVAHI_IPV6='"no"'
+ AVAHI_REFLECTOR='"no"'
+ AVAHI_REFLECT_IPV='"no"'
+ '[' yes = yes ']'
+ export -n
declare -x CUPS_ENV_DEBUG="yes"
declare -x CUPS_IP="10.1.0.224"
declare -x CUPS_LOGLEVEL="\"debug\""
declare -x CUPS_LPADMIN_PRINTER1=""
declare -x CUPS_REMOTE_ADMIN="\"yes\""
declare -x CUPS_SHARE_PRINTERS="\"yes\""
declare -x CUPS_WEBINTERFACE="\"yes\""
declare -x DEBIAN_FRONTEND="noninteractive"
declare -x HOME="/root"
declare -x HOSTNAME="airprint-bridge"
declare -x OLDPWD
declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
declare -x PWD="/"
declare -x SHLVL="1"
declare -x TZ="GMT"
+ printf %s 41rpr1nt
+ LC_ALL=C
+ grep -q '[^ -~]\+'
++ grep -ci '"admin"' /etc/shadow
+ '[' 0 -eq 0 ']'
++ mkpasswd 41rpr1nt
+ useradd '"admin"' --system -g lpadmin --no-create-home --password '$y$j9T$q20XHtGV/Lr64qCPRvsFL.$AxFUMNjXUOZcGIgWvzZP7t86W9hJ202geIFqQsN99z8'
+ [[ 0 -ne 0 ]]
+ sed -i 's/^.*AccessLog .*/AccessLog stderr/' /etc/cups/cups-files.conf
+ sed -i 's/^.*ErrorLog .*/ErrorLog stderr/' /etc/cups/cups-files.conf
+ sed -i 's/^.*PageLog .*/PageLog stderr/' /etc/cups/cups-files.conf
++ grep '^Listen \*:631' /etc/cups/cupsd.conf
+ '[' yes = '"yes"' -a -z '' ']'
+ '[' -n '' -a -n '' ']'
+ mv /usr/bin/smbspool /usr/bin/smbspool.orig
+ echo '#!/bin/sh
cat <&0| /usr/bin/smbspool.orig $DEVICE_URI "$1" "$2" "$3" "$4" "$5"
exit 0
'
+ chmod +x /usr/bin/smbspool
+ '[' -n '""' ']'
+ sed -i 's/^.*allow-interfaces=.*/allow-interfaces=""/' /etc/avahi/avahi-daemon.conf
+ sed -i 's/^.*use-ipv6=.*/use-ipv6="no"/' /etc/avahi/avahi-daemon.conf
+ sed -i 's/^.*publish-aaaa-on-ipv4=.*/publish-aaaa-on-ipv4="no"/' /etc/avahi/avahi-daemon.conf
+ sed -i 's/^.*enable\-reflector=.*/enable\-reflector\="no"/' /etc/avahi/avahi-daemon.conf
+ sed -i 's/^.*reflect\-ipv=.*/reflect\-ipv\="no"/' /etc/avahi/avahi-daemon.conf
+ sed -i 's/^.*enable-dbus=.*/enable-dbus=no/' /etc/avahi/avahi-daemon.conf
+ /opt/airprint/printer-update.sh
1
+ true
+ /usr/sbin/avahi-daemon -c
Setting up watches.
Watches established.
5
+ /usr/sbin/avahi-daemon
Found user 'avahi' (UID 105) and group 'avahi' (GID 112).
Successfully dropped root privileges.
avahi-daemon 0.8 starting up.
Successfully called chroot().
Successfully dropped remaining capabilities.
No service file found in /etc/avahi/services.
Network interface enumeration completed.
Server startup complete. Host name is airprint-bridge.local. Local service cookie is 2732563847.
+ cupsctl -h localhost:631 --share-printers
+ /usr/sbin/cupsd -f
2
+ echo -n .
1
E [02/Oct/2023:21:08:54 +0000] Unable to open listen socket for address [v1.::1]:631 - Cannot assign requested address.
+ cupsctl -h localhost:631 --share-printers
localhost - - [02/Oct/2023:21:08:55 +0000] "PUT /admin/conf/cupsd.conf HTTP/1.1" 401 0 - -
localhost - root [02/Oct/2023:21:08:55 +0000] "PUT /admin/conf/cupsd.conf HTTP/1.1" 201 4805 - -
+ cupsctl --debug-logging
E [02/Oct/2023:21:08:55 +0000] Unable to communicate with avahi-daemon: Daemon not running
localhost - - [02/Oct/2023:21:08:55 +0000] "PUT /admin/conf/cupsd.conf HTTP/1.1" 401 0 - -
localhost - root [02/Oct/2023:21:08:55 +0000] "PUT /admin/conf/cupsd.conf HTTP/1.1" 201 4759 - -
I [02/Oct/2023:21:08:55 +0000] Listening to 0.0.0.0:631 (IPv4)
I [02/Oct/2023:21:08:55 +0000] Listening to [v1.::]:631 (IPv6)
I [02/Oct/2023:21:08:55 +0000] Listening to /run/cups/cups.sock (Domain)
+ echo '--> CUPS ready'
.--> CUPS ready
+ '[' yes = yes ']'
+ cupsctl --debug-logging
I [02/Oct/2023:21:08:55 +0000] Remote access is enabled.
D [02/Oct/2023:21:08:55 +0000] Added auto ServerAlias airprint-bridge
I [02/Oct/2023:21:08:55 +0000] Loaded configuration file "/etc/cups/cupsd.conf"
D [02/Oct/2023:21:08:55 +0000] Using keychain "/etc/cups/ssl" for server name "airprint-bridge".
I [02/Oct/2023:21:08:55 +0000] Configured for up to 100 clients.
I [02/Oct/2023:21:08:55 +0000] Allowing up to 100 client connections per host.
I [02/Oct/2023:21:08:55 +0000] Using policy "default" as the default.
D [02/Oct/2023:21:08:55 +0000] cupsdMarkDirty(--p--)
D [02/Oct/2023:21:08:55 +0000] cupsdSetBusyState: newbusy="Dirty files", busy="Not busy"
I [02/Oct/2023:21:08:55 +0000] Partial reload complete.
I [02/Oct/2023:21:08:55 +0000] Listening to 0.0.0.0:631 on fd 4...
I [02/Oct/2023:21:08:55 +0000] Listening to [v1.::]:631 on fd 5...
I [02/Oct/2023:21:08:55 +0000] Listening to /run/cups/cups.sock on fd 6...
I [02/Oct/2023:21:08:55 +0000] Resuming new connection processing...
Here are the environment variables I'm using and weirdly, it uses a wrong IP address as seen in the Log: (it uses the correct one, I had an error in my macvlan subnet. The main Problem is the listening interfaces config as it somehow always tries to use the loopback interface but the remote admin thing doesn't work)
Ok, I think it's due to the cups.config... the default is not 0.0.0.0:631 but instead localhost:631.. obviously, that doesn't work.
So, allthough I have enabled remote admin, it still does not configure it the way you described and inside cupsd.config
in the container I only see Listen localhost:631
This is my interface in the container:
root@a5ec1f004b32:/# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
61: eth0@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:0a:01:00:e8 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.1.0.232/24 brd 10.1.0.255 scope global eth0
valid_lft forever preferred_lft forever
I am trying to mount cupsd.conf
in the compose file now:
volumes:
- /home/dietpi/airprint-bridge/cupsd.conf:/etc/cups/cupds.conf
But all I'm getting now is this:
+ sleep 1
+ cupsctl -h localhost:631 --share-printers
localhost - - [02/Oct/2023:22:50:20 +0000] "PUT /admin/conf/cupsd.conf HTTP/1.1" 401 0 - -
E [02/Oct/2023:22:50:20 +0000] Unable to finalize "/etc/cups/cupsd.conf": Device or resource busy
localhost - root [02/Oct/2023:22:50:20 +0000] "PUT /admin/conf/cupsd.conf HTTP/1.1" 500 4579 - -
+ echo -n .
I really can't figure out how I can mount the cupsd.conf
into the container from the host with the file being accessible afterwards.
I also tried this:
volumes:
- type: bind
source: /home/dietpi/airprint-bridge/cupsd.conf
target: /etc/cups/cupsd.conf
read_only: false
But it still results in the above error of the resource being busy... Just HOW can I get this file in the container or otherwise set the listening interfaces to ALL? The default somehow does not work and I'm utterly confused now.
I think I fixed it. for some reason the environment variables in the compose file did not actually make it to the actual container.. I also made sure to use AVAHI_INTERFACES="eth0@if2". I can now access everything.
I'm trying to deploy the image in portainer swarm environment. I've configured a macvlan network and it should be getting a valid address.
However, when running the service, I get this log with a bunch of errors due to it being unable to start the HTTP server:
This is my compose file:
Can anyone help with this?