Bugzilla – Attachment 68638 Details for
Bug 141182
--ghost does not work in auto.master
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
autofs start script
autofs (text/plain), 8.33 KB, created by
Chris L Mason
on 2006-02-15 14:43:52 UTC
(
hide
)
Description:
autofs start script
Filename:
MIME Type:
Creator:
Chris L Mason
Created:
2006-02-15 14:43:52 UTC
Size:
8.33 KB
patch
obsolete
>#!/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 ># > >### BEGIN INIT INFO ># Provides: autofs ># Required-Start: $network $syslog $remote_fs ># X-UnitedLinux-Should-Start: ypbind keyserv ># Required-Stop: ># X-UnitedLinux-Should-Stop: ># Default-Start: 3 5 ># Default-Stop: ># Description: Start the autofs daemon for automatic mounting of filesystems. >### END INIT INFO > ># ># Location of the automount daemon and the init directory ># >DAEMON=/usr/sbin/automount > >. /etc/rc.status >. /etc/sysconfig/autofs > ># check if program is installed >test -x $DAEMON || exit 5 > >PATH=/sbin:/usr/sbin:/bin:/usr/bin >export PATH > ># ># We can add local options here ># e.g. localoptions='rsize=8192,wsize=8192' ># >localoptions='' > ># ># Daemon options ># e.g. --timeout 60 ># >daemonoptions=$AUTOFS_OPTIONS > ># normal behavior of ps, please. >unset PS_PERSONALITY >unset CMD_ENV > ># ># Check for all maps that are to be loaded ># >function getschemes() >{ > grep ^automount: /etc/nsswitch.conf | sed -e 's/^.*://' -e 's/\[.*\]/ /g' >} >function catnismap() >{ > if [ -z "$1" ] ; then > map="auto_master" > else > map="$1" > fi > /usr/bin/ypcat -k "$map" 2> /dev/null | sed -e '/^#/d' -e '/^$/d' >} >function getfilemounts() >{ > if [ -f /etc/auto.master ] ; then > cat /etc/auto.master | grep -v '^\+' | sed -e '/^#/d' -e '/^$/d' > for nismap in `cat /etc/auto.master | grep '^\+' | sed -e '/^#/d' -e '/^$/d'`; do > catnismap `echo "$nismap" | sed -e 's/^\+//'` > done > fi >} >function getnismounts() >{ > catnismap auto.master >} >function getldapmounts() >{ > /usr/lib/autofs/autofs-ldap-auto-master 2> /dev/null >} >function getrawmounts() >{ > for scheme in `getschemes` ; do > case "$scheme" in > files) > if [ -z "$filescheme" ] ; then > getfilemounts > filescheme=1 > export filescheme > fi > ;; > nis*) > if [ -z "$nisscheme" ] ; then > getnismounts > nisscheme=1 > export nisscheme > fi > ;; > ldap*) > if [ -z "$ldapscheme" ] ; then > getldapmounts > ldapscheme=1 > export ldapscheme > fi > ;; > esac > done >} > > ># ># 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() >{ > knownmaps=" " > getrawmounts | ( > while read dir map options > do > # These checks screen out duplicates and skip over directories > # where the map is '-'. > # We can't do empty or direct host maps, so don't bother trying. > if [ ! -z "$map" -a "$map" = "-hosts" ] ; then > continue > fi > if [ ! -z "$dir" -a ! -z "$map" \ > -a x`echo "$map" | cut -c1` != 'x-' \ > -a "`echo "$knownmaps" | grep $dir/`" = "" ] > then > # If the options include a -t or --timeout parameter, then > # pull those particular options out. > : echo DAEMONOPTIONS OPTIONS $daemonoptions $options > startupoptions= > if echo $options | grep -q -- '-t' ; then > startupoptions="--timeout $(echo $daemonoptions $options | \ > sed 's/.*--*t\(imeout\)*[ \t=]*\([0-9][0-9]*\).*$/\2/g')" > fi > # Other option flags are intended for maps. > mapoptions="$(echo "$daemonoptions $options" |\ > sed 's/--*t\(imeout\)*[ \t=]*\([0-9][0-9]*\)//g')" > # Break up the maptype and map, if the map type is specified > maptype=`echo $map | cut -f1 -d:` > # Handle degenerate map specifiers > if [ "$maptype" = "$map" ] ; then > if [ -x "$map" ]; then > maptype=program > elif [ -x "/etc/$map" ]; then > maptype=program > map=`echo /etc/$map | sed 's^//^/^g'` > elif [ -f "$map" ]; then > maptype=file > elif [ -f "/etc/$map" ]; then > maptype=file > map=`echo /etc/$map | sed 's^//^/^g'` > elif [ "$map" = "hesiod" -o "$map" = "userhome" ] ; then > maptype=$map > map= > elif [ "$map" = "multi" ] ; then > maptype=$map > map= > else > maptype=yp > map=`basename $map | sed -e s/^auto_home/auto.home/ -e s/^auto_mnt/auto.mnt/` > fi > fi > map=`echo $map | cut -f2- -d:` > > : echo STARTUPOPTIONS $startupoptions > : echo DIR $dir > : echo MAPTYPE $maptype > : echo MAP $map > : echo MAPOPTIONS $mapoptions > : echo LOCALOPTIONS $localoptions > > echo "$DAEMON $startupoptions $dir $maptype $map $mapoptions $localoptions" | sed -e 's/ / /g' -e 's/ / /g' > > : echo ------------------------ > fi > knownmaps=" $dir/ $knownmaps" > done > ) >} ># ># Status lister. ># >function status() >{ > echo "Configured Mount Points:" > echo "------------------------" > getmounts > echo "" > echo "Active Mount Points:" > echo "--------------------" > ps -w -C automount -o command= | grep "^$DAEMON " >} > > ># ># Return true if at least one pid is alive. ># >function alive() >{ > if [ -z "$*" ]; then > return 1 > fi > for i in $*; do > if kill -0 $i 2> /dev/null; then > return 0 > fi > done > > return 1 >} > > ># ># Kill all processes using automounted paths. ># >function kill_all_using_me() >{ > for SIG in -TERM -KILL ; do > while read mount_type path foobar ; do > case "$mount_type" in > automount*) > ( > kill $SIG `echo $(fuser -m $path/* | cut -d : -f 2- | sed 's#[^0-9 ]##g' )` > ) &> /dev/null > ;; > esac > done < /proc/mounts > if [ $SIG == -TERM ] ; then > sleep 2 > fi > done >} > > ># ># See how we were called. ># > >return=0 > ># ># avoid duplicate mounts ># > >case "$1" in > start) > # Check if the automounter is already running? > echo -n "Starting service automounter" > pids=$(/sbin/pidof $DAEMON) > if [ ! -f /var/lock/subsys/autofs -o -z "$pids" ]; then > rm -f /var/lock/subsys/autofs > if [ -z "`getmounts`" ]; then > schemes=`getschemes` > if [ "$schemes" ]; then > echo -n " (\"$schemes\" does not provide any mounts)" > else > echo -n " (no mounts configured)" > fi > rc_status -s > # service is not configured > rc_failed 6 > rc_exit > else > getmounts | sh || return=1 > touch /var/lock/subsys/autofs > fi > else > echo -n " (already running)" > fi > rc_status -v > ;; > stop) > echo -n "Shutting down service automount" > if checkproc $DAEMON ; then > # kill all automounts in runlevel 0 and 6 to prevent busy > case $RUNLEVEL in > 0|6|s|S) > kill_all_using_me > ;; > esac > # now kill daemons > pids=$(/sbin/pidof $DAEMON) > killproc -TERM $DAEMON || return=1 > if [ $return == 0 ] ; then > echo -e "$rc_done" > else > echo -e "$rc_failed" > fi > count=1 > while alive $pids; do > sleep 5 > count=$(expr $count + 1) > if [ $count -gt 5 ]; then > echo "Giving up on automounter" > break; > fi > echo "Automounter not stopped yet: retrying... (attempt $count)" > done > if [ $count -gt 1 -a $count -le 10 ]; then > echo "Automounter stopped" > fi > else > return=0 > echo -e "$rc_done" > fi > rm -f /var/lock/subsys/autofs > ;; > restart|force-reload) > $0 stop > $0 start > return=$? > ;; > reload) > if [ ! -f /var/lock/subsys/autofs ]; then > echo "Automounter not running" > exit 1 > fi > echo "Checking for changes to /etc/auto.master ..." > TMP1=`mktemp /tmp/autofs.XXXXXX` || { echo "could not make temp file" >& 2; exit 1; } > TMP2=`mktemp /tmp/autofs.XXXXXX` || { echo "could not make temp file" >& 2; exit 1; } > getmounts >$TMP1 > ps -w -C automount -o pid=,command= | grep " $DAEMON " | ( > while read pid command; do > echo "$command" >>$TMP2 > if ! grep -q "^$command" $TMP1; then > ( > while kill -USR2 $pid; do > sleep 3 > done > ) &> /dev/null > echo "Stop $command" > fi > done > ) > ( while read x; do > if ! grep -q "^$x" $TMP2; then > $x > echo "Start $x" > fi > done ) < $TMP1 > rm -f $TMP1 $TMP2 > ;; > status) > echo -n "Checking for service autofs: " > checkproc $DAEMON && return=0 || return=3 > if [ $return == 0 ] ; then > echo -e "$rc_running" > else > echo -e "$rc_unused" > fi > status > ;; > expire) > echo -n "Trigger expire for autofs: " > if checkproc $DAEMON ; then > # send HUP to daemons > killproc -HUP $DAEMON || return=1 > fi > if [ $return == 0 ] ; then > echo -e "$rc_done" > else > echo -e "$rc_failed" > fi > ;; > *) > echo "Usage: $initdir/autofs {start|stop|restart|reload|force-reload|status|expire}" > exit 3 >esac > >exit $return >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
Attachments on
bug 141182
:
61861
|
61862
| 68638