[arch-commits] Commit in syslog-ng/trunk (syslog-ng.rc)
Dave Reisner
dreisner at archlinux.org
Sat Sep 17 18:50:18 UTC 2011
Date: Saturday, September 17, 2011 @ 14:50:18
Author: dreisner
Revision: 138144
rewrite rc script, particularly to use syslog-ng's own PID file
Modified:
syslog-ng/trunk/syslog-ng.rc
--------------+
syslog-ng.rc | 56 ++++++++++++++++++++++++++++++--------------------------
1 file changed, 30 insertions(+), 26 deletions(-)
Modified: syslog-ng.rc
===================================================================
--- syslog-ng.rc 2011-09-17 17:00:45 UTC (rev 138143)
+++ syslog-ng.rc 2011-09-17 18:50:18 UTC (rev 138144)
@@ -4,51 +4,56 @@
. /etc/rc.d/functions
checkconfig() {
- syslog-ng -s -f /etc/syslog-ng/syslog-ng.conf
- if [ $? -gt 0 ]; then
- stat_busy "Configuration error. Please fix your config file (/etc/syslog-ng/syslog-ng.conf)."
- stat_fail
- exit 0
- fi
+ if ! syslog-ng -s -f /etc/syslog-ng/syslog-ng.conf; then
+ stat_busy "Configuration error. Please fix your config file (/etc/syslog-ng/syslog-ng.conf)."
+ stat_fail
+ exit 1
+ fi
}
-PID=`pidof -o %PPID /usr/sbin/syslog-ng`
-case "$1" in
+pidfile=/run/syslog-ng.pid
+if [[ -r $pidfile ]]; then
+ read -r PID < "$pidfile"
+ if [[ ! -d /proc/$PID ]]; then
+ # stale pidfile
+ unset PID
+ rm -f "$pidfile"
+ fi
+fi
+
+case $1 in
start)
stat_busy "Starting Syslog-NG"
checkconfig
- [ -z "$PID" ] && /usr/sbin/syslog-ng
- if [ $? -gt 0 ]; then
- stat_fail
- else
+ if [[ -z "$PID" ]] && /usr/sbin/syslog-ng; then
add_daemon syslog-ng
stat_done
+ else
+ stat_fail
+ exit 1
fi
;;
stop)
stat_busy "Stopping Syslog-NG"
- [ ! -z "$PID" ] && kill $PID &> /dev/null
- if [ $? -gt 0 ]; then
- stat_fail
- else
- rm -f /var/run/syslog-ng.pid
-# Removing stale syslog-ng.persist file. Its new location, as of 2.0.6-1, is /var/lib/syslog-ng/
- rm -f /var/syslog-ng.persist
+ 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
+ if [[ -z $PID ]]; then
stat_fail
else
checkconfig
- kill -HUP $PID &> /dev/null
- if [ $? -gt 0 ]; then
+ if kill -HUP $PID &>/dev/null; then
+ stat_done
+ else
stat_fail
- else
- stat_done
+ exit 1
fi
fi
;;
@@ -58,6 +63,5 @@
$0 start
;;
*)
- echo "usage: $0 {start|stop|restart|reload}"
+ echo "usage: $0 {start|stop|restart|reload}"
esac
-exit 0
More information about the arch-commits
mailing list