You might have some issues with character encoding and line endings when copying and pasting directly from this website, so I recommend you download the actual file for use:
http://www.mediafire.com/file/ewlwnmywizd/red5
Place this script in /etc/init.d/ and name it red 5. Also make sure you give the script proper permissions!
#!/bin/sh
#
# Dr. Kenneth Noisewater 05/07/2010
#
# I wrote this for CentOS, but it should work fine in RedHat and related distros
#
# chkconfig: 2345 85 85
# description: Red5 Media Server
# processname: red5
# We need to initialize a few things
PROG=red5
RED5_HOME=/usr/local/red5
DAEMON=$RED5_HOME/$PROG.sh
PIDFILE=/var/run/$PROG.pid
# Make sure the sucka using this actually has permission, not that we would be able to open some essential ports if the weren't anyway
#[ "`id -u`" = 0 ] || exit 1
# Source function library
. /etc/rc.d/init.d/functions
[ -r /etc/sysconfig/red5 ] && . /etc/sysconfig/red5
RETVAL=0
# And here is where the magic happens...
start() {
echo -n "Starting $PROG: "
cd $RED5_HOME
$DAEMON >/dev/null 2>/dev/null &
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo $! > $PIDFILE
touch /var/lock/subsys/$PROG
fi
[ $RETVAL -eq 0 ] && success $"$PROG startup" || failure $"$PROG startup"
echo
}
stop() {
echo -n "Shutting down $PROG: "
killproc -p $PIDFILE
RETVAL=$?
echo
[$RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROG
}
restart() {
stop
sleep 10 # give it a few moments to shut down
start
}
# Check to see what the user is telling us to do, and if we know how to do it
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $PROG -p $PIDFILE
RETVAL=$?
;;
restart)
restart
;;
*)
echo "Usage $0 {start|stop|restart|status}"
RETVAL=1
esac
exit $RETVAL
Now you can start and stop Red5 with the script!
service red5 start
service red5 stop
service red5 restart
service red5 status
If you want Red5 server to start up automatically on reboot:
chkconfig red5 on
That is all for today!
0 comments:
Post a Comment