Sophie

Sophie

distrib > Mageia > 2 > i586 > by-pkgid > 48646cdcf290e440a2b0a25434a567fd > files > 8

autofs-5.0.6-6.mga2.i586.rpm

#!/bin/sh

# chkconfig: 345 60 72
# description: This startup script launches the automounter

### BEGIN INIT INFO
# Provides: autofs
# Required-Start:
# Required-Stop:
# Should-Start: $network ldap ypbind
# Should-Stop: $network ldap ypbind
# Default-Start: 3 4 5
# 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
        gprintf "Starting %s: " "$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
                gprintf "Error: failed to load autofs4 module.\n"
                return 1
            fi
        elif ([ -f /proc/modules ] && lsmod) | grep -q autofs[^4]; then
            # wrong autofs filesystem module loaded
            echo
            gprintf "Error: autofs kernel module is loaded, autofs4 required\n"
            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() {
    gprintf "Stopping %s: " "$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() {
    gprintf "Reloading %s: " "$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
        ;;
    *)
        gprintf "Usage: %s {start|stop|restart|reload|condrestart|condreload|status}\n" "$0"
        RETVAL=1
        ;;
esac

exit $RETVAL