#!/bin/sh # # Date : Feb 04, 2004 # Author : Terminator, # # rc.autofs - Starts the filesystem automounter # Based on rc.autofs by David Cantrell, # # This function will build a list of automount commands to execute in # order to activate all the mount points. It is used to figure out # the difference of automount points in case of a reload # function getmounts() { # Check for local maps to be loaded if [ -f /etc/auto.master ] then cat /etc/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/$map" | sed -e 's:^/etc//:/:'` options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'` if [ ! -d $dir ] then mkdir -p $dir fi if [ -x $map ] then echo "/usr/sbin/automount -p /var/run/automount.pid -t 3 $dir program $map $options $localoptions" elif [ -f $map ] then echo "/usr/sbin/automount -p /var/run/automount.pid -t 3 $dir file $map $options $localoptions" else echo "/usr/sbin/automount -p /var/run/automount.pid -t 3 $dir `basename $map` $options $localoptions" fi fi done ) fi # Check for NIS 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'` if [ ! -d $dir ] then mkdir -p $dir fi echo "/usr/sbin/automount -p /var/run/automount.pid -t 3 $dir yp $map $options $localoptions" fi done ) fi } autofs_start() { if [ -x /usr/sbin/automount ]; then echo "Starting autofs daemons... " (grep -q autofs /proc/filesystems || modprobe -q autofs || modprobe -q autofs4) 2> /dev/null getmounts | sh fi } autofs_stop() { echo "Stopping autofs daemons... " umount -a -f -t autofs 2> /dev/null killall -15 automount 2> /dev/null modprobe -q -r isofs 2> /dev/null (modprobe -q -r autofs4 || modprobe -q -r autofs) 2> /dev/null } autofs_restart() { autofs_stop sleep 1 autofs_start } case "$1" in 'start') autofs_start ;; 'stop') autofs_stop ;; 'restart') autofs_restart ;; *) echo "usage $0 start|stop|restart" esac