To my knowledge everything in this bash script works on mac as well as linux. This is the bash script I use for my teamspeak 3 server.
make sure you change the DIR to the right location, the DAEMON to the correct file, and the PARAMS to anything you want to specify on commandline to it
Code:
#! /bin/sh
# Leave this alone.
NAME=teamspeak3_server
PATH=/bin:/usr/bin:/sbin:/usr/sbin
# DON'T FORGET TO CHANGE THE PATH TO YOUR NEEDS!
DIR=/home/teamspeak_server
# Change this to the file for your system.
DAEMON=ts3server_linux_x86
# Internet-server:
PARAMS="inifile=ts3server.ini"
# Leave this alone.
DESC="Teamspeak server"
case "$1" in
start)
ps aux | grep -v grep | grep "SCREEN -A -d -m -S $NAME" > /dev/null
CHECK=$?
if [ $CHECK -eq 0 ]; then
echo "Teamspeak server is already running."
exit 1
else
echo "Starting $DESC: $NAME"
cd $DIR && screen -A -d -m -S $NAME ./$DAEMON $PARAMS
fi
;;
stop)
if [[ `screen -ls |grep $NAME` ]]
then
echo -n "Stopping $DESC: $NAME"
kill `ps aux | grep -v grep | grep "SCREEN -A -d -m -S $NAME" | awk '{print $2}'`
echo " ... done."
else
echo "Coulnd't find a running $DESC"
fi
;;
status)
ps aux | grep -v grep | grep "SCREEN -A -d -m -S $NAME" > /dev/null
CHECK=$?
if [ $CHECK -eq 0 ]; then
echo "Teamspeak server running"
else
echo "Teamspeak server is not running"
fi
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1
;;
esac
exit 0