#! /bin/bash # # portmap Start/Stop RPC portmapper # # chkconfig: 345 11 89 # description: The portmapper manages RPC connections, which are used by \ # protocols such as NFS and NIS. The portmap server must be \ # running on machines which act as servers for protocols which \ # make use of the RPC mechanism. # processname: portmap # Source function library. . /etc/rc.d/init.d/functions # Get config. . /etc/sysconfig/network check_network() { route -n | grep -q ^0\.0\.0\.0 } # Check that networking is up. if [ ${NETWORKING} = "no" ] then exit 0 fi [ -f /sbin/portmap ] || exit 0 MAX=5 TIMEOUT=5 # Check for and source configuration file otherwise set defaults [ -f /etc/sysconfig/portmap ] && . /etc/sysconfig/portmap if [ -n "${PORTMAP_IP_OR_HOSTNAME}" ]; then PORTMAPARG="-i ${PORTMAP_IP_OR_HOSTNAME}" else PORTMAPARG="" fi RETVAL=0 # See how we were called. case "$1" in start) num=0 echo -n "Starting portmapper: " while [ -n "${PORTMAP_IP_OR_HOSTNAME}" ] && ! check_network && [ $num -lt $MAX ]; do sleep $TIMEOUT num=$(($num + 1)) done daemon portmap ${PORTMAPARG} RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/portmap ;; stop) echo -n "Stopping portmap services: " killproc portmap RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/portmap ;; status) status portmap RETVAL=$? ;; restart|reload) $0 stop $0 start RETVAL=$? ;; *) echo "Usage: portmap {start|stop|status|restart|reload}" exit 1 esac exit $RETVAL