1

I am creating startup script for Red5 on Ubuntu. Red5 is installed in /opt/red5

Following is a working script on a CentOS Box on which Red5 is running [code]

==========Start init script ==========

 #!/bin/sh
    

    PROG=red5
    RED5_HOME=/opt/red5/dist
    DAEMON=$RED5_HOME/$PROG.sh
    PIDFILE=/var/run/$PROG.pid

    # Source function library
    . /etc/rc.d/init.d/functions

    [ -r /etc/sysconfig/red5 ] && . /etc/sysconfig/red5

    RETVAL=0

    case "$1" in
    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)
    $0 stop
    $0 start
    ;;
    status)
    status $PROG -p $PIDFILE
    RETVAL=$?
    ;;
    *)
    echo $"Usage: $0 {start|stop|restart|status}"
    RETVAL=1
    esac

    exit $RETVAL

[/code] What do I need to replace for Ubuntu in the above script.

My Red5 is in /opt/red5/ and to start it manually I always do

/opt/red5/dist/red5.sh from Ubuntu As I did not find rc.d/functions on Ubuntu on my laptop also /etc/init.d/functions I did not existed. I would like to be able to use them with service as Red hat distributions do. I checked /lib/lsb/init-functions.

user49249
  • 11
  • 3

2 Answers2

1

The file you probably want is /lib/lsb/init_functions.

You say you checked that file. What do you mean? Did you try using it in place of /etc/rc.d/init.d/functions in that line in the startup script? Did you get any error messages in the logs?

You should try modeling your script after other scripts in /etc/init.d.

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
1

Ok here is what I did following is the script which is actually working

#The script to start Red 5 Tapas Mishra
##Begin some thing some thing
### BEGIN INIT INFO
# Provides:          Red5
# Required-Start:    No idea
# Required-Stop:     No idea
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Red5 Streaming Server
# Description:       Ubuntu init script for Red5 server
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON="/opt/red5/dist/red5.sh"
NAME="Red5"
RED5_HOME=/opt/red5/dist
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
DESC="Red5 Ubuntu Server"

. /lib/lsb/init-functions
set -e

PROCESS_DIR="/opt/red5/dist"

case "$1" in
  start)
        log_daemon_msg "Starting $DESC" "$NAME"
        start-stop-daemon --start --pidfile $PIDFILE \
                --chdir $RED5_HOME --background --make-pidfile \
                --exec $DAEMON
        log_end_msg $?
        ;;
   stop)
        log_daemon_msg "Stopping $DESC" "$NAME"
        start-stop-daemon --stop --quiet --pidfile $PIDFILE \

             --name java
        rm -f $PIDFILE
        log_end_msg $?
        ;;
  restart|force-reload)
        echo -n "Restarting $DESC: $NAME"
        start-stop-daemon --stop --quiet --pidfile $PIDFILE \
                --name java
        rm -f $PIDFILE
        sleep 1
        echo -e
        $0 start
        ;;
  *)
        echo "Usage: $0 {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0
Bond
  • 781
  • 4
  • 12
  • 22