summaryrefslogtreecommitdiffstats
path: root/system/rsyslog/config/rc.rsyslogd
blob: 6318d7f8ed0851d69dee6848689d7ccf1fec8541 (plain)
#!/bin/sh
# Start/stop/restart the system logging daemons.
#
# Written for Slackware Linux by Patrick J. Volkerding <volkerdi@slackware.com>.
# Modded for rsyslogd by Chris Elvidge <chris@lowe.ae> Sept 2005
# slightly modified by ponce <matteo.bernardini@sns.it> Oct 2010

create_xconsole()
{
    if [ ! -e /dev/xconsole ]; then
      mknod -m 640 /dev/xconsole p
    else
      chmod 0640 /dev/xconsole
    fi
    chown 0:0 /dev/xconsole
}

rsyslogd_start() {
  if [ -x /usr/sbin/rsyslogd ]; then
    echo "Starting rsyslogd daemon:  "
    echo "/usr/sbin/rsyslogd -i $pidfile1"
    /usr/sbin/rsyslogd -i "$pidfile1"
    cp "$pidfile1" "$pidfile2"
  fi
}

rsyslogd_stop() {
  killall rsyslogd 2> /dev/null
  /usr/bin/rm "$pidfile1" 2> /dev/null
  /usr/bin/rm "$pidfile2" 2> /dev/null
}

rsyslogd_restart() {
  rsyslogd_stop
  sleep 1
  rsyslogd_start
}

pidfile1=/var/run/rsyslogd.pid
pidfile2=/var/run/syslogd.pid

case "$1" in
'start')
  create_xconsole
  rsyslogd_start
  ;;
'stop')
  rsyslogd_stop
  ;;
'restart')
  rsyslogd_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac