Difference between revisions of "Avahi"
(→Connecting via SSH using mDNS: change old "castle" to new "palm-webos-device" default hostname, add instruction to connect with OpenSSH key) |
(Note an issue in installing via command line.) |
||
(10 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
[http://avahi.org Avahi] is a Linux service for providing multicast-DNS/DNS-SD (also known as [http://en.wikipedia.org/wiki/Bonjour_%28software%29 Bonjour] or mDNS/DNS-SD). Avahi allows for simple service discovery and advertisement on a local network and provides name resolution for all hosts running a mDNS/DNS-SD service. | [http://avahi.org Avahi] is a Linux service for providing multicast-DNS/DNS-SD (also known as [http://en.wikipedia.org/wiki/Bonjour_%28software%29 Bonjour] or mDNS/DNS-SD). Avahi allows for simple service discovery and advertisement on a local network and provides name resolution for all hosts running a mDNS/DNS-SD service. | ||
− | Using Avahi allows for easy SSH access over a local wireless network. Once installed and started, users can ssh to their device using their mDNS assigned hostname. | + | Using Avahi allows for easy SSH access, among other things, over a local wireless network. Once installed and started, users can ssh to their device using their mDNS assigned hostname. |
==Avahi Installation== | ==Avahi Installation== | ||
− | First, | + | For 2.x and 3.x devices, avahi can be found in the alpha repo, any other devices install via ipkg as follows: |
+ | |||
+ | First, use novacom to access the Pre and install the Avahi ipkg. | ||
− | |||
$> sudo /opt/bin/ipkg-opt install avahi | $> sudo /opt/bin/ipkg-opt install avahi | ||
− | Avahi currently attempts to access a different dbus system socket than the one provided by the Pre's dbus, | + | Avahi seems to want to run as a user named "avahi". To create the user, run the following command: |
+ | |||
+ | $> adduser -h /opt/var/run/avahi avahi | ||
+ | |||
+ | |||
+ | Avahi currently attempts to access a different dbus system socket than the one provided by the Pre's dbus, it is possible to start Avahi with dbus support by creating a symbolic link from palm dbus directory to the /opt dbus directory and starting avahi daemon with root privileges. According to the Avahi website, however running avahi-daemon with root privileges is not recommended. | ||
+ | |||
+ | The following command will create a symbolic link to /opt dbus directory to palm dbus directory: | ||
+ | |||
+ | ln -s /var/run/dbus /opt/var/run/dbus | ||
+ | |||
+ | |||
+ | if preferred avahi can be be ran without dbus support by editing <tt>/opt/etc/avahi/avahi-daemon.conf</tt> and make the following change: | ||
Replace this line: | Replace this line: | ||
Line 21: | Line 34: | ||
enable-dbus=no | enable-dbus=no | ||
− | + | However, this does not allow the use of avahi commands such as avahi-browse, avahi-publish etc... | |
+ | |||
− | + | At this point, the Avahi daemon can be started with root privileges and dbus support with the following command: | |
+ | $> /opt/sbin/avahi-daemon --no-drop-root | ||
− | + | If you disabled dbus support however it is recommended to run Avahi daemon without root privileges using the following command: | |
− | $> | + | $> /opt/sbin/avahi-daemon |
Line 55: | Line 70: | ||
Make sure you set the startup script to executable: | Make sure you set the startup script to executable: | ||
− | $> | + | $> chmod 755 /opt/etc/init.d/S60avahi |
+ | |||
+ | Alternatively, you can create an upstart script at '''/etc/event.d/avahi-daemon''': | ||
+ | # avahi-daemon - mDNS/DNS-SD daemon | ||
+ | # | ||
+ | # The Avahi daemon provides mDNS/DNS-SD discovery support (Bonjour/Zeroconf) | ||
+ | # allowing applications to discover services on the network. | ||
+ | |||
+ | description "mDNS/DNS-SD daemon" | ||
+ | |||
+ | start on started LunaSysMgr | ||
+ | respawn | ||
+ | |||
+ | console none | ||
+ | |||
+ | exec /opt/sbin/avahi-daemon | ||
− | + | NOTE 1: This script is not being stored in the /opt directory. You may have to replace it after an update, and it may cause problems with your Pre. | |
− | + | NOTE 2: You may find your device appearing at '''hostname-4.local''' instead of simply '''hostname.local'''. Restarting avahi-daemon (stop avahi, start avahi) will fix that. You could also figure out the root cause for that problem and address it in a pre-start block in the upstart script. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | NOTE: | + | NOTE 3: The Preware alpha feed approach creates a similar upstart script at '''/var/palm/event.d/org.webosinternals.avahi-daemon''' |
==Connecting via SSH using mDNS== | ==Connecting via SSH using mDNS== | ||
Line 80: | Line 105: | ||
'''Note: The system that you are connecting from MUST have a mDNS service also running, else the hostname will not resolve''' | '''Note: The system that you are connecting from MUST have a mDNS service also running, else the hostname will not resolve''' | ||
− | ==Current Issues== | + | ==Current Issues on the Pre== |
− | * The ipkg binary of Avahi attempts to find the dbus socket at <tt>/opt/var/run/dbus/system_bus_socket</tt>, but the Pre's dbus socket is at <tt>/var/run/dbus/system_bus_socket</tt>. I | + | * The ipkg binary of Avahi attempts to find the dbus socket at <tt>/opt/var/run/dbus/system_bus_socket</tt>, but the Pre's dbus socket is at <tt>/var/run/dbus/system_bus_socket</tt>. I have detailed a solution by running Avahi with root privileges however an approach which allow it to run after dropping root privileges is preferred. |
* The avahi-daemon seems to have issues keeping the mDNS name resolution running for more than a few minutes. I don't know if this is a power management issue or something else at this point. | * The avahi-daemon seems to have issues keeping the mDNS name resolution running for more than a few minutes. I don't know if this is a power management issue or something else at this point. | ||
+ | * The command line install approach may result in your device appearing at '''hostname-4.local''' due to avahi-daemon believing that your hostname is already claimed on the first run only. |
Latest revision as of 11:35, 14 January 2012
Avahi
Avahi is a Linux service for providing multicast-DNS/DNS-SD (also known as Bonjour or mDNS/DNS-SD). Avahi allows for simple service discovery and advertisement on a local network and provides name resolution for all hosts running a mDNS/DNS-SD service.
Using Avahi allows for easy SSH access, among other things, over a local wireless network. Once installed and started, users can ssh to their device using their mDNS assigned hostname.
Avahi Installation
For 2.x and 3.x devices, avahi can be found in the alpha repo, any other devices install via ipkg as follows:
First, use novacom to access the Pre and install the Avahi ipkg.
$> sudo /opt/bin/ipkg-opt install avahi
Avahi seems to want to run as a user named "avahi". To create the user, run the following command:
$> adduser -h /opt/var/run/avahi avahi
Avahi currently attempts to access a different dbus system socket than the one provided by the Pre's dbus, it is possible to start Avahi with dbus support by creating a symbolic link from palm dbus directory to the /opt dbus directory and starting avahi daemon with root privileges. According to the Avahi website, however running avahi-daemon with root privileges is not recommended.
The following command will create a symbolic link to /opt dbus directory to palm dbus directory:
ln -s /var/run/dbus /opt/var/run/dbus
if preferred avahi can be be ran without dbus support by editing /opt/etc/avahi/avahi-daemon.conf and make the following change:
Replace this line: #enable-dbus=yes With this line: enable-dbus=no
However, this does not allow the use of avahi commands such as avahi-browse, avahi-publish etc...
At this point, the Avahi daemon can be started with root privileges and dbus support with the following command:
$> /opt/sbin/avahi-daemon --no-drop-root
If you disabled dbus support however it is recommended to run Avahi daemon without root privileges using the following command:
$> /opt/sbin/avahi-daemon
If you would like Avahi to start up at boot, create the following two files:
/opt/etc/init.d/S60avahi
#!/bin/sh [ -e /opt/etc/default/avahi ] && . /opt/etc/default/avahi if [ "$AVAHI_ENABLE" = "no" ]; then exit fi if [ -n "`pidof /opt/sbin/avahi-daemon`" ]; then killall /opt/sbin/avahi 2>/dev/null fi /opt/sbin/avahi-daemon -D
/opt/etc/default/avahi
AVAHI_ENABLE=yes
Make sure you set the startup script to executable:
$> chmod 755 /opt/etc/init.d/S60avahi
Alternatively, you can create an upstart script at /etc/event.d/avahi-daemon:
# avahi-daemon - mDNS/DNS-SD daemon # # The Avahi daemon provides mDNS/DNS-SD discovery support (Bonjour/Zeroconf) # allowing applications to discover services on the network. description "mDNS/DNS-SD daemon" start on started LunaSysMgr respawn console none exec /opt/sbin/avahi-daemon
NOTE 1: This script is not being stored in the /opt directory. You may have to replace it after an update, and it may cause problems with your Pre.
NOTE 2: You may find your device appearing at hostname-4.local instead of simply hostname.local. Restarting avahi-daemon (stop avahi, start avahi) will fix that. You could also figure out the root cause for that problem and address it in a pre-start block in the upstart script.
NOTE 3: The Preware alpha feed approach creates a similar upstart script at /var/palm/event.d/org.webosinternals.avahi-daemon
Connecting via SSH using mDNS
mDNS uses the system's hostname and appends it to the local. domain. Using the Pre's default palm-webos-device hostname, the following command would be used to SSH to your Pre on port 222:
$> ssh -P 222 palm-webos-device.local.
If you are using an OpenSSH key to connect:
$> ssh -i /path/to/ssh/key palm-webos-device.local.
Note: The system that you are connecting from MUST have a mDNS service also running, else the hostname will not resolve
Current Issues on the Pre
- The ipkg binary of Avahi attempts to find the dbus socket at /opt/var/run/dbus/system_bus_socket, but the Pre's dbus socket is at /var/run/dbus/system_bus_socket. I have detailed a solution by running Avahi with root privileges however an approach which allow it to run after dropping root privileges is preferred.
- The avahi-daemon seems to have issues keeping the mDNS name resolution running for more than a few minutes. I don't know if this is a power management issue or something else at this point.
- The command line install approach may result in your device appearing at hostname-4.local due to avahi-daemon believing that your hostname is already claimed on the first run only.