1#! /bin/sh
2### BEGIN INIT INFO
3# Provides:             krb5-kdc
4# Required-Start:       $local_fs $remote_fs $network $syslog
5# Required-Stop:        $local_fs $remote_fs $network $syslog
6# X-Start-Before: $x-display-manager
7# Default-Start:        2 3 4 5
8# Default-Stop:         0 1 6
9# Short-Description:    MIT Kerberos KDC
10# Description:          Starts, stops, or restarts the MIT Kerberos KDC.  This
11#                       daemon responds to ticket requests from Kerberos
12#                       clients.
13### END INIT INFO
14
15# Author: Sam Hartman <hartmans@mit.edu>
16# Author: Russ Allbery <rra@debian.org>
17#
18# Based on the /etc/init.d/skeleton template as found in initscripts version
19# 2.86.ds1-15.
20
21# June, 2012: Adopted for yocto <amy.fong@windriver.com>
22
23PATH=/usr/sbin:/usr/bin:/sbin:/bin
24DESC="Kerberos KDC"
25NAME=krb5kdc
26DAEMON=/usr/sbin/$NAME
27DAEMON_ARGS=""
28SCRIPTNAME=/etc/init.d/krb5-kdc
29
30# Exit if the package is not installed.
31[ -x "$DAEMON" ] || exit 0
32
33# Read configuration if it is present.
34[ -r /etc/default/krb5-kdc ] && . /etc/default/krb5-kdc
35
36# Get the setting of VERBOSE and other rcS variables.
37[ -f /etc/default/rcS ] && . /etc/default/rcS
38
39. /etc/init.d/functions
40
41# Return
42#   0 if daemon has been started
43#   1 if daemon was already running
44#   2 if daemon could not be started
45do_start_kdc()
46{
47    start-stop-daemon --start --quiet --startas $DAEMON --name $NAME --test \
48        > /dev/null || return 1
49    start-stop-daemon --start --quiet --startas $DAEMON --name $NAME \
50        -- $DAEMON_ARGS || return 2
51}
52
53
54# Return
55#   0 if daemon has been stopped
56#   1 if daemon was already stopped
57#   2 if daemon could not be stopped
58#   other if a failure occurred
59do_stop_kdc()
60{
61    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --name $NAME
62    RETVAL="$?"
63    [ "$RETVAL" = 2 ] && return 2
64    return "$RETVAL"
65}
66
67
68case "$1" in
69  start)
70    [ "$VERBOSE" != no ] && echo "Starting $DESC" "$NAME"
71    do_start_kdc
72    case "$?" in
73      0|1)
74            [ "$VERBOSE" != no ] && echo 0
75        ;;
76      2)
77        [ "$VERBOSE" != no ] && echo 1
78        ;;
79    esac
80    ;;
81
82  stop)
83    [ "$VERBOSE" != no ] && echo "Stopping $DESC" "$NAME"
84    do_stop_kdc
85    case "$?" in
86      0|1)
87        [ "$VERBOSE" != no ] && echo "krb524d"
88        ;;
89      2)
90        [ "$VERBOSE" != no ] && echo 1
91        ;;
92    esac
93    ;;
94
95  restart|force-reload)
96    echo "Restarting $DESC" "$NAME"
97    do_stop_kdc
98    case "$?" in
99      0|1)
100        do_start_kdc
101        case "$?" in
102          0)
103	  echo 0
104	  ;;
105          1|2)
106            echo 1
107            ;;
108        esac
109        ;;
110      *)
111        echo 1
112        ;;
113    esac
114    ;;
115
116  status)
117    pidofproc "$DAEMON" >/dev/null
118    status=$?
119    if [ $status -eq 0 ]; then
120        echo "$NAME is running."
121    else
122        echo "$NAME is not running."
123    fi
124    exit $status
125    ;;
126
127  *)
128    echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
129    exit 3
130    ;;
131esac
132
133:
134