summaryrefslogtreecommitdiff
path: root/system/syslog-ng/rc.syslog-ng
blob: 61f4a2beee5914ad3937ab3e0a6ff10861a92217 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh
#
# Start/stop/restart the syslog-ng daemon
# Drop-in replacement for a stock Slackware rc.syslog script
# Written by Mario Preksavec <mario@slackware.hr>

syslog_start() {
  if [ -x /usr/sbin/syslog-ng ]; then
    if [ -f /var/run/syslog-ng.pid ] && kill -0 $(cat /var/run/syslog-ng.pid) 2> /dev/null; then
      echo "syslog-ng daemon already running!"
      return
    fi

    echo "Starting syslog-ng daemon:  /usr/sbin/syslog-ng"
    /usr/sbin/syslog-ng -R /var/lib/syslog-ng/syslog-ng.persist

    # Link syslogd.pid for compatibility with other rc scripts
    if [ -f /var/run/syslog-ng.pid ] && kill -0 $(cat /var/run/syslog-ng.pid) 2> /dev/null; then
      ln -sf /var/run/syslog-ng.pid /var/run/syslogd.pid
    fi
  fi
}

syslog_stop() {
  if [ -f /var/run/syslog-ng.pid ]; then
    echo "Stopping syslog-ng daemon"
    kill $(cat /var/run/syslog-ng.pid) 2> /dev/null && rm -f /var/run/syslog-ng.pid
    # Unlink syslogd.pid
    unlink /var/run/syslogd.pid
  fi
  killall syslog-ng 2> /dev/null
}

syslog_restart() {
  syslog_stop
  sleep 1
  syslog_start
}

case "$1" in
'start')
  syslog_start
  ;;
'stop')
  syslog_stop
  ;;
'restart')
  syslog_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac