X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=autofs.init;h=8416ac46c42161f95b2621f82eb7c848739ff039;hb=d06732d9e50cf0b6033e9a457084bed5813da505;hp=09e4dcfad00938331dae0408743f6ba97e706904;hpb=a38f29775935cae617c60144345baa68e00ad013;p=packages%2Fautofs.git diff --git a/autofs.init b/autofs.init index 09e4dcf..8416ac4 100644 --- a/autofs.init +++ b/autofs.init @@ -5,11 +5,11 @@ # # 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: automount +# processname: autofs # config: /etc/autofs/auto.master @@ -19,17 +19,20 @@ # 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. -[ "${NETWORKING}" = "no" ] && echo "Error: Networking is down"; exit 0 +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 - -# 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 @@ -39,106 +42,119 @@ localoptions='' getmounts() { # -# Check for local maps to be loaded +# 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/:/:'` - # 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'` - if [ -x $map ]; then - echo "/usr/sbin/automount $mountoptions $dir program $map $options $localoptions" - elif [ -f $map ]; then - echo "/usr/sbin/automount $mountoptions $dir file $map $options $localoptions" +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 + : + else + continue + fi + + maptype=${map%%:*} + 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} ${OPTIONS} $dir program $map $options" + elif [ -f $map ]; then + echo "$DAEMON --timeout ${TIMEOUT} ${OPTIONS} $dir file $map $options" + else + echo "$DAEMON --timeout ${TIMEOUT} ${OPTIONS} $dir `basename $map` $options" + fi else - echo "/usr/sbin/automount $mountoptions $dir `basename $map` $options $localoptions" + map=${map#*/} + if [ "$map" ]; then + if [ "$maptype" = "file" ]; then + map=`echo "/etc/autofs/$map" | sed -e 's:^/etc/autofs//:/:'` + fi + echo "$DAEMON --timeout $TIMEOUT ${OPTIONS} $dir $maptype $map $options" + fi fi - fi done - ) + ) 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 - 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 "/usr/sbin/automount $mountoptions $dir yp $map $options $localoptions" - 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 ${OPTIONS} $mountoptions \ + $dir yp $map $options" + fi + done + ) + fi fi } -# -# See how we were called. -# -case "$1" in - start) +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 +# getmounts | sh + $DAEMON --timeout $TIMEOUT /etc/autofs/auto.master + RETVAL=$? + [ $RETVAL -eq 0 ] && ok || fail + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/autofs else - echo "automount already is running" + msg_already_running automounter fi - touch /var/lock/subsys/automount +} + +stop() { + 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 +} + +RETVAL=0 +# See how we were called. +case "$1" in + start) + start ;; stop) - show Stopping automounter - killproc automount -TERM - rm -f /var/lock/subsys/automount + stop ;; - restart|reload) - if [ ! -f /var/lock/subsys/automount ]; then - echo "Automounter not running" - exit 1 - fi - $0 stop - $0 start - ;; - status) - echo "Configured Mount Points:" - getmounts - echo "" - echo "Active Mount Points:" - ps ax|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | ( - while read pid tt stat time command; do echo $command; done - ) + restart|force-reload) + stop + start ;; +# status) +# nls "Configured Mount Points:" +# getmounts +# echo "" +# 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 +# ) +# ;; *) - echo "Usage: $0 {start|stop|restart|reload|status}" - exit 1 + msg_usage "$0 {start|stop|restart|force-reload|status}" + exit 3 esac -exit 0 +exit $RETVAL