#!/bin/sh # chkconfig: 345 60 72 # description: This startup script launches the automounter ### BEGIN INIT INFO # Provides: autofs # Should-Start: $network ldap ypbind # Should-Stop: $network ldap ypbind # Default-Start: 345 # Short-Description: Automounts filesystems on demand # Description: This startup script launches the automounter ### END INIT INFO # Local variables NAME=autofs BINARY=/usr/sbin/automount DEVICE="autofs" LOCKFILE=/var/lock/subsys/$NAME USE_MISC_DEVICE="no" # Source function library. . /etc/rc.d/init.d/functions # Load service configuration [ -f /etc/sysconfig/autofs ] && . /etc/sysconfig/autofs function start() { if [ ! -f $LOCKFILE ]; then echo -n "Starting $NAME: " # Make sure autofs4 module is loaded if ! grep -q autofs /proc/filesystems; then # Try load the autofs4 module fail if we can't modprobe autofs4 >/dev/null 2>&1 if [ $? -eq 1 ]; then echo "Error: failed to load autofs4 module." return 1 fi elif ([ -f /proc/modules ] && lsmod) | grep -q autofs[^4]; then # wrong autofs filesystem module loaded echo echo "Error: autofs kernel module is loaded, autofs4 required" return 1 fi # Check misc device if [ $USE_MISC_DEVICE = "yes" ]; then sleep 1 if [ -e "/proc/misc" ]; then MINOR=`awk "/$DEVICE/ {print \\$1}" /proc/misc` if [ -n "$MINOR" -a ! -c "/dev/$DEVICE" ]; then mknod -m 0600 /dev/$DEVICE c 10 $MINOR fi fi if [ -x /sbin/restorecon -a -c /dev/$DEVICE ]; then /sbin/restorecon /dev/$DEVICE fi else if [ -c /dev/$DEVICE ]; then rm -f /dev/$DEVICE fi fi daemon $BINARY $OPTIONS RETVAL=$? [ $RETVAL -eq 0 ] && touch $LOCKFILE echo fi } function stop() { echo -n $"Stopping $NAME: " count=0 while [ -f $LOCKFILE -a $count -lt 15 ]; do killproc $BINARY RETVAL=$? if [ $RETVAL -eq 0 ]; then rm -f $LOCKFILE else count=$(($count+1)) fi done echo } function restart() { stop start } function reload() { echo -n $"Reloading $NAME: " killproc $BINARY -HUP RETVAL=$? echo } RETVAL=0 case "$1" in start) start ;; stop) stop ;; restart) restart ;; condrestart) if [ -f $LOCKFILE ]; then restart fi ;; reload) reload ;; condreload) if [ -f $LOCKFILE ]; then reload fi ;; status) status $BINARY ;; *) echo "Usage: $0 {start|stop|restart|reload|condrestart|condreload|status}" RETVAL=1 ;; esac exit $RETVAL