r2832 - in trunk/bootscripts: . blfs/init.d blfs/sysconfig

larry at linuxfromscratch.org larry at linuxfromscratch.org
Mon Oct 18 13:26:31 PDT 2004


Author: larry
Date: 2004-10-18 14:26:29 -0600 (Mon, 18 Oct 2004)
New Revision: 2832

Added:
   trunk/bootscripts/blfs/init.d/autofs
   trunk/bootscripts/blfs/sysconfig/autofs.conf
Modified:
   trunk/bootscripts/Makefile
Log:
added automount

Modified: trunk/bootscripts/Makefile
===================================================================
--- trunk/bootscripts/Makefile	2004-10-18 20:26:04 UTC (rev 2831)
+++ trunk/bootscripts/Makefile	2004-10-18 20:26:29 UTC (rev 2832)
@@ -49,6 +49,11 @@
 	ln -sf  ../init.d/apache ${EXTDIR}/rc.d/rc5.d/S32apache
 	ln -sf  ../init.d/apache ${EXTDIR}/rc.d/rc6.d/K28apache
 
+install-autofs: create-dirs
+	install -m $(MODE) blfs/init.d/autofs    $(EXTDIR)/rc.d/init.d/
+	install -m $(CONFMODE) blfs/sysconfig/autofs.conf $(EXTDIR)/sysconfig/
+	ln -sf  ../init.d/autofs $(EXTDIR)/rc.d/rcsysinit.d/S45autofs
+
 install-bind: create-dirs
 	install -m ${MODE} blfs/init.d/bind       ${EXTDIR}/rc.d/init.d/
 	ln -sf  ../init.d/bind ${EXTDIR}/rc.d/rc0.d/K49bind

Added: trunk/bootscripts/blfs/init.d/autofs
===================================================================
--- trunk/bootscripts/blfs/init.d/autofs	2004-10-18 20:26:04 UTC (rev 2831)
+++ trunk/bootscripts/blfs/init.d/autofs	2004-10-18 20:26:29 UTC (rev 2832)
@@ -0,0 +1,193 @@
+#!/bin/bash
+#
+# Autofs Boot Script
+#
+# Filename:     /etc/rc.d/init.d/autofs
+#
+# Author:       Bryan Mason <bmason at bmason.com>
+#
+# Edit History:
+#
+# Date         Author        Action
+# ----------------------------------------------------------------------
+# 20 Jan 2004  B. Mason      Created by modifying original autofs 
+#                            script created by Peter Anvin
+# 20 Mar 2004  B. Mason      Modified to create mountpoints if they
+#                            don't already exist.
+
+source /etc/sysconfig/rc
+source $rc_functions
+source /etc/sysconfig/autofs.conf
+
+#
+# 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()
+{
+    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 "  $dir program $map $options"
+                    else 
+                        echo "  $dir file $map $options"
+                    fi
+                fi
+            done
+        )
+    fi
+}
+
+#
+# Show the status of configured and active mounts.
+#
+function status()
+{
+    echo "Configured Mount Points:"
+    getmounts |
+    (
+        while read dir type map options
+        do
+            echo $dir $type $map $options
+
+            if [ $type = 'file' ]
+            then
+                cat $map | sed -e '/^#/d' -e '/^$/d' |
+                (
+                    while read key options location
+                    do
+                        echo "  $key $options $location"
+                    done
+                )
+                echo ""
+            fi 
+        done
+    )
+
+    echo "Active Automount Daemons:"
+    if [ $(COLUMNS=1024 ps ax | grep "[0-9]:[0-9][0-9] $automount " | wc -w) -gt 0 ]
+    then
+        COLUMNS=1024 ps ax | grep "[0-9]:[0-9][0-9] $automount " | 
+        (
+            while read pid tt stat time command; do echo "  $command" ; done
+        )
+    else
+         echo "  None";
+    fi
+    echo ""
+
+    echo "Actively Automounted Directories:"
+    getmounts |
+    (
+        while read dir type map options
+        do
+            line=$(mount | grep -v "^automount" | grep "$dir")
+            if [ $(echo $line | wc -w) -ne 0 ]
+                then
+                echo "$line" | sed -e "s/^./  &/"  
+            fi
+        done
+    )
+    echo ""
+}
+
+case "$1" in 
+    start)
+        getmounts | 
+        (
+            while read dir type map options
+            do 
+                echo -n "Automounting $dir..."
+                pidfile=$(echo $dir | sed -e "y/\//-/" | sed -e "s/^-//")
+                pidpath=${piddir}/${pidroot}.${pidfile}.pid
+
+                if [ ! -d "$dir" ]
+                then
+                    echo -n " Creating mountpoint $dir..."
+                    mkdir -p "$dir"
+                fi
+
+                if [ ! -e "$map" ]
+                then
+                    echo "Map file $map does not exist!"
+                    print_status failure
+                    continue
+                fi
+
+                if [ ! -x "$map" -a "$type" == "program" ]
+                then
+                    echo "Map file $map is not executable!"
+                    print_status failure
+                    continue
+                fi
+
+                if [ -e "$pidpath" ]
+                then
+                    echo " "
+                    print_status warning running
+                else
+                    echo " "
+                    $automount -p $pidpath $daemonoptions $dir $type $map $options $localoptions
+                    evaluate_retval
+                fi
+            done 
+        )
+        ;;
+
+    stop)
+        # Kill all automounters listed in /var/run
+        ls ${piddir}/${pidroot}.*.pid 2>/dev/null |
+        (
+            while read pidpath
+            do
+                pid=$(cat $pidpath)
+                pidfile=$(basename $pidpath)
+                mountpoint=$(echo $pidfile | sed -e "s/^autofs\.\(.*\)\.pid$/\1/" | sed -e "y/-/\//")
+                echo "Stopping automount on /$mountpoint..."
+                kill $pid
+                evaluate_retval
+            done
+        )
+
+        # Now kill any rogue automounters (automount process w/o pid files)
+        sleep 1
+        COLUMNS=1024 ps ax | grep "[0-9]:[0-9][0-9] $automount " |
+        (
+            while read pid everything_else
+            do
+                echo "Stopping automount with pid $pid..."
+                kill $pid
+                evaluate_retval
+            done
+        )
+        ;;
+
+    restart)
+        $0 stop
+        sleep 1
+        $0 start
+        ;;
+
+    status)
+        status
+        ;;
+
+    *)
+        echo "usage: $0 {start|stop|restart|status}"
+        exit 1
+        ;;
+esac
+
+
+# END
+

Added: trunk/bootscripts/blfs/sysconfig/autofs.conf
===================================================================
--- trunk/bootscripts/blfs/sysconfig/autofs.conf	2004-10-18 20:26:04 UTC (rev 2831)
+++ trunk/bootscripts/blfs/sysconfig/autofs.conf	2004-10-18 20:26:29 UTC (rev 2832)
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# Autofs configuration file
+#
+# Filename:	/etc/sysconfig/autofs.conf
+#
+# Author:	Bryan Mason
+#
+# Edit History:
+#
+# Date		Author		Action
+# ----------------------------------------------------------------------
+# 19 Jan 2004	B. Mason	Created
+# 18 Oct 2004   L. Lawrence     Assume /usr is not mounted, add timeout
+
+automount=/sbin/automount
+localoptions=''
+daemonoptions='--timeout 60'
+piddir=/var/run
+pidroot=autofs
+
+# END
+




More information about the blfs-book mailing list