start on (net-device-up IFACE!=lo)
stop on runlevel [!2345]
expect daemon
respawn
pre-start script
. /etc/default/autofs
# Make sure the (right) kernel module is loaded
if ! grep -q autofs /proc/filesystems; then
if !modprobe autofs4 >/dev/null 2>&1; then
echo "Error: failed to load autofs4 module"
exit 1
fi
elif [ -f /proc/modules ] && grep -q ^autofs[^4] /proc/modules; then
# wrong autofs filesystem module loaded
echo
echo "Error: autofs kernel module is loaded, autofs4 required"
exit 1
fi
# Check misc device
if [ -n "$USE_MISC_DEVICE" -a "$USE_MISC_DEVICE" = "yes" ]; then
sleep 1
if [ -e "/proc/misc" ]; then
MINOR=$(awk '/autofs/ { print $1 }' /proc/misc)
if [ -n "$MINOR" -a ! -c "/dev/autofs" ]; then
mknod -m 0600 /dev/autofs c 10 $MINOR
fi
fi
if [ -x /sbin/restorecon -a -c /dev/autofs ]; then
/sbin/restorecon /dev/autofs
fi
else
if [ -c /dev/autofs ]; then
rm /dev/autofs
fi
fi
end script
This is the upstart job that I've hacked together, but either it's incorrect, or Upstart is misbehaving, because it's not working terribly well.
description "automounter"
author "Andrew Pollock <email address hidden>"
start on (net-device-up IFACE!=lo)
stop on runlevel [!2345]
expect daemon
respawn
pre-start script
. /etc/default/autofs
# Make sure the (right) kernel module is loaded
if ! grep -q autofs /proc/filesystems; then
if !modprobe autofs4 >/dev/null 2>&1; then
echo "Error: failed to load autofs4 module"
exit 1
fi
elif [ -f /proc/modules ] && grep -q ^autofs[^4] /proc/modules; then
# wrong autofs filesystem module loaded
echo
echo "Error: autofs kernel module is loaded, autofs4 required"
exit 1
fi
# Check misc device
if [ -n "$USE_MISC_DEVICE" -a "$USE_MISC_DEVICE" = "yes" ]; then
sleep 1
if [ -e "/proc/misc" ]; then
MINOR=$(awk '/autofs/ { print $1 }' /proc/misc)
if [ -n "$MINOR" -a ! -c "/dev/autofs" ]; then
mknod -m 0600 /dev/autofs c 10 $MINOR
fi
fi
if [ -x /sbin/restorecon -a -c /dev/autofs ]; then
/sbin/restorecon /dev/autofs
fi
else
if [ -c /dev/autofs ]; then
rm /dev/autofs
fi
fi
end script
exec /usr/sbin/automount