For me, adding the above script to /etc/network/if-up.d/ didn't work. But I was able to address the issue with the following horrible kludge. Since this whole problem will likely be addressed via the new upstart paradigm, I thought I would base my fix on upstart. It could just as easily be put into an init.d script instead.
file: /etc/init/fix-autofs.conf
---------------------------------------------
# fix-autofs - Check for and fix LDAP/AutoFS race condition error
#
# When NIS or LDAP is used in conjunction with AutoFS a race condition is
# introduced into the system where, when AutoFS is started before the network
# is completely up, AutoFS will exit, as it won't be able to find any of it's
# configuration information.
description "AutoFS/LDAP Race Condition Fix"
start on runlevel [2345]
task
script
#
# Using ldapsearch here to pass the time until LDAP binding is up.
# Edit the search term 'ou=automount' to taste...
#
while ! /usr/bin/ldapsearch -xLLL 'ou=automount' > /dev/null 2>&1 ; do
echo "Waiting for LDAP to bind..."
sleep 1
done
if ! /usr/bin/pgrep automount > /dev/null 2>&1 ; then
echo "AutoFS is not running, attempting to start..."
#
# Seriously? Using an upstart script to call invoke-rc.d?
# Yes. There is no upstart configuration file for autofs (yet).
#
/usr/sbin/invoke-rc.d autofs restart
fi
end script
For me, adding the above script to /etc/network/ if-up.d/ didn't work. But I was able to address the issue with the following horrible kludge. Since this whole problem will likely be addressed via the new upstart paradigm, I thought I would base my fix on upstart. It could just as easily be put into an init.d script instead.
file: /etc/init/ fix-autofs. conf ------- ------- ------- ------- ------- ---
-------
# fix-autofs - Check for and fix LDAP/AutoFS race condition error
#
# When NIS or LDAP is used in conjunction with AutoFS a race condition is
# introduced into the system where, when AutoFS is started before the network
# is completely up, AutoFS will exit, as it won't be able to find any of it's
# configuration information.
description "AutoFS/LDAP Race Condition Fix"
start on runlevel [2345]
task sbin/invoke- rc.d autofs restart
script
#
# Using ldapsearch here to pass the time until LDAP binding is up.
# Edit the search term 'ou=automount' to taste...
#
while ! /usr/bin/ldapsearch -xLLL 'ou=automount' > /dev/null 2>&1 ; do
echo "Waiting for LDAP to bind..."
sleep 1
done
if ! /usr/bin/pgrep automount > /dev/null 2>&1 ; then
echo "AutoFS is not running, attempting to start..."
#
# Seriously? Using an upstart script to call invoke-rc.d?
# Yes. There is no upstart configuration file for autofs (yet).
#
/usr/
fi
end script