core/syslog-ng/syslog-ng.rc

68 lines
1.1 KiB
Plaintext
Raw Normal View History

2010-03-13 23:25:19 +08:00
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
2012-02-26 12:09:49 +08:00
checkconfig() {
if ! syslog-ng -s -f /etc/syslog-ng/syslog-ng.conf; 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
2010-03-13 23:25:19 +08:00
start)
stat_busy "Starting Syslog-NG"
2012-02-26 12:09:49 +08:00
checkconfig
if [[ -z $PID ]] && /usr/sbin/syslog-ng; then
2010-03-13 23:25:19 +08:00
add_daemon syslog-ng
stat_done
2012-02-26 12:09:49 +08:00
else
stat_fail
exit 1
2010-03-13 23:25:19 +08:00
fi
;;
stop)
stat_busy "Stopping Syslog-NG"
2012-02-26 12:09:49 +08:00
if [[ $PID ]] && kill $PID &>/dev/null; then
2010-03-13 23:25:19 +08:00
rm_daemon syslog-ng
stat_done
2012-02-26 12:09:49 +08:00
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
2010-03-13 23:25:19 +08:00
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
2012-02-26 12:09:49 +08:00
echo "usage: $0 {start|stop|restart|reload}"
2010-03-13 23:25:19 +08:00
esac
exit 0