Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | # |
| 3 | # Author: Jaakko Niemi <liiwi@iki.fi> |
| 4 | # Modified from skeleton file in sarge |
| 5 | |
| 6 | ### BEGIN INIT INFO |
| 7 | # Provides: tftp-hpa |
| 8 | # Required-Start: $local_fs $remote_fs $syslog $network |
| 9 | # Required-Stop: $local_fs $remote_fs $syslog $network |
| 10 | # Default-Start: 2 3 4 5 |
| 11 | # Default-Stop: 1 |
| 12 | # Short-Description: HPA's tftp client |
| 13 | # Description: tftp server to allow booting clients which support |
| 14 | # the PXE protocol. |
| 15 | ### END INIT INFO |
| 16 | |
| 17 | set -e |
| 18 | |
| 19 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin |
| 20 | DESC="HPA's tftpd" |
| 21 | NAME=in.tftpd-hpa |
| 22 | SCRIPTNAME=/etc/init.d/tftpd-hpa |
| 23 | |
| 24 | # Read config file if it is present. |
| 25 | if [ -r /etc/default/tftpd-hpa ] |
| 26 | then |
| 27 | . /etc/default/tftpd-hpa |
| 28 | fi |
| 29 | |
| 30 | DAEMON=/usr/sbin/$NAME |
| 31 | PIDFILE=/var/run/$NAME.pid |
| 32 | |
| 33 | # Gracefully exit if the package has been removed. |
| 34 | test -x $DAEMON || exit 0 |
| 35 | |
| 36 | if [ "$RUN_DAEMON" != "yes" ] ; then |
| 37 | echo "tftpd-hpa disabled in /etc/default/tftpd-hpa" |
| 38 | exit 0 |
| 39 | fi |
| 40 | |
| 41 | # |
| 42 | # Function that starts the daemon/service. |
| 43 | # |
| 44 | d_start() { |
| 45 | start-stop-daemon --start --quiet --exec $DAEMON -- $OPTIONS |
| 46 | } |
| 47 | |
| 48 | # |
| 49 | # Function that stops the daemon/service. |
| 50 | # |
| 51 | d_stop() { |
| 52 | start-stop-daemon --stop --quiet --name $NAME |
| 53 | } |
| 54 | |
| 55 | # |
| 56 | # Function that sends a SIGHUP to the daemon/service. |
| 57 | # |
| 58 | d_reload() { |
| 59 | start-stop-daemon --stop --quiet --name $NAME --signal 1 |
| 60 | } |
| 61 | |
| 62 | case "$1" in |
| 63 | start) |
| 64 | echo "Starting $DESC: $NAME" |
| 65 | d_start |
| 66 | echo "." |
| 67 | ;; |
| 68 | stop) |
| 69 | echo "Stopping $DESC: $NAME" |
| 70 | d_stop |
| 71 | echo "." |
| 72 | ;; |
| 73 | #reload) |
| 74 | # |
| 75 | # If the daemon can reload its configuration without |
| 76 | # restarting (for example, when it is sent a SIGHUP), |
| 77 | # then implement that here. |
| 78 | # |
| 79 | # If the daemon responds to changes in its config file |
| 80 | # directly anyway, make this an "exit 0". |
| 81 | # |
| 82 | # echo -n "Reloading $DESC configuration..." |
| 83 | # d_reload |
| 84 | # echo "done." |
| 85 | #;; |
| 86 | restart|force-reload) |
| 87 | # |
| 88 | # If the "reload" option is implemented, move the "force-reload" |
| 89 | # option to the "reload" entry above. If not, "force-reload" is |
| 90 | # just the same as "restart". |
| 91 | # |
| 92 | echo "Restarting $DESC: $NAME" |
| 93 | d_stop |
| 94 | sleep 1 |
| 95 | d_start |
| 96 | echo "." |
| 97 | ;; |
| 98 | *) |
| 99 | # echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 |
| 100 | echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 |
| 101 | exit 1 |
| 102 | ;; |
| 103 | esac |
| 104 | |
| 105 | exit 0 |