X-Git-Url: https://git.pld-linux.org/?a=blobdiff_plain;f=autofs.init;h=6370f0a699f500954f970632c4ed707baaa4bff8;hb=0318fe8687cb7ef14670c50cef052faf5a86100c;hp=d7c8184c842efe2d7c08955c03223b107652626e;hpb=aba83489236c611a5ec4ca31a42b7650f40d00d3;p=packages%2Fautofs.git diff --git a/autofs.init b/autofs.init index d7c8184..6370f0a 100644 --- a/autofs.init +++ b/autofs.init @@ -5,8 +5,8 @@ # # chkconfig: 2345 72 08 # -# description: Script for automount using a Sun-style "master map". -# We first look for a local /etc/autofs/auto.master, then a YP +# description: Script for automount using a Sun-style "master map". \ +# We first look for a local /etc/autofs/auto.master, then a YP \ # map with that name # # processname: autofs @@ -23,12 +23,15 @@ [ -f /etc/sysconfig/autofs ] && . /etc/sysconfig/autofs # Check that networking is up. -if is_no "${NETWORKING}"; then - # nls "ERROR: Networking is down. %s can't be run." - msg_network_down automounter - exit 1 +if is_yes "${NETWORKING}"; then + if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then + msg_network_down automounter + exit 1 + fi +else + exit 0 fi - + DAEMON=/usr/sbin/automount # @@ -41,101 +44,106 @@ getmounts() # # Check for local maps to be loaded # -if [ -f /etc/autofs/auto.master ] -then - cat /etc/autofs/auto.master | sed -e '/^#/d' -e '/^$/d'| ( - while read dir map options - do - if [ ! -z "$dir" -a ! -z "$map" \ - -a x`echo "$map" | cut -c1` != 'x-' ] - then - map=`echo "/etc/autofs/$map" | sed -e 's:^/etc\/autofs//:/:'` - options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'` - if [ -x $map ]; then - echo "$DAEMON --timeout $TIMEOUT $dir program $map $options" - elif [ -f $map ]; then - echo "$DAEMON --timeout $TIMEOUT $dir file $map $options" - else - echo "$DAEMON --timeout $TIMEOUT $dir `basename $map` $options" +if [ -f /etc/autofs/auto.master ]; then + cat /etc/autofs/auto.master | sed -e '/^#/d' -e '/^$/d'| ( + while read dir map options; do + if [ ! -z "$dir" -a ! -z "$map" \ + -a x`echo "$map" | cut -c1` != 'x-' ]; then + maptype=`echo $map | cut -f1 -d:` + if [ "$maptype" = "$map" ]; then + map=`echo "/etc/autofs/$map" | sed -e 's:^/etc\/autofs//:/:'` + options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'` + if [ -x $map ]; then + echo "$DAEMON --timeout $TIMEOUT $dir program $map $options" + elif [ -f $map ]; then + echo "$DAEMON --timeout $TIMEOUT $dir file $map $options" + else + echo "$DAEMON --timeout $TIMEOUT $dir `basename $map` $options" + fi + else + map=`echo $map | cut -f2- -d:` + if [ ! -z "$map" ]; then + if [ "$maptype" = "file" ]; then + map=`echo "/etc/autofs/$map" | sed -e 's:^/etc\/autofs//:/:'` + fi + echo "$DAEMON --timeout $TIMEOUT $dir $maptype $map $options" + fi + fi fi - fi done - ) + ) fi # # Check for YellowPage maps to be loaded # -if [ -e /usr/bin/ypcat ] && [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ] -then - ypcat -k auto.master | ( - while read dir map options - do - if [ ! -z "$dir" -a ! -z "$map" \ - -a x`echo "$map" | cut -c1` != 'x-' ] - then - map=`echo "$map" | sed -e 's/^auto_/auto./'` - 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'` - echo "$DAEMON --timeout $TIMEOUT $mountoptions $dir yp $map $options" - fi - done - ) +if is_yes $USE_YP; then + if [ -e /usr/bin/ypcat ] && \ + [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ]; then + ypcat -k auto.master | ( + while read dir map options; do + if [ ! -z "$dir" -a ! -z "$map" \ + -a x`echo "$map" | cut -c1` != 'x-' ]; then + map=`echo "$map" | sed -e 's/^auto_/auto./'` + 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'` + echo "$DAEMON --timeout $TIMEOUT $mountoptions \ + $dir yp $map $options" + fi + done + ) + fi fi } -# -# See how we were called. -# +RETVAL=0 +# See how we were called. case "$1" in start) # Check if the service is already running? if [ ! -f /var/lock/subsys/autofs ]; then - msg_starting automounter + msg_starting automounter busy - if getmounts | sh; then - deltext;ok - else - deltext;ok - fi - RETVAL=$? + getmounts | sh + RETVAL=$? + [ $RETVAL -eq 0 ] && ok || fail [ $RETVAL -eq 0 ] && touch /var/lock/subsys/autofs else - msg_already_running automounter - exit 1 + msg_already_running automounter fi ;; stop) - 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 + if [ -f /var/lock/subsys/autofs ]; then + msg_stopping automounter + killproc automount + rm -f /var/lock/subsys/autofs >/dev/null 2>&1 + else + msg_not_running automounter + fi ;; - restart) + restart|force-reload) $0 stop $0 start + exit $? ;; status) - echo "Configured Mount Points:" + nls "Configured Mount Points:" getmounts echo "" - echo "Active Mount Points:" + nls "Active Mount Points:" ps axw|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | ( while read pid tt stat time command; do echo $command; done ) ;; *) - msg_usage: "$0 {start|stop|restart|status}" - exit 1 + msg_usage "$0 {start|stop|restart|force-reload|status}" + exit 3 esac exit $RETVAL