Patchwork [2/6] sysvinit: add init.d/bootlogd status command for LSB compliance

login
register
mail settings
Submitter jackie huang
Date Aug. 20, 2013, 3:25 a.m.
Message ID <0502058d180d47c81b6431d01868dd9bba6653f5.1376968627.git.jackie.huang@windriver.com>
Download mbox | patch
Permalink /patch/56019/
State New
Headers show

Comments

jackie huang - Aug. 20, 2013, 3:25 a.m.
From: Jackie Huang <jackie.huang@windriver.com>

Signed-off-by: Li Wang <li.wang@windriver.com>
Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
---
 meta/recipes-core/sysvinit/sysvinit/bootlogd.init |   28 ++++++++++++++++++---
 1 files changed, 24 insertions(+), 4 deletions(-)
Phil Blundell - Aug. 20, 2013, 6:39 a.m.
On Tue, 2013-08-20 at 11:25 +0800, jackie.huang@windriver.com wrote:
> @@ -37,6 +40,19 @@ case "$0" in
>  		;;
>  esac
>  
> +# default /var/log/boot is not an option since /var/log becomes
> +# /var/volatile/log
> +logfile=/var/local/bootlogd.log
> +
> +#
> +# Create initial log files
> +#
> +if [ ! -f "$logfile" ] && touch "$logfile" >/dev/null 2>&1; then
> +	echo "(Nothing has been logged yet.)" >| "$logfile"
> +	chown root:adm "$logfile"
> +	chmod 640 "$logfile"
> +fi
> +
>  case "$ACTION" in
>  	start)
>  		echo -n "Starting $DESC: "
> @@ -44,9 +60,9 @@ case "$ACTION" in
>  		then
>  			umask 027
>  			start-stop-daemon --start --quiet \
> -				--exec $DAEMON -- -r
> +				--exec $DAEMON -- -r -l $logfile
>  		else
> -			$DAEMON -r
> +			$DAEMON -r -l $logfile
>  		fi
>  		echo "$NAME."
>  		;;

It's not totally obvious that the changes are related to the "status"
command.  If you're creating new logfiles that didn't exist previously
then I think the commit message ought to explain why.

p.
jackie huang - Aug. 20, 2013, 9:33 a.m.
On 8/20/2013 2:39 PM, Phil Blundell wrote:
> On Tue, 2013-08-20 at 11:25 +0800, jackie.huang@windriver.com wrote:
>> @@ -37,6 +40,19 @@ case "$0" in
>>   		;;
>>   esac
>>
>> +# default /var/log/boot is not an option since /var/log becomes
>> +# /var/volatile/log
>> +logfile=/var/local/bootlogd.log
>> +
>> +#
>> +# Create initial log files
>> +#
>> +if [ ! -f "$logfile" ] && touch "$logfile" >/dev/null 2>&1; then
>> +	echo "(Nothing has been logged yet.)" >| "$logfile"
>> +	chown root:adm "$logfile"
>> +	chmod 640 "$logfile"
>> +fi
>> +
>>   case "$ACTION" in
>>   	start)
>>   		echo -n "Starting $DESC: "
>> @@ -44,9 +60,9 @@ case "$ACTION" in
>>   		then
>>   			umask 027
>>   			start-stop-daemon --start --quiet \
>> -				--exec $DAEMON -- -r
>> +				--exec $DAEMON -- -r -l $logfile
>>   		else
>> -			$DAEMON -r
>> +			$DAEMON -r -l $logfile
>>   		fi
>>   		echo "$NAME."
>>   		;;
>
> It's not totally obvious that the changes are related to the "status"
> command.  If you're creating new logfiles that didn't exist previously
> then I think the commit message ought to explain why.
>

Sorry, my mistake to involve some other patch when I got the patch from 
our layer, I will remake the patches.

Thanks,
Jackie

> p.
>
>
>
>

Patch

diff --git a/meta/recipes-core/sysvinit/sysvinit/bootlogd.init b/meta/recipes-core/sysvinit/sysvinit/bootlogd.init
index f8f07a0..455d001 100755
--- a/meta/recipes-core/sysvinit/sysvinit/bootlogd.init
+++ b/meta/recipes-core/sysvinit/sysvinit/bootlogd.init
@@ -13,6 +13,9 @@  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
@@ -37,6 +40,19 @@  case "$0" in
 		;;
 esac
 
+# default /var/log/boot is not an option since /var/log becomes
+# /var/volatile/log
+logfile=/var/local/bootlogd.log
+
+#
+# Create initial log files
+#
+if [ ! -f "$logfile" ] && touch "$logfile" >/dev/null 2>&1; then
+	echo "(Nothing has been logged yet.)" >| "$logfile"
+	chown root:adm "$logfile"
+	chmod 640 "$logfile"
+fi
+
 case "$ACTION" in
 	start)
 		echo -n "Starting $DESC: "
@@ -44,9 +60,9 @@  case "$ACTION" in
 		then
 			umask 027
 			start-stop-daemon --start --quiet \
-				--exec $DAEMON -- -r
+				--exec $DAEMON -- -r -l $logfile
 		else
-			$DAEMON -r
+			$DAEMON -r -l $logfile
 		fi
 		echo "$NAME."
 		;;
@@ -70,13 +86,17 @@  case "$ACTION" in
 		echo -n "Restarting $DESC: "
 		start-stop-daemon --stop --quiet --exec $DAEMON
 		sleep 1
-		start-stop-daemon --start --quiet --exec $DAEMON
+		start-stop-daemon --start --quiet --exec $DAEMON -- -l $logfile
 		echo "$NAME."
 		;;
+	status)
+		status $DAEMON
+		exit $?
+		;;
 	*)
 		N=${0##*/}
 		N=${N#[SK]??}
-		echo "Usage: $N {start|stop|restart|force-reload}" >&2
+		echo "Usage: $N {start|stop|status|restart|force-reload}" >&2
 		exit 1
 		;;
 esac