blob: 621aa171ae6fddf8e09cdae19ee5e2b6cca371d4 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/bin/sh
2#
3### BEGIN INIT INFO
4# Provides: portmap
5# Required-Start: $network
6# Required-Stop: $network
7# Default-Start: S 2 3 4 5
8# Default-Stop: 0 1 6
9# Short-Description: The RPC portmapper
10# Description: Portmap is a server that converts RPC (Remote
11# Procedure Call) program numbers into DARPA
12# protocol port numbers. It must be running in
13# order to make RPC calls. Services that use
14# RPC include NFS and NIS.
15### END INIT INFO
16
17test -f /sbin/portmap || exit 0
18
19case "$1" in
20 start)
21 echo "Starting portmap daemon..."
22 start-stop-daemon --start --quiet --exec /sbin/portmap
23
24 if [ -f /var/run/portmap.upgrade-state ]; then
25 echo "Restoring old RPC service information..."
26 sleep 1 # needs a short pause or pmap_set won't work. :(
27 pmap_set </var/run/portmap.upgrade-state
28 rm -f /var/run/portmap.upgrade-state
29 echo "done."
30 fi
31
32 ;;
33 stop)
34 echo "Stopping portmap daemon..."
35 start-stop-daemon --stop --quiet --exec /sbin/portmap
36 ;;
37 reload)
38 ;;
39 force-reload)
40 $0 restart
41 ;;
42 restart)
43 # pmap_dump and pmap_set may be in a different package and not installed...
44 if [ -f /sbin/pmap_dump -a -f /sbin/pmap_set ]; then
45 do_state=1
46 else
47 do_state=0
48 fi
49 [ $do_state -eq 1 ] && pmap_dump >/var/run/portmap.state
50 $0 stop
51 $0 start
52 if [ $do_state -eq 1 ]; then
53 if [ ! -f /var/run/portmap.upgrade-state ]; then
54 sleep 1
55 pmap_set </var/run/portmap.state
56 fi
57 rm -f /var/run/portmap.state
58 fi
59 ;;
60 *)
61 echo "Usage: /etc/init.d/portmap {start|stop|reload|restart}"
62 exit 1
63 ;;
64esac
65
66exit 0
67