# rpcbind - RPC portmapper replacement

# rpcbind is a server that converts RPC (Remote Procedure Call) program
# numbers into DARPA protocol port numbers. It must be running in order
# to make RPC calls.

# Note that this is called portmap rather than rpcbind because other
# packages rely on the portmap name.

description	"RPC portmapper replacement"
author		"Colin Watson <cjwatson@ubuntu.com>"

start on start-rpcbind
stop on unmounted-remote-filesystems

# ON_BOOT is set on start-rpcbind in rpcbind-boot.conf
# Used by statd which must not start on started portmap during boot
export ON_BOOT
env ON_BOOT=

expect fork
respawn

pre-start exec mkdir -p /run/rpcbind

script
	OPTIONS="-w"
	if [ -f /etc/default/rpcbind ]; then
		. /etc/default/rpcbind
	elif [ -f /etc/rpcbind.conf ]; then
		. /etc/rpcbind.conf
	fi
	exec rpcbind $OPTIONS
end script

# For compatibility with older upstart jobs in Ubuntu
post-start exec initctl emit --no-wait started JOB=portmap ON_BOOT=$ON_BOOT
pre-stop exec initctl emit --no-wait stopping JOB=portmap
