Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.4: Create Spotlight indexes for networked volumes' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Create Spotlight indexes for networked volumes
Authored by: chargrill on May 18, '05 04:44:52PM

i just found this hint and read through the comments and was saddened by the reports that this wouldn't work for samba mounted shares. i decided to try it anyhow, and was joyous when it worked. i then decided it was too much work to do this every time my computer is re-connected to the "work" network, so i wrote a script and put it in root's crontab. (note: you may be not want to do this, as it involves a lot of root activity).

here's the shell script:


#!/bin/sh

echo "`date +'%Y%m%d %H:%M:%S'` - checking for VOLUME_NAME" >> /var/root/reindex.VOLUME_NAME.log

if [[ `df -k | grep VOLUME_NAME` != "" ]]
  then
    echo "`date +'%Y%m%d %H:%M:%S'` - VOLUME_NAME mounted" >> /var/root/reindex.VOLUME_NAME.log
    if [[ `mdutil -s /Volumes/VOLUME_NAME | grep Enabled` == "" ]]
      then
        echo "`date +'%Y%m%d %H:%M:%S'` - reindexing VOLUME_NAME" >> /var/root/reindex.VOLUME_NAME.log
        mdutil -i on /Volumes/VOLUME_NAME
    fi
fi

i chmod +x'd the script, put it at /var/root/reindex.VOLUME_NAME, and added the following to root's crontab:


*/5 8-18 * * 1-5 /var/root/reindex.VOLUME_NAME > /dev/null 2>&1

this basically checks every five minutes of the workday if it needs to re-enable indexing on my SMB mounted share and turns it on if it isn't already. and keeps a log on its activities for debugging purposes. i've already removed those lines as i don't need to keep an eye on it after i know it's setup and working properly.

note: figuring out how to do all this as root is left as an exercise to the reader. i don't want to be responsible for anyone hosing their system :)



[ Reply to This | # ]
10.4: Create Spotlight indexes for networked volumes
Authored by: JesperHansen on May 31, '05 08:37:06PM

Instead of polling each minutes, its now possible with Tigers new launchd to only run commands when a specific folder changes (like /Volumes).

Here is a small example of how I enable indexing when I mount my "stuff" smb volume.

Two files are involved, first a Launch Daemon config file:
/Library/LaunchDaemons/enableindexing.plist


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>enableindexing</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/local/bin/enableindexing.sh</string>
        </array>
        <key>WatchPaths</key>
        <array>
                <string>/Volumes</string>
        </array>
</dict>
</plist>
This basically tells the daemon to run the script "/usr/local/bin/enableindexing.sh" when something in /Volumes is changed.

My "/usr/local/bin/enableindexing.sh" scripts look like this:


#!/bin/sh
sleep 1 # let things settle down a bit
if mdutil -s "/Volumes/stuff" | grep -q "Indexing Disabled" ; then
	mdutil -i on "/Volumes/stuff" >/dev/null
fi

If your smb volume is not called stuff, you might want to change the script a bit :)
The "sleep 1" line is enough on my machine (G5), but maybe a longer sleep is needed on a slower machine.
Also remember to run "chmod +x /usr/local/bin/enableindexing.sh"

To tell the Launch Daemon about this new script, either reboot or do "sudo launchctl load /Library/LaunchDaemons/enableindexing.plist"

[ Reply to This | # ]

10.4: Create Spotlight indexes for networked volumes
Authored by: rlaan on Jun 13, '05 08:11:52AM

Very interesting, but what happens if the volume is an automount that mounts on login? e.g. in a Workgroup Environment

Ruben

---
The box said, Windows 95 or better, so I bought OS X.



[ Reply to This | # ]
10.4: Create Spotlight indexes for networked volumes
Authored by: regulus on Jul 06, '05 05:08:45PM

You are KING! That works great!

This tip is so good it should be its own hint.



[ Reply to This | # ]
10.4: Create Spotlight indexes for networked volumes
Authored by: matteus on Jul 12, '05 04:10:05PM
This works great, and I can verify that my SMB shared files are indexed with:
mdls /Volumes/volumename/filename
However neither the spotlight menubar interface or mdfind searches the indices that contain these SMB volumes. This is a great tip to keep my SMB volumes indexed, but if I can't search these indices then what's really the point? Any help appreciated.

Thanks,
matteus

[ Reply to This | # ]
10.4: Create Spotlight indexes for networked volumes
Authored by: regulus on Jul 12, '05 04:27:18PM

To search on them you first cmd-f to bring up a find window and then click "servers"... that will search any mounted drives.



[ Reply to This | # ]