]> git.pld-linux.org Git - packages/autofs.git/blobdiff - autofs.init
- fixed the init script: typo, added reload (=restart)
[packages/autofs.git] / autofs.init
index a7cd2a0e3f925b7575723546399b2454c476d82f..7bece751a971b0a5bfdbd621e5afe85b70cbfae1 100644 (file)
@@ -9,7 +9,7 @@
 #              We first look for a local /etc/autofs/auto.master, then a YP
 #              map with that name
 #
-# processname: automount
+# processname: autofs
 # config:      /etc/autofs/auto.master
 
 
 # Get network config
 . /etc/sysconfig/network
 
-# Get service config
-[ -f /etc/sysconfig/inetd ] && . /etc/sysconfig/inetd
+# Demon specified configuration.
+[ -f /etc/sysconfig/autofs ] && . /etc/sysconfig/autofs
 
 # Check that networking is up.
-if [ "${NETWORKING}" = "no" ]; then
-       echo "WARNING: Networking is down. Autofs service can't be runed."
-       exit 1
+if is_no "${NETWORKING}"; then
+        # nls "ERROR: Networking is down. %s can't be run." <service>
+        msg_network_down automounter
+        exit 1
 fi
-
-
-#      We can add local options here
-#      e.g. localoptions='rsize=8192,wsize=8192'
-#
-localoptions=''
+                       
+DAEMON=/usr/sbin/automount
 
 #
 #      This function will build a list of automount commands to execute in
@@ -42,7 +39,7 @@ localoptions=''
 getmounts()
 {
 #
-#      Check for local maps to be loaded
+# Check for local maps to be loaded
 #
 if [ -f /etc/autofs/auto.master ]
 then
@@ -52,22 +49,14 @@ then
            if [ ! -z "$dir" -a ! -z "$map" \
                        -a x`echo "$map" | cut -c1` != 'x-' ]
            then
-               map=`echo "/etc/autofs/$map" | sed -e 's:^/etc/autofs/:/:'`
-               # special: treat -t or --timeout (or any reasonable derivative)
-               # specially, since it can't be made a normal mount option.
-               if echo $options | grep -- '-t' >/dev/null 2>&1 ; then
-                   mountoptions="--timeout $(echo $options | \
-                     sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
-               fi
-               options=`echo "$options" | sed -e '
-                 s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
-                 s/\(^\|[ \t]\)-/\1/g'`
+               map=`echo "/etc/autofs/$map" | sed -e 's:^/etc\/autofs//:/:'`
+               options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'`
                if [ -x $map ]; then
-                   echo "/usr/sbin/automount $mountoptions $dir program $map $options $localoptions"
+                   echo "$DAEMON --timeout $TIMEOUT $dir program $map $options"
                elif [ -f $map ]; then
-                   echo "/usr/sbin/automount $mountoptions $dir file $map $options $localoptions"
+                   echo "$DAEMON --timeout $TIMEOUT $dir file $map $options"
                else
-                   echo "/usr/sbin/automount $mountoptions $dir `basename $map` $options $localoptions"
+                   echo "$DAEMON --timeout $TIMEOUT $dir `basename $map` $options"
                fi
            fi
        done
@@ -75,7 +64,7 @@ then
 fi
 
 #
-#      Check for YellowPage maps to be loaded
+# Check for YellowPage maps to be loaded
 #
 if [ -e /usr/bin/ypcat ] && [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ]
 then
@@ -90,10 +79,10 @@ then
                    mountoptions="--timeout $(echo $options | \
                      sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
                fi
-               options=`echo "$options" | sed -e '
-                 s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
-                 s/\(^\|[ \t]\)-/\1/g'`
-               echo "/usr/sbin/automount $mountoptions $dir yp $map $options $localoptions"
+                options=`echo "$options" | sed -e '
+                  s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
+                  s/\(^\|[ \t]\)-/\1/g'`
+               echo "$DAEMON --timeout $TIMEOUT $mountoptions $dir yp $map $options"
            fi
        done
     )
@@ -106,27 +95,32 @@ fi
 case "$1" in
   start)
        # Check if the service is already running?
-       if [ ! -f /var/lock/subsys/automount ]; then
-               show Starting automounter
+       if [ ! -f /var/lock/subsys/autofs ]; then
+                msg_starting automounter
                busy
-               getmounts | sh
-               deltext
-               ok
+               if getmounts | sh; then
+                   deltext;ok
+               else
+                   deltext;ok
+               fi
+                RETVAL=$?
+               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/autofs
        else
-           echo "automount already is running"
+                msg_already_running automounter
+               exit 1
        fi
-       touch /var/lock/subsys/automount
        ;;
   stop)
-       show Stopping automounter
-       killproc automount -TERM
-       rm -f /var/lock/subsys/automount
+        if [ -f /var/lock/subsys/autofs ]; then
+                msg_stopping automount -TERM
+                killproc automount
+                rm -f /var/lock/subsys/autofs >/dev/null 2>&1
+        else
+                msg_not_running automounter
+                exit 1
+        fi
        ;;
   restart|reload)
-       if [ ! -f /var/lock/subsys/automount ]; then
-               echo "Automounter not running"
-               exit 1
-       fi
        $0 stop
        $0 start
        ;;
@@ -135,13 +129,13 @@ case "$1" in
        getmounts
        echo ""
        echo "Active Mount Points:"
-       ps ax|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | (
+       ps axw|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | (
                while read pid tt stat time command; do echo $command; done
        )
        ;;
   *)
-       echo "Usage: $0 {start|stop|restart|reload|status}"
+       msg_usage "$0 {start|stop|restart|reload|status}"
        exit 1
 esac
 
-exit 0
+exit $RETVAL
This page took 0.08378 seconds and 4 git commands to generate.