#!/bin/sh
#
# MacPorts generated daemondo support script
#

#
# Init
#
prefix=/opt/local
bump() { [ `sysctl -n $1` -lt $2 ] && sysctl $1=$2 ; } 
bump kern.sysv.shmall 32768 && bump kern.sysv.shmmax 134217728

#
# Start
#
Start()
{
	/opt/local/sbin/zabbix/zabbix_server
}

#
# Stop
#
Stop()
{
	let x=120; while /usr/bin/pkill -u zabbix -F /opt/local/var/run/zabbix/zabbix_server.pid;  do sleep 1; let x--; [ $x -le 0 ] && break; done
}

#
# Restart
#
Restart()
{
	Stop
	Start
}

#
# Run
#
Run()
{
case $1 in
  start  ) Start   ;;
  stop   ) Stop    ;;
  restart) Restart ;;
  *      ) echo "$0: unknown argument: $1";;
esac
}

#
# Run a phase based on the selector
#
Run $1

