#!/bin/sh#This is a red5 start/stop script on debian/ubuntu#You will need to have screen installed#red5 is started in its own screen, allowing debug#for now, exept debug screen, there is no log# Construct vars#exe is the full path to the executablename="Red5"log_dir="/opt/red5/log"workdir="/opt/red5/"exe="./red5.sh"#time=`echo $(date +%Y%m%d)_$(date +%H_%M_%S)`# notify if no option is givenif [ $# -ne 1 ]; thenecho "Usage: $0 (start|stop|restart|status|debug) "exitfiStart(){cd $tmp_dirif ps -ef | grep SCREEN_$name | grep -v grep > /dev/null; thenecho "$name is running, stop first to restart!"else#mv $log_dir/red5.log $log_dir/red5.log.$timecd $workdir$exe echo "$name started"fi}Stop(){if ps -ef | grep SCREEN_$name | grep -v grep > /dev/null; thenecho "$name is runningStopping now"ps -ef | grep "$exe" | grep -v grep | awk ' { print $2 } '| xargs kill > /dev/nullelseecho "$name not running"fi}Status(){if ps -ef | grep SCREEN_$name | grep -v grep > /dev/null ; thenecho "$name is running!"elseecho "$name is not running!"fi}Debug(){if ps -ef | grep SCREEN_$name | grep -v grep > /dev/null ; thenecho "$name is running!"echo "You will now debug $name, to quit debugging press CTRL+A+D"echo "DON'T USE CTRL+C, You will kill $name!"echo "Press any key to continue"read TA/usr/bin/screen -r SCREEN_$nameelseecho "$name is not running!"fi}# MAINcase "$1" instart)Start;;stop)Stop;;restart)Stopsleep 2Start;;debug)Debug;;status)Status;;esacexit 0然后运行 cd /etc/init.d/ update-rc.d red5 defaults 可以通过 /etc/init.d/red5 start 启动服务 重启系统后red5服务随开机启动