ServerContainers / samba

samba - (ghcr.io/servercontainers/samba) (+ optional zeroconf, wsdd2 & time machine) on alpine [x86 + arm]

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add configuration to change AVAHI service host name

sigxcpu76 opened this issue · comments

In my setup, I'm running this container as a Kubernetes Pod. This pod is running with hostnetwork = true for things to work.
Unfortunately, a side effect of that is that the Avahi host name is the Kubernetes node name instead of the configured Samba service name.
The net effect is that the Samba service is advertised as Library (the Samba service name) and, upon connection, it gets to be gen9 (the Kubernetes node name).
Editing the live pod avahi-daemon.conf and setting host-name to Library fixes that. Unfortunately there is no way to do that through the pod configuration.
Can you please add a new optional env var that patches /etc/avahi/avahi-daemon.conf ?

can you provide me with a sed -i command which patches the file correctly? if so I'll add an env variable to update the value

do you use the internal avahi daemon? or you hosts daemon?

it sounds to me, that I might update this file always if the AVAHI_NAME env is set - what do you think?

sed -i 's/%h/'"$AVAHI_NAME"'/g' /etc/avahi/services/samba.service

sed -i "s/#host-name=foo/host-name=${AVAHI_NAME}/" /etc/avahi/avahi-daemon.conf this does it for me.
I am using internal Avahi daemon as I don't have any other service running on that node that needs Avahi.

The service name is generated correctly - because it is advertised correctly. The pointer is wrong, going to the generic avahi host name, which is the node name. The one that needs patching is the avahi-daemon.conf that is the source for all service mappings to IP addresses/hostnames.

<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
 <name replace-wildcards="yes">Library</name>
 <service>
   <type>_smb._tcp</type>
   <port>445</port>
 </service>

 <service>
  <type>_device-info._tcp</type>
  <port>0</port>
  <txt-record>model=TimeCapsule</txt-record>
 </service>
</service-group>

ahhh so I can remove this sed -i 's/%h/'"$AVAHI_NAME"'/g' /etc/avahi/services/samba.service entierly? since the name is loaded from avahi-daemon.conf

Most likely yes. I am not 100% sure about that.
My guess is that avahi-daemon provides the host part of the service and the service file provides the advertised name of the service.
So you can map something like LIBRARYSAMBA service (the service part) to the host Library.local (the avahi-daemon part).

yeah I thought about it. I'm just adding the additional sed command to patch /etc/avahi/avahi-daemon.conf

okay I fixed it. but build might take some time

okay latest build contains your changes now

I already thumbed up when deployed the last build as in "it works" seeing that you closed the ticket. Thanks.