Rev 3 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/bin/bash## rc file for automount using a Sun-style "master map".## chkconfig: 345 28 72# processname: /usr/sbin/automount# config: /etc/auto.master# description: Automounts filesystems on demand#### BEGIN INIT INFO# Provides: autofs# Required-Start: $network ypbind# Required-Stop: $network ypbind# Default-Start: 3 4 5# Default-Stop: 0 1 2 6# Short-Description: Automounts filesystems on demand# Description: Automounts filesystems on demand### END INIT INFO## Location of the automount daemon and the init directory#DAEMON=/usr/sbin/automountprog=`basename $DAEMON`MODULE="autofs4"DEVICE="autofs"initdir=/etc/init.dconfdir=/etc/sysconfigtest -e $DAEMON || exit 0if [ -r $initdir/functions ]; then. $initdir/functionsfiPATH=/sbin:/usr/sbin:/bin:/usr/binexport PATH## load customized configuation settings#if [ -r $confdir/autofs ]; then. $confdir/autofsfifunction start() {# Make sure autofs4 module is loadedif ! grep -q autofs /proc/filesystemsthenecho -n "Loading $MODULE: "# Try load the autofs4 module fail if we can'tmodprobe $MODULE >/dev/null 2>&1RETVAL=$?if [ $RETVAL -eq 1 ]thenfailure "Load $MODULE"echoreturn $RETVALelsesuccess "Load $MODULE"echofielif ([ -f /proc/modules ] && lsmod) | grep -q autofs[^4]thenRETVAL=1failure "Load $MODULE"echoreturn $RETVALfi# Check misc deviceif [ -n "$USE_MISC_DEVICE" -a "x$USE_MISC_DEVICE" = "xyes" ]; thensleep 1if [ -e "/proc/misc" ]; thenMINOR=`awk "/$DEVICE/ {print \\$1}" /proc/misc`if [ -n "$MINOR" -a ! -c "/dev/$DEVICE" ]; thenmknod -m 0600 /dev/$DEVICE c 10 $MINORfifiif [ -x /sbin/restorecon -a -c /dev/$DEVICE ]; then/sbin/restorecon /dev/$DEVICEfielseif [ -c /dev/$DEVICE ]; thenrm /dev/$DEVICEfifiecho -n $"Starting $prog: "$prog $OPTIONS --pid-file /var/run/autofs.pidRETVAL=$?if [ $RETVAL -eq 0 ] ; thensuccess "$prog startup"elsefailure "$prog startup"fiif [ $RETVAL -eq 0 ]; thentouch /var/lock/subsys/autofselseRETVAL=1fiechoreturn $RETVAL}function stop() {echo -n $"Stopping $prog: "count=0while [ -n "`pidof $prog`" -a $count -lt 15 ] ; dokillproc $prog -TERM >& /dev/nullRETVAL=$?[ $RETVAL = 0 -a -z "`pidof $prog`" ] || sleep 3count=`expr $count + 1`doneif [ $RETVAL -eq 0 ]; thenrm -f /var/lock/subsys/autofselseRETVAL=1fiif [ -n "`pidof $prog`" ] ; thenfailure "$prog shutdown"elsesuccess "$prog shutdown"fiechoreturn $RETVAL}function restart() {status autofs > /dev/null 2>&1if [ $? -eq 0 ]; thenstopif [ -n "`pidof $prog`" ]; then# If we failed to stop, try at least one more time# after waiting a little whilesleep 20stopauto_pid=`pidof $prog`if [ -n "$auto_pid" ]; thenkill -9 $auto_pidfififistart}function reload() {if [ ! -f /var/lock/subsys/autofs ]; thenecho $"$prog not running"RETVAL=1return $RETVALfipid=`pidof $prog`if [ -z $pid ]; thenecho $"$prog not running"RETVAL=1elsekill -HUP $pid 2> /dev/nullecho $"Reloading maps"RETVAL=0fireturn $RETVAL}function usage_message() {echo $"Usage: $0 {start|forcestart|stop|status|restart|force-reload|forcerestart|reload|condrestart|try-restart|usage}"}RETVAL=0# allow non-root users to read status / usagecase "$1" instatus)status -p /var/run/autofs.pid -l autofs $progexit $?;;;usage)usage_messageexit 0;;;esac# Only the root user may change the service statusif [ `id -u` -ne 0 ]; thenecho "insufficient privilege to change service status"exit 4ficase "$1" instart)start;;forcestart)OPTIONS="$OPTIONS --force"start;;stop)stop;;restart|force-reload)restart;;forcerestart)OPTIONS="$OPTIONS --force"restart;;reload)reload;;condrestart|try-restart)if [ -f /var/lock/subsys/autofs ]; thenrestartfi;;*)usage_messageexit 2;;esacexit $?