diff options
author | Sergey Lapin <slapin@ossfans.org> | 2010-04-20 15:01:42 +0400 |
---|---|---|
committer | Sergey Lapin <slapin@ossfans.org> | 2010-04-20 15:03:11 +0400 |
commit | c2df527b5576907cee0d20c9bea110b54dca4b06 (patch) | |
tree | c154b386a3996a932a1e4496b49bb1748859970c /recipes/sysklogd | |
parent | 5453d2a8938c2142e9d893d7713790e6001477b6 (diff) |
sysklogd: installing init script
Diffstat (limited to 'recipes/sysklogd')
-rwxr-xr-x | recipes/sysklogd/files/sysklogd | 140 | ||||
-rw-r--r-- | recipes/sysklogd/sysklogd.inc | 8 |
2 files changed, 147 insertions, 1 deletions
diff --git a/recipes/sysklogd/files/sysklogd b/recipes/sysklogd/files/sysklogd new file mode 100755 index 0000000000..e0fa7a8e1e --- /dev/null +++ b/recipes/sysklogd/files/sysklogd @@ -0,0 +1,140 @@ +#! /bin/sh +# /etc/init.d/sysklogd: start the system log daemon. + +### BEGIN INIT INFO +# Provides: sysklogd +# Required-Start: $remote_fs $time +# Required-Stop: $remote_fs $time +# Should-Start: $network +# Should-Stop: $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: System logger +### END INIT INFO + +PATH=/bin:/usr/bin:/sbin:/usr/sbin + +pidfile_syslogd=/var/run/syslogd.pid +pidfile_klogd=/var/run/syslogd.pid +binpath_syslogd=/sbin/syslogd +binpath_klogd=/sbin/klogd + +test -x $binpath || exit 0 + +test ! -r /etc/default/syslogd || . /etc/default/syslogd + +create_xconsole() +{ + # Only proceed if /dev/xconsole is used at all + if ! grep -q '^[^#].*/dev/xconsole' /etc/syslog.conf + then + return + fi + + if [ ! -e /dev/xconsole ]; then + mknod -m 640 /dev/xconsole p + else + chmod 0640 /dev/xconsole + fi + chown root:adm /dev/xconsole + test ! -x /sbin/restorecon || /sbin/restorecon /dev/xconsole +} + +log_begin_msg () { + echo -n $1 +} + +log_end_msg () { + echo $1 +} + +log_success_msg () { + echo $1 +} + +running() +{ + # No pidfile, probably no daemon present + # + if [ ! -f $pidfile ] + then + return 1 + fi + + pid=`cat $pidfile_syslogd` + + # No pid, probably no daemon present + # + if [ -z "$pid" ] + then + return 1 + fi + + if [ ! -d /proc/$pid ] + then + return 1 + fi + + cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1` + + # No syslogd? + # + if [ "$cmd" != "$binpath" ] + then + return 1 + fi + + return 0 +} + +case "$1" in + start) + log_begin_msg "Starting system log daemon..." + create_xconsole + start-stop-daemon --start --quiet --pidfile $pidfile_syslogd --name syslogd --startas $binpath_syslogd -- $SYSLOGD + log_end_msg $? + log_begin_msg "Starting kernel log daemon..." + start-stop-daemon --start --quiet --pidfile $pidfile_klogd --name klogd --startas $binpath_klogd -- $KLOGD + log_end_msg $? + ;; + stop) + log_begin_msg "Stopping system log daemon..." + start-stop-daemon --stop --quiet --pidfile $pidfile_syslogd --name syslogd + log_end_msg $? + log_begin_msg "Stopping kernel log daemon..." + start-stop-daemon --stop --quiet --retry 3 --exec $binpath_klogd --pidfile $pidfile_klogd + log_end_msg $? + ;; + reload|force-reload) + log_begin_msg "Reloading system log daemon..." + start-stop-daemon --stop --quiet --signal 1 --pidfile $pidfile_syslogd --name syslogd + log_end_msg $? + log_begin_msg "Reloading kernel log daemon..." + start-stop-daemon --stop --quiet --retry 3 --exec $binpath_klogd --pidfile $pidfile_klogd + start-stop-daemon --start --quiet --pidfile $pidfile_klogd --name klogd --startas $binpath_klogd -- $KLOGD + log_end_msg $? + ;; + restart) + log_begin_msg "Restarting system log daemon..." + start-stop-daemon --stop --retry 5 --quiet --pidfile $pidfile_syslogd --name syslogd + start-stop-daemon --start --quiet --pidfile $pidfile_syslogd --name syslogd --startas $binpath_syslogd -- $SYSLOGD + log_end_msg $? + log_begin_msg "Reloading kernel log daemon..." + start-stop-daemon --stop --quiet --retry 3 --exec $binpath_klogd --pidfile $pidfile_klogd + start-stop-daemon --start --quiet --pidfile $pidfile_klogd --name klogd --startas $binpath_klogd -- $KLOGD + log_end_msg $? + ;; + reload-or-restart) + if running + then + $0 reload + else + $0 start + fi + ;; + *) + log_success_msg "Usage: /etc/init.d/sysklogd {start|stop|reload|restart|force-reload|reload-or-restart}" + exit 1 +esac + +exit 0 diff --git a/recipes/sysklogd/sysklogd.inc b/recipes/sysklogd/sysklogd.inc index 5eb85a2943..65da86d835 100644 --- a/recipes/sysklogd/sysklogd.inc +++ b/recipes/sysklogd/sysklogd.inc @@ -3,8 +3,12 @@ SECTION = "base" DESCRIPTION = "The sysklogd package implements two system log daemons." SRC_URI = "http://www.ibiblio.org/pub/Linux/system/daemons/sysklogd-${PV}.tar.gz \ - file://nonrootinstall.patch;patch=1" + file://nonrootinstall.patch;patch=1 \ + file://sysklogd" +inherit update-rc.d +INITSCRIPT_NAME = "sysklogd" +INITSCRIPT_PARAMS = "start 39 S 1 2 3 . stop 99 0 6 ." CFLAGS_append = " -DSYSV" RCONFLICTS = "busybox-syslog" @@ -18,6 +22,8 @@ do_install () { mv ${D}${base_sbindir}/klogd ${D}${base_sbindir}/klogd.${PN} install -d ${D}${sysconfdir} install -m 644 ${S}/syslog.conf ${D}${sysconfdir}/syslog.conf + install -d ${D}${sysconfdir}/init.d + install -m 755 ${WORKDIR}/sysklogd ${D}${sysconfdir}/init.d/sysklogd } pkg_postinst_${PN} () { update-alternatives --install ${base_sbindir}/syslogd syslogd syslogd.${PN} 100 |