1#! /bin/sh 2### BEGIN INIT INFO 3# Provides: bootlogd 4# Required-Start: 5# Required-Stop: 6# Default-Start: S 7# Default-Stop: 2 3 4 5 8# Short-Description: One of the first scripts to be executed. Starts or stops 9# the bootlogd log program. If this script is called as 10# "stop-bootlogd", it will stop the daemon instead of 11# starting it even when called with the "start" argument. 12# 13### END INIT INFO 14 15PATH=/sbin:/bin:/usr/sbin:/usr/bin 16DAEMON=/sbin/bootlogd 17NAME=bootlogd 18DESC="Bootlog daemon" 19 20# source function library 21. /etc/init.d/functions 22 23test -f $DAEMON || exit 0 24 25[ -r /etc/default/bootlogd ] && . /etc/default/bootlogd 26 27## set -e # not needed 28 29case "$BOOTLOGD_ENABLE" in 30 [Nn]*) 31 exit 0 32 ;; 33esac 34 35STOPPER= 36ACTION="$1" 37case "$0" in 38 *stop-bootlog*) 39 STOPPER=Y 40 if [ "$ACTION" = start ] 41 then 42 ACTION=stop 43 fi 44 ;; 45esac 46 47case "$ACTION" in 48 start) 49 [ "${VERBOSE}" != "no" ] && echo -n "Starting $DESC: " 50 if [ -d /proc/1/. ] 51 then 52 umask 027 53 start-stop-daemon --start --quiet \ 54 --exec $DAEMON -- -r -c 55 else 56 $DAEMON -r -c 57 fi 58 [ "${VERBOSE}" != "no" ] && echo "$NAME." 59 ;; 60 stop) 61 # stop may get called during bootup, so let it honor 62 # rcS VERBOSE setting 63 [ "${VERBOSE}" != "no" ] && echo -n "Stopping $DESC: " 64 start-stop-daemon --stop --quiet --exec $DAEMON 65 66 if [ "$STOPPER" ] && [ "$(which savelog 2>/dev/null)" ] && \ 67 [ -f /var/log/boot ] && [ -f /var/log/boot~ ] 68 then 69 cd /var/log 70 chgrp adm boot 71 savelog -p -c 5 boot > /dev/null 2>&1 72 mv boot.0 boot 73 mv boot~ boot.0 74 fi 75 76 [ "${VERBOSE}" != "no" ] && echo "$NAME." 77 ;; 78 restart|force-reload) 79 echo -n "Restarting $DESC: " 80 start-stop-daemon --stop --quiet --exec $DAEMON 81 sleep 1 82 start-stop-daemon --start --quiet --exec $DAEMON 83 echo "$NAME." 84 ;; 85 status) 86 status $DAEMON 87 exit $? 88 ;; 89 *) 90 N=${0##*/} 91 N=${N#[SK]??} 92 echo "Usage: $N {start|stop|status|restart|force-reload}" >&2 93 exit 1 94 ;; 95esac 96 97exit 0 98 99