#!/bin/sh # 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//:/:'` if [ "$map" = "/etc/auto.removable" ]; then comopt="-t 20" elif [ "$map" = "/etc/auto.semiperm" ]; then comopt="-t 600" elif [ "$map" = "/etc/auto.net" ]; then comopt="-t 60" else comopt="" fi options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'` if [ -x $map ]; then echo "automount $comopt $dir program $map $options $localoptions" else echo "automount $comopt $dir file $map $options $localoptions" fi fi done ) fi } # # Status lister. # function status() { echo "Configured Mount Points:" echo "------------------------" getmounts echo "" echo "Active Mount Points:" echo "--------------------" ps ax|grep "[0-9]:[0-9][0-9] automount " | ( while read pid tt stat time command; do echo $command; done ) } # # Slackware start/stop function. # function slackware() { # # See how we were called. # case "$1" in start) # Check if the automounter is already running? if [ ! -f /var/lock/automount ]; then echo 'Starting automounter: ' # insmod /lib/modules/`uname -r`/fs/autofs.o getmounts | sh touch /var/lock/automount fi ;; stop) # killall -TERM automount TMP2=/tmp/rc.auto.$$ ps ax|grep "[0-9]:[0-9][0-9] automount " | ( while read pid tt stat time command; do echo "$command" >>$TMP2 if grep -q "^$command" $TMP2; then kill -TERM $pid echo "Stop $command" fi done ) rm $TMP2 rm -f /var/lock/automount # rmmod autofs ;; reload|restart) if [ ! -f /var/lock/automount ]; then echo "Automounter not running" exit 1 fi echo "Checking for changes to /etc/auto.master ...." TMP1=/tmp/rc.auto1.$$ TMP2=/tmp/rc.auto2.$$ getmounts >$TMP1 ps ax|grep "[0-9]:[0-9][0-9] automount " | ( while read pid tt stat time command; do echo "$command" >>$TMP2 if grep -q "^$command" $TMP2; then kill -USR2 $pid echo "Stop $command" fi done ) cat $TMP1 | ( while read x; do if grep -q "^$x" $TMP2; then $x echo "Start $x" fi done ) rm $TMP1 $TMP2 ;; status) status ;; *) echo "Usage: /etc/init.d/autofs {start|stop|restart|reload|status}" exit 1 esac } #echo -n 'Starting automounter: ' #insmod /lib/modules/`uname -r`/fs/autofs.o 2>/dev/null #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./'` # echo -n "$map " # options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'` # automount "$dir" yp "$map" $options $localoptions # fi # done #) slackware "$@"