PageRenderTime 60ms CodeModel.GetById 56ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/init.d/openbsd-inetd

http://github.com/brinkman83/bashrc
Shell | 86 lines | 65 code | 10 blank | 11 comment | 7 complexity | d6c5a849e04ac6def196c326d74faf1b MD5 | raw file
 1#!/bin/sh -e
 2### BEGIN INIT INFO
 3# Provides:          openbsd-inetd
 4# Required-Start:    $local_fs $remote_fs
 5# Required-Stop:     $local_fs $remote_fs
 6# Should-Start:      $syslog
 7# Should-Stop:       $syslog
 8# Default-Start:     2 3 4 5
 9# Default-Stop:      0 1 6
10# Short-Description: Start or stop the inetd daemon.
11### END INIT INFO
12
13DAEMON=/usr/sbin/inetd
14
15[ -x $DAEMON -a -e /etc/inetd.conf ] || exit 0
16
17[ -e /etc/default/openbsd-inetd ] && . /etc/default/openbsd-inetd
18
19. /lib/lsb/init-functions
20
21checkportmap () {
22  if ! grep -v -s "^ *#" /etc/inetd.conf | grep -q -s 'rpc/'; then
23    return 0
24  fi
25
26  if [ ! -x /usr/bin/rpcinfo ]; then
27    log_action_msg "WARNING: rpcinfo not available - RPC services may be unavailable!"
28    log_action_msg "         (Commenting out the rpc services in inetd.conf will"
29    log_action_msg "         disable this message)"
30  elif ! /usr/bin/rpcinfo -u localhost portmapper >/dev/null 2>&1; then
31    log_action_msg "WARNING: portmapper inactive - RPC services unavailable!"
32    log_action_msg "         (Commenting out the rpc services in inetd.conf will"
33    log_action_msg "         disable this message)"
34  fi
35} 
36
37checknoservices () {
38    if ! grep -q "^[[:alnum:]/]" /etc/inetd.conf; then
39	log_action_msg "Not starting internet superserver: no services enabled"
40	exit 0
41    fi
42}
43
44case "$1" in
45    start)
46	checknoservices
47        checkportmap
48	log_daemon_msg "Starting internet superserver" "inetd"
49	start-stop-daemon --start --quiet --pidfile /var/run/inetd.pid \
50	    --exec $DAEMON -- $OPTIONS
51	log_end_msg 0
52	;;
53    stop)
54	log_daemon_msg "Stopping internet superserver" "inetd"
55	start-stop-daemon --stop --quiet --pidfile /var/run/inetd.pid \
56	    --oknodo
57	log_end_msg 0
58	;;
59    reload|force-reload)
60	log_daemon_msg "Reloading internet superserver" "inetd"
61	start-stop-daemon --stop --quiet --pidfile /var/run/inetd.pid \
62	    --oknodo --signal 1
63	log_end_msg 0
64	;;
65    restart)
66	checkportmap
67	log_daemon_msg "Restarting internet superserver" "inetd"
68	start-stop-daemon --stop --quiet --pidfile /var/run/inetd.pid \
69	    --oknodo
70	checknoservices
71	sleep 1
72	start-stop-daemon --start --quiet --pidfile /var/run/inetd.pid \
73	    --exec $DAEMON -- $OPTIONS
74	log_end_msg 0
75	;;
76    status)
77	status_of_proc -p /var/run/inetd.pid $DAEMON inetd && exit 0 || exit $?
78	;;
79    *)
80	echo "Usage: /etc/init.d/openbsd-inetd {start|stop|reload|force-reload|restart|status}"
81	exit 2
82	;;
83esac
84
85exit 0
86