diff options
author | H. Peter Anvin <hpa@zytor.com> | 1997-10-06 21:05:49 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 1997-10-06 21:05:49 +0000 |
commit | bddd43e289c8b8b62d7cb3f1f7eb27ca67cae28e (patch) | |
tree | aac5e4a4b924cb13a54cc0760e99f349ea36bd12 /samples | |
download | autofs3-bddd43e289c8b8b62d7cb3f1f7eb27ca67cae28e.tar.gz autofs3-bddd43e289c8b8b62d7cb3f1f7eb27ca67cae28e.tar.xz autofs3-bddd43e289c8b8b62d7cb3f1f7eb27ca67cae28e.zip |
Initial revision
Diffstat (limited to 'samples')
-rw-r--r-- | samples/auto.master | 5 | ||||
-rw-r--r-- | samples/auto.misc | 9 | ||||
-rw-r--r-- | samples/rc.autofs | 225 |
3 files changed, 239 insertions, 0 deletions
diff --git a/samples/auto.master b/samples/auto.master new file mode 100644 index 0000000..d5bedc3 --- /dev/null +++ b/samples/auto.master @@ -0,0 +1,5 @@ +# Sample auto.master file +# Format of this file: +# mountpoint map options +# For details of the format look at autofs(8). +/misc /etc/auto.misc diff --git a/samples/auto.misc b/samples/auto.misc new file mode 100644 index 0000000..587879a --- /dev/null +++ b/samples/auto.misc @@ -0,0 +1,9 @@ +# This is an automounter map and it has the following format +# key [ -mount-options-separated-by-comma ] location +# Details may be found in the autofs(5) manpage + +kernel -ro ftp.kernel.org:/pub/linux +boot -fstype=ext2 :/dev/hda1 +removable -fstype=ext2 :/dev/hdd +cd -fstype=iso9660,ro :/dev/hdc +floppy -fstype=auto :/dev/fd0 diff --git a/samples/rc.autofs b/samples/rc.autofs new file mode 100644 index 0000000..e928792 --- /dev/null +++ b/samples/rc.autofs @@ -0,0 +1,225 @@ +#! /bin/bash +# +# rc file for automount using a Sun-style "master map". +# We first look for a local /etc/auto.master, then a YP +# map with that name +# +# On most distributions, this file should be called: +# /etc/rc.d/init.d/autofs or /etc/init.d/autofs +# + +# This is used in the Debian distribution to determine the proper +# location for the S- and K-links to this init file. +# The following value is extracted by debstd to figure out how to +# generate the postinst script. Edit the field to change the way the +# script is registered through update-rc.d (see the manpage for +# update-rc.d!) +# +FLAGS="defaults 21" + +test -f /usr/sbin/automount || exit 0 +PATH=/sbin:/usr/sbin:/bin:/usr/bin +export PATH + +# +# We can add local options here +# e.g. localoptions='rsize=8192,wsize=8192' +# +localoptions='' + +# +# 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 [ -x $map ]; then + echo "automount $dir program $map $options $localoptions" + else + echo "automount $dir file $map $options $localoptions" + 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./'` + options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'` + echo "automount $dir yp $map $options $localoptions" + 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 + ) +} + + +# +# Redhat start/stop function. +# +function redhat() +{ + +# +# 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: ' + getmounts | sh + touch /var/lock/subsys/automount + fi + ;; + stop) + killall -TERM automount + rm -f /var/lock/subsys/automount + ;; + reload|restart) + if [ ! -f /var/lock/subsys/automount ]; then + echo "Automounter not running" + exit 1 + fi + echo "Checking for changes to /etc/auto.master ...." + TMP1=`tempfile`; + TMP2=`tempfile`; + 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 +} + +# +# Debian start/stop functions. +# +function debian() +{ + +DAEMON=/usr/sbin/automount + +# +# See how we were called. +# +case "$1" in + start) + echo -n 'Starting automounter:' + getmounts | while read cmd mnt rest + do + echo -n " $mnt" + pidfile=/var/run/automount`echo $mnt | sed 's/\//./'`.pid + start-stop-daemon --start --pidfile $pidfile --quiet \ + --exec $DAEMON -- $mnt $rest + # + # Automount needs a '--pidfile' or '-p' option. + # For now we look for the pid ourself. + # + ps ax | grep "[0-9]:[0-9][0-9] $DAEMON $mnt" | ( + read pid rest + echo $pid > $pidfile + echo "$mnt $rest" >> $pidfile + ) + done + echo "." + ;; + stop) + echo 'Stopping automounter.' + start-stop-daemon --stop --quiet --signal USR2 --exec $DAEMON + ;; + reload|restart) + echo "Reloading automounter: checking for changes ... " + TMP=/var/run/automount.tmp + getmounts >$TMP + for i in /var/run/automount.*.pid + do + pid=`head -n 1 $i 2>/dev/null` + [ "$pid" = "" ] && continue + command=`tail +2 $i` + if ! grep -q "^$command" $TMP + then + echo "Stopping automounter: $command" + kill -USR2 $pid + fi + done + rm -f $TMP + /etc/init.d/autofs start + ;; + status) + status + ;; + *) + echo "Usage: /etc/init.d/autofs {start|stop|restart|reload|status}" >&2 + exit 1 + ;; +esac +} + +if [ -f /etc/debian_version ] +then + debian "$@" +else + redhat "$@" +fi + +exit 0 |