#!/bin/sh

case "$1" in
    start)
	echo -n "Starting zabbix_server - 60s start delay for MySQL to load during boot"
	sleep 60
        sudo -u zabbix __PREFIX__/bin/zabbix/zabbix_server -c __PREFIX__/etc/zabbix/zabbix_server.conf
        ;;

    stop)
        echo -n "Shutting down zabbix_server"
        pid=`ps axc|awk "{if (\\$5==\"zabbix_server\") print \\$1}"`
        /bin/kill $pid
       rm /var/tmp/zabbix_server.pid
        ;;
    restart)
        $0 stop
        $0 start
        ;;
    status)
        /bin/ps -ax |/usr/bin/grep zabbix_server
        ;;
        *)
        echo "Usage: $0 {start|stop|restart|status}"
        exit 1
esac

