NOTE Please see Rotate Red5 Logs Without logrotate for a better way to configure logging.

This script assumes you have installed Red5 to /opt/red5, added a non-privileged user named Red5 and applied the appropriate ownership/permissions to the red5/log, red5/webapps and red5/work directories. It is compatible with OpenRC.

#!/sbin/runscript
# Copyright (c) 2011 http://foxpa.ws
# All rights released

description="Runs Red5 streaming media server on Gentoo"

depend()
{
        need net
}

start()
{
        ebegin "Starting Red5"
        start-stop-daemon --start --quiet --user=red5 --background --chdir=/opt/red5/ --stdout /var/log/red5/red5.log --stderr /var/log/red5/red5_errors.log --exec "/opt/red5/red5.sh"
        eend ${?}
}

stop()
{
        ebegin "Stopping Red5"
        cd /opt/red5/
        start-stop-daemon --stop --quiet --exec "/opt/red5/red5.sh"
        ./red5-shutdown.sh &> /dev/null
        eend ${?}
}