Richard Tollerton 8076ab295a sysvinit: bootlogd: Don't run savelog if it's not installed
bootlogd's default log rotation code on stop requires `savelog`, which
is in debianutils, which may not be installed.  If it's not installed,
don't try to perform the log rotation.

That is: in the affected code block, `savelog` is what is responsible
for creating "boot.0".  When `savelog` doesn't exist, an error message
gets printed on bootup to the effect of "mv: can't find boot.0".

(From OE-Core rev: 5c22973e1bf76615bcf57984ac7a30cf7d0766df)

Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
Signed-off-by: Ben Shelton <ben.shelton@ni.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-07-23 21:59:17 +01:00

99 lines
2.0 KiB
Bash
Executable File

#! /bin/sh
### BEGIN INIT INFO
# Provides: bootlogd
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop: 2 3 4 5
# Short-Description: One of the first scripts to be executed. Starts or stops
# the bootlogd log program. If this script is called as
# "stop-bootlogd", it will stop the daemon instead of
# starting it even when called with the "start" argument.
#
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/sbin/bootlogd
NAME=bootlogd
DESC="Bootlog daemon"
# source function library
. /etc/init.d/functions
test -f $DAEMON || exit 0
[ -r /etc/default/bootlogd ] && . /etc/default/bootlogd
## set -e # not needed
case "$BOOTLOGD_ENABLE" in
[Nn]*)
exit 0
;;
esac
STOPPER=
ACTION="$1"
case "$0" in
*stop-bootlog*)
STOPPER=Y
if [ "$ACTION" = start ]
then
ACTION=stop
fi
;;
esac
case "$ACTION" in
start)
[ "${VERBOSE}" != "no" ] && echo -n "Starting $DESC: "
if [ -d /proc/1/. ]
then
umask 027
start-stop-daemon --start --quiet \
--exec $DAEMON -- -r -c
else
$DAEMON -r -c
fi
[ "${VERBOSE}" != "no" ] && echo "$NAME."
;;
stop)
# stop may get called during bootup, so let it honor
# rcS VERBOSE setting
[ "${VERBOSE}" != "no" ] && echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --exec $DAEMON
if [ "$STOPPER" ] && [ "$(which savelog 2>/dev/null)" ] && \
[ -f /var/log/boot ] && [ -f /var/log/boot~ ]
then
cd /var/log
chgrp adm boot
savelog -p -c 5 boot > /dev/null 2>&1
mv boot.0 boot
mv boot~ boot.0
fi
[ "${VERBOSE}" != "no" ] && echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --exec $DAEMON
echo "$NAME."
;;
status)
status $DAEMON
exit $?
;;
*)
N=${0##*/}
N=${N#[SK]??}
echo "Usage: $N {start|stop|status|restart|force-reload}" >&2
exit 1
;;
esac
exit 0