Skip to contentSkip to conversation

initscripts: add dmesg file to /var/log

PATCH New [email protected] 1 participant 2 messages Jul 4, 2013

lore
Share & tools
lore
#0 lore raw

cover initscripts: add dmesg file to /var/log

From: Jackie Huang <[email protected]>

The following changes since commit 682bcd0939697c34ce9bc7b2fe8f7d734f280490:

initscripts: overwrite default hostname.sh (2013-07-04 17:19:03 +0800)

are available in the git repository at:
git://git.pokylinux.org/poky-contrib jhuang0/r_bbappend_udev-initscripts_dmesg_0704_1
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=jhuang0/r_bbappend_udev-initscripts_dmesg_0704_1

Jackie Huang (1):
initscripts: add dmesg file to /var/log

 .../initscripts/initscripts-1.0/dmesg.sh           |   17 +++++++++++++++++
 .../initscripts-1.0/logrotate-dmesg.conf           |    9 +++++++++
 meta/recipes-core/initscripts/initscripts_1.0.bb   |    9 +++++++--
 3 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-core/initscripts/initscripts-1.0/dmesg.sh
 create mode 100644 meta/recipes-core/initscripts/initscripts-1.0/logrotate-dmesg.conf
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 1/1 initscripts: add dmesg file to /var/log

From: Jackie Huang <[email protected]>

We should create the /var/log/dmesg.log file as a default. If we don't then a later kernel error can flush the dmesg ring buffer, losing valuable debug information.

---
 .../initscripts/initscripts-1.0/dmesg.sh           |   17 +++++++++++++++++
 .../initscripts-1.0/logrotate-dmesg.conf           |    9 +++++++++
 meta/recipes-core/initscripts/initscripts_1.0.bb   |    9 +++++++--
 3 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-core/initscripts/initscripts-1.0/dmesg.sh
 create mode 100644 meta/recipes-core/initscripts/initscripts-1.0/logrotate-dmesg.conf
meta/recipes-core/initscripts/initscripts-1.0/dmesg.sh new file +17 -0
new file mode 100644
index 0000000..a97b068
@@ -0,0 +1,17 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:             dmesg
+# Required-Start:
+# Required-Stop:
+# Default-Start:        S
+# Default-Stop:
+### END INIT INFO
+
+if [ -f /var/log/dmesg ]; then
+	if [ -f /usr/sbin/logrotate ]; then
+		logrotate -f /etc/logrotate-dmesg.conf
+	else
+		mv -f /var/log/dmesg /var/log/dmesg.old
+	fi
+fi
+dmesg -s 131072 > /var/log/dmesg
meta/recipes-core/initscripts/initscripts-1.0/logrotate-dmesg.conf new file +9 -0
new file mode 100644
index 0000000..6f46e42
@@ -0,0 +1,9 @@
+# see "man logrotate" for details
+# rotate dmesg, and keep 5 versions.
+
+/var/log/dmesg {
+	create
+	rotate 5
+	nodateext
+}
+
meta/recipes-core/initscripts/initscripts_1.0.bb +7 -2
index 531b2b6..52e1c9c 100644
@@ -3,7 +3,7 @@ DESCRIPTION = "Initscripts provide the basic system startup initialization scrip
 SECTION = "base"
 LICENSE = "GPLv2"
 LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
-PR = "r140"
+PR = "r141"
 
 INHIBIT_DEFAULT_DEPS = "1"
 
@@ -31,7 +31,10 @@ SRC_URI = "file://functions \
            file://read-only-rootfs-hook.sh \
            file://volatiles \
            file://save-rtc.sh \
-           file://GPLv2.patch"
+           file://GPLv2.patch \
+           file://dmesg.sh \
+           file://logrotate-dmesg.conf \
+"
 
 SRC_URI_append_arm = " file://alignment.sh"
 
@@ -89,6 +92,8 @@ do_install () {
 	install -m 0755    ${WORKDIR}/read-only-rootfs-hook.sh ${D}${sysconfdir}/init.d
 	install -m 0755    ${WORKDIR}/save-rtc.sh	${D}${sysconfdir}/init.d
 	install -m 0644    ${WORKDIR}/volatiles		${D}${sysconfdir}/default/volatiles/00_core
+	install -m 0755    ${WORKDIR}/dmesg.sh		${D}${sysconfdir}/init.d
+	install -m 0644    ${WORKDIR}/logrotate-dmesg.conf ${D}${sysconfdir}/
 
 	if [ "${TARGET_ARCH}" = "arm" ]; then
 		install -m 0755 ${WORKDIR}/alignment.sh	${D}${sysconfdir}/init.d
Signature · 1 line
1.7.4.1