summarylogtreecommitdiffstats
path: root/syslog-ng.rc
diff options
context:
space:
mode:
authorAlexey D2015-07-05 14:24:37 +0300
committerAlexey D2015-07-05 14:24:37 +0300
commit1486eec543ce30a61dadbd838465310cbf510af0 (patch)
treedfc8e920930e387b2679837643aac28ea283314f /syslog-ng.rc
downloadaur-1486eec543ce30a61dadbd838465310cbf510af0.tar.gz
initial version
Diffstat (limited to 'syslog-ng.rc')
-rw-r--r--syslog-ng.rc67
1 files changed, 67 insertions, 0 deletions
diff --git a/syslog-ng.rc b/syslog-ng.rc
new file mode 100644
index 000000000000..d48b71ed1775
--- /dev/null
+++ b/syslog-ng.rc
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+. /etc/conf.d/syslog-ng
+
+checkconfig() {
+ if ! syslog-ng -s "${SYSLOG_NG_CHECKOPTS[@]}"; then
+ stat_fail
+ exit 1
+ fi
+}
+
+pidfile=/run/syslog-ng.pid
+if [[ -r $pidfile ]]; then
+ read -r PID < "$pidfile"
+ if [[ $PID && ! -d /proc/$PID ]]; then
+ # stale pidfile
+ unset PID
+ rm -f "$pidfile"
+ fi
+fi
+
+case $1 in
+ start)
+ stat_busy "Starting Syslog-NG"
+ checkconfig
+ if [[ -z $PID ]] && /usr/sbin/syslog-ng "${SYSLOG_NG_OPTS[@]}"; then
+ add_daemon syslog-ng
+ stat_done
+ else
+ stat_fail
+ exit 1
+ fi
+ ;;
+ stop)
+ stat_busy "Stopping Syslog-NG"
+ if [[ $PID ]] && kill $PID &>/dev/null; then
+ rm_daemon syslog-ng
+ stat_done
+ else
+ stat_fail
+ exit 1
+ fi
+ ;;
+ reload)
+ stat_busy "Reloading Syslog-NG configuration and re-opening log files"
+ if [[ -z $PID ]]; then
+ stat_fail
+ else
+ checkconfig
+ if kill -HUP $PID &>/dev/null; then
+ stat_done
+ else
+ stat_fail
+ exit 1
+ fi
+ fi
+ ;;
+ restart)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+ *)
+ echo "usage: $0 {start|stop|restart|reload}"
+esac