#!/sbin/runscript # # description: Starts and stops the ulogd daemon # CONF="/etc/ulogd.conf" LOG="`/bin/awk '/^logfile/ {print $2}' $CONF`" opts="${opts} reload" # You will want to lose this dependency if you don't log to mysql depend() { need mysql } initService() { # Check that ulogd.conf exists. if [ ! -f $CONF ]; then eend 1 "Config file $CONF is missing" return 1 fi # Now make sure database is running before trying to start # ulogd fails to connect with no clue if database isn't listening if [ `/bin/grep -c '^[^#].*MYSQL' $CONF` -gt 0 ]; then RUNNING=0 for ((i=1; i<10; i+=1)); do if [ `/bin/netstat --inet -pln | /bin/grep -c mysqld` -gt 0 ]; then RUNNING=1 break fi echo -n "+" /bin/sleep 1 done if [ "$i" -gt 1 ]; then echo "`/bin/date` made $i checks for mysql listening" >>${LOG} fi if [ "$RUNNING" -eq 0 ]; then eend 1 "mysql NOT listening even after $i check(s)" return 1 fi fi return 0 } start() { ebegin "Starting ulogd" initService || return 1 start-stop-daemon --start --quiet --exec /usr/sbin/ulogd -- -d >/dev/null 2>&1 eend $? } stop() { ebegin "Stopping ulogd" start-stop-daemon --stop --quiet --exec /usr/sbin/ulogd >/dev/null 2>&1 eend $? } reload() { ebegin "Reloading ulogd.conf file" initService || return 1 start-stop-daemon --stop --signal HUP --quiet --exec /usr/sbin/ulogd >/dev/null 2>&1 eend $? }