This page is meant to give an overview about compiling and configuring Samba with support for OS X Spotlight support.
Samba uses Gnome Tracker as search engine, search tool and metadata storage system.
You need the following packages installed: tracker and libtracker-sparql-dev, the exact name may be different on your system.
Configure samba with --enable-spotlight:
$ ./configure ... --enable-spotlight ... ... Checking for tracker-sparql-1.0 : not found Checking for tracker-sparql-0.16 : yes Checking for header tracker-sparql.h : yes Checking for library tracker-sparql-0.16 : yes Checking for library glib-2.0 : yes Checking for library gio-2.0 : yes Checking for library gobject-2.0 : yes building with Spotlight support ...
Tracker version 1.0 or newer
Beginning with Tracker 1.0.0, by setting an environment variable Tracker can be configured to register in the system dbus context, offering its services as system services -- a setup that makes much more sense then (mis)using root user dbus context.
This environment variable must be set before Samba is started (eg from within the Samba start script) and before Tracker is started (eg from within the Tracker start script).
You need another environment variable that tells the processes where to find the system dbus IPC socket:
# grep '<listen>' /etc/dbus-1/system.conf | sed 's/<listen>\(.*\)<\/listen>/export DBUS_SESSION_BUS_ADDRESS=\"\1\"/g' export DBUS_SESSION_BUS_ADDRESS="unix:path=/var/run/dbus/system_bus_socket"
Create a user under which Tracker will run
For security reasons it is highly recommended to create a unprivileged user under which Tracker process will run:
# useradd -m tracker
The user needs a home directory, as Tracker will store its database and configuration inside the users home directory:
$ tree --noreport /home/tracker/.config/ /home/tracker/.config/ ├── dconf │ └── user └── tracker $ tree --noreport /home/tracker/.cache/ /home/tracker/.cache/ ├── dconf │ └── user └── tracker ├── db-locale.txt ├── db-version.txt ├── first-index.txt ├── last-crawl.txt ├── meta.db ├── meta.db-shm ├── meta.db-wal └── ontologies.gvdb $
Tracker will run as this user when crawling and indexing filesystems, so permissions on filesystems must grant read access to this user as desired.
Tracker doesn't provide a dbus config file for running as a system service yet, so here is one: Tracker Config File. Thanks Martyn!
dbus Service Files
Copy the existing dbus service files to the system directory and append user directive (using username tracker here):
# cp /usr/share/dbus-1/services/org.freedesktop.Tracker1.* /usr/share/dbus-1/system-services/ # echo "User=tracker" >> /usr/share/dbus-1/system-services/org.freedesktop.Tracker1.*
Configuring which Paths to index in Tracker
Tracker uses Gnome GSettings so settings are stored in the user context of the chosen user, so the user "tracker" in this example. Changing settings can be done by running the commadline tool gsettings, but this requires a user dbus session to be active:
# su tracker tracker$ cd $HOME tracker$ dbus-launch --sh-syntax > .dbus_settings tracker$ . .dbus_settings
Once you have sourced .dbus_settings you can run gsettings command:
tracker$ . .dbus_settings tracker$ gsettings list-recursively | grep Tracker org.freedesktop.Tracker.DB journal-chunk-size 50 org.freedesktop.Tracker.DB journal-rotate-destination '' ... org.freedesktop.Tracker.Extract wait-for-miner-fs false tracker$ gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories "['/Volumes/spotlight']" tracker$
tracker$ export TRACKER_BUS_TYPE="system" tracker$ export DBUS_SESSION_BUS_ADDRESS="unix:path=/var/run/dbus/system_bus_socket" tracker$ /opt/tracker/libexec/tracker-store -v 3 ...
Tracker versions older then 1.0.0
Tracker uses DBUS for IPC between Tracker processes and processes that want to run queries against the Tracker metadata store. Therefor you have to carefully start Samba, a dbus-daemon instance and Tracker ensuring all processes are then able to communicate with each other over the correct DBUS bus: Samba Spotlight Start Script. The magic that makes this work is the environment variable DBUS_SESSION_BUS_ADDRESS.
The dbus-daemon that is started from the script need its config file with a matching DBUS session address, here's an example: Spotlight DBUS Configuration File.
Another point to keep in mind is the location where Tracker stores its config and database. Tracker was developed with a per-user use case in mind, as such configuration and data is put in locations relative to the users home directory of the uid of the Tracker processes. By changing the value of the HOME environment variable (a more fine grained approach is modifying the environment variables of the XDG basedir specification).
Configuring Tracker and using Tracker tools
In order to use Tracker commandline tools, you have to run a root shell and source these shell commands:
# cat .tracker_env INSTALLDIR=/some/dir TRACKER_DIR="$INSTALLDIR/var/tracker" export HOME="$TRACKER_DIR" export DBUS_SESSION_BUS_ADDRESS="unix:path=$INSTALLDIR/var/run/spotlight.ipc" # . .tracker_env #
Now you can tell Tracker which directories to index:
# gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories "['/Volumes/spotlight']"
You can run the Spotlight RPC service mdssvc either as embedded service or as separate RPC daemon by enabling the mdssd RPC daemon:
[global] .... rpc_server:mdssvc = embedded ....
[global] .... rpc_daemon:mdssd = fork rpc_server:mdssvc = external ....
Finally enable Spotlight searching on a per share basis:
[share] path = /some/path spotlight = yes