#!/bin/sh

# note: do not name this script "monkey"

# pidof, killall does not work properly if monkey is in working dir
cd /tmp

if [ "$1" = "start" ]
then
  "$0" stop
  chown -R nobody:nobody /root/monkey/
  /root/monkey/bin/monkey -Dc /root/monkey/conf
  exit
fi

if [ "$1" = "stop" ]
then
  if pidof monkey > /dev/null
  then
    killall -q -2 monkey
    sleep 1
    killall -q -2 monkey && killall -q -9 monkey
  fi
  exit
fi

echo "Useage: `basename "$0"` [start|stop]"
