Simple Red5 start/stop script (Mac OSX ready)

27 Jan
2010

Notes: Make sure to create a writeable log file for red5 at “/var/log/red5.log”. Usage of the script is straightforward: “/etc/init.d/red5 start”.

[cci lang="bash"]
#! /bin/sh
# Author: Sandeep Ghael
# put these contents at: /etc/init.d/red5
# change red5 directory path below as necessary
RED5_DIR=/usr/share/red5

start()
{
echo “Starting Red5 Service”
sudo su root -c “cd $RED5_DIR; ./red5.sh > /var/log/red5.log &”
return
}

stop()
{
echo “Shutting down red5″
sudo su root -c ‘killall red5 java’
return
}

case “$1″ in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo “Usage: {start|stop|restart}”
exit 1
;;
esac
exit $?
[/cci]

2 Responses to Simple Red5 start/stop script (Mac OSX ready)

Avatar

George

April 4th, 2010 at 12:27 pm

Hi Sandeep,
Thanks for writing this script, I have been looking for something like this as I can only stop the server is by force quitting it at the moment.

Although, I am having some troubles with your script.
I have copied your example code, and saved it as “red5.sh” in the same directory as my Red5 install
On my Mac Red5 is installed in:
/Applications/Red5/Red5.app
So I have changed the directory path to
RED5_DIR=/Applications/Red5

I have created the log file in /Applications/Red5/log/red5.log
and edited the refering path to:
sudo su root -c “cd $RED5_DIR; ./red5.sh > ./log/red5.log &”
I have given the full permissions to both red5.sh & red5.log by running chmod 777 on them in Terminal.

You suggest running: “/etc/init.d/red5 start”
so in my case I would run “/Applications/Red5/log/red5 start”
but I get this error:
“-bash: /Applications/Red5/red5: No such file or directory”

changing the command to:
“/Applications/Red5/red5.sh start”
I get:
“Starting Red5 Service appears
Password:”
on entering that, nothing happens, although looking at the red5.log file I can see the following:
“Usage: {start|stop|restart}”

Could you offer any assistance?

Thanks George

Avatar

sghael

April 19th, 2010 at 10:56 am

Hi George,

Are you sure “/Applications/Red5/Red5.app” is a binary you can execute? Typically on Mac OS X, something.app is a folder which contains other files, one of which is the actual start script (red5.sh). I installed Red5 from source, so we have differing directory structures. I don’t have an .app directory at all.

My script above is not intended to be “red5.sh”. “red5.sh” is a start script that typically comes with the install of Red5 (again, I installed Red5 from the source package, so YMMV). My script saved as “/etc/init.d/red5″ calls the start script “red5.sh” which is ususally in some subdirectory of where ever Red5 got installed.

It could also be you have a permissions problem. Make sure the user trying to execute the script has SU ability. The prompt for password you are getting is because of the line ” sudo su root -c “cd $RED5_DIR; ./red5.sh > /var/log/red5.log &” ” .

Let me know if you get it working!

Comment Form

top