Skip to contentSkip to conversation

Autofs init script

PATCH Daniel Mueller 1 participant 1 message Nov 29, 2003 Kernel automounter

lore
Share & tools
lore
#0 lore raw

Hello,

this patch is a proposal for a 'generic' system.

BTW, I had some problems to compile autofs-4.1.0-beta3 without openldap. The following command helped me to get rid of this:

$ cd autofs-4.1.0-beta3
$ sed -i  -e 's|^all:.*|all: rc.autofs|g' \
 -e 's|.*install -c autofs-ldap-auto-master.*||g' \
 samples/Makefile
$

If you already know this, I'm sorry.

bye,

Daniel

Signature · 2 lines
Daniel Mueller			mailto:[email protected]
Berlin, Germany		(OpenPGP:  1024D/F7E7C01F)
autofs.new renamed from autofs +60 -2
@@ -36,14 +36,16 @@
 #
 # Determine which kind of configuration we're using
 #
+# Try 'generic' if you have an unsupported system.
+#system=generic
+
 system=unknown
 if [ -f /etc/debian_version ]; then
     system=debian
 elif [ -f /etc/redhat-release ]; then
     system=redhat
-else
+elif [ "$system" = "unknown" ]; then
     echo "$0: Unknown system, please port and contact [email protected]" 1>&2
-    exit 1
 fi
 
 if [ $system = redhat ]; then
@@ -139,6 +141,14 @@
                 ;;
         esac
     done
+    if [ -z "`getschemes`" ]; then
+        # automount entry in /etc/nsswitch.conf not found
+	if [ -z "$filescheme" ] ; then
+		getfilemounts
+		filescheme=1
+		export filescheme
+	fi
+    fi
 }
 
 
@@ -401,11 +411,59 @@
 esac
 }
 
+
+#
+# Generic start/stop function.
+#
+function generic()
+{
+
+case "$1" in
+  start)
+        # Make sure the autofs filesystem type is available.
+        (grep -q autofs /proc/filesystems || /sbin/modprobe -k autofs4 || /sbin/modprobe -k autofs) 2> /dev/null
+        TMP=`mktemp /tmp/autofs.XXXXXX` || { echo $"could not make temp file" >& 2; exit 1; }
+        getmounts | tee $TMP | sh
+        RETVAL=$?
+	if [ -s $TMP ] ; then
+	    [ $RETVAL = 0 ] || echo "Starting automounter failed"
+	else
+	    echo "No Mountpoints Defined"
+	fi
+	rm -f $TMP
+	echo
+	;;
+  stop)
+	killall -USR2 $DAEMON 2> /dev/null
+	count=0
+	while [ -n "`pidof $DAEMON`" -a $count -lt 10 ] ; do
+	   killall -USR2 $DAEMON 2> /dev/null
+	   RETVAL=$?
+	   [ $RETVAL = 0 -a -z "`pidof $DAEMON`" ] || sleep 3
+	   count=`expr $count + 1`
+	done
+	umount -a -f -t autofs
+	echo
+	;;
+  restart)
+	generic stop
+	generic start
+	;;
+  status)
+	status
+	;;
+  *)
+	echo $"Usage: $0 {start|stop|restart|status}"
+esac
+}
+
 RETVAL=0
 if [ $system = debian ]; then
 	debian "$@"
 elif [ $system = redhat ]; then
 	redhat "$@"
+elif [ $system = generic ]; then
+	generic "$@"
 fi
 
 exit $RETVAL

_______________________________________________
autofs mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/autofs