3 # init.d script with LSB support.
5 # Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
6 # Copyright (c) 2008 Axel Beckert <abe@deuxchevaux.org>
8 # This is free software; you may redistribute it and/or modify
9 # it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; either version 2,
11 # or (at your option) any later version.
13 # This is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License with
19 # the Debian operating system, in /usr/share/common-licenses/GPL; if
20 # not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA 02111-1307 USA
24 # Provides: busybox-klogd klogd
25 # Required-Start: $remote_fs
26 # Required-Stop: $remote_fs
27 # Should-Start: syslogd
29 # Default-Start: 2 3 4 5
31 # Short-Description: Starts klogd
32 # Description: Starts the busybox klogd
35 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
37 NAME=klogd # Introduce the short server's name here
38 DAEMON=/sbin/$NAME # Introduce the server's location here
39 DESC="busybox' $NAME implementation" # Introduce a short description here
43 test -x $DAEMON || exit 0
45 . /lib/lsb/init-functions
47 # Default options, these can be overriden by the information
48 # at /etc/default/$NAME
49 KLOG_OPTS="" # Additional options given to the server
51 DIETIME=10 # Time to wait for the server to die, in seconds
52 # If this value is set too low you might not
53 # let some servers to die gracefully and
54 # 'restart' will not work
56 STARTTIME=2 # Time to wait for the server to start, in seconds
57 # If this value is set each time the server is
58 # started (on start or restart) the script will
59 # stall to try to determine if it is running
60 # If it is not set and the server takes time
61 # to setup a pid file the log message might
62 # be a false positive (says it did not start
63 # when it actually did)
65 # Include defaults if available
66 if [ -f /etc/default/busybox-syslogd ] ; then
67 . /etc/default/busybox-syslogd
73 start-stop-daemon --start --verbose --name $NAME \
74 --exec $DAEMON -- $NEEDED_OPTS $KLOG_OPTS
78 start-stop-daemon --stop --verbose --name $NAME
82 cut -d ' ' -f 1-2 /proc/[0-9]*/stat 2> /dev/null | grep -F "($NAME)"
87 log_daemon_msg "Starting $DESC " "$NAME"
88 # Check if it's running first
90 log_progress_msg "apparently already running"
94 if start_server ; then
95 # NOTE: Some servers might die some time after they start,
96 # this code will detect this issue if STARTTIME is set
97 # to a reasonable value
98 [ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time
100 # It's ok, the server started and is running
103 # It is not running after we did start
107 # Either we could not start it
113 log_daemon_msg "Stopping $DESC" "$NAME"
115 # Only stop the server if we see it running
117 stop_server || errcode=$?
120 # If it's not running don't do anything
121 log_progress_msg "apparently not running"
127 restart|force-reload)
128 log_daemon_msg "Restarting $DESC" "$NAME"
130 stop_server || errcode=$?
131 # Wait some sensible amount, some server need this
132 [ -n "$DIETIME" ] && sleep $DIETIME
133 start_server || errcode=$?
134 [ -n "$STARTTIME" ] && sleep $STARTTIME
135 running || errcode=$?
140 log_daemon_msg "Checking status of $DESC" "$NAME"
142 log_progress_msg "running"
145 log_progress_msg "apparently not running"
153 echo "Usage: $N {start|stop|restart|force-reload|status}" >&2