Saturday, March 12, 2011

THIS SITE HAS MOVED!

Site moved permanently to http://www.noisewaterphd.com

Go there now, update your bookmarks. Thanks for reading!

Tuesday, May 11, 2010

Red5 Server Startup Script For Linux (init)

I've also posted a previous version of this file in an earlier post about installing Red5 Server on Linux.  This version is a bit more refined.

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!

Wednesday, April 28, 2010

Installing Red5 Server On Linux (CentOS)

Red5 Installation Instructions
 
NONE OF THIS WILL WORK WITHOUT ANT, So first install ANT 1.8.0 (See my previous post...)
 
STEP 1
 
Once ANT is installed we can download and install the Red5 server:
I needed Red5 version 0.9.RC1 specifically in order to have some particular things work properly, you may want to check out the trunk rather than this older tag, just adjust your subversion URL accordingly.


cd /usr/src
  svn checkout http://red5.googlecode.com/svn/java/server/tags/0_9rc1/ red5
  mv red5 /usr/local/
  cd /usr/local/red5
  ant prepare
  ant dist
 
Once the compile is finished you should see:
BUILD SUCCESSFUL


STEP 2
 
Now we need to set up the configuration directory: copy the conf directory from dist:

cp -r dist/conf .
  ./red5.sh
 
 
STEP 3
 
If everything starts up nicely, then we can build an init script for Red5:

UPDATE: No matter what I seem to try, blogger is screwing up my line endings and character encoding. So here is a link to the file itself, if you are wanting to just directly copy and paste a working init script, use this file:

http://www.mediafire.com/file/ewlwnmywizd/red5

vi /etc/init.d/red5
 
Copy this text in:

#!/bin/sh
  # For RedHat and cousins:
  # chkconfig: 2345 85 85
  # description: Red5 flash streaming server
  # processname: red5
  PROG=red5
  RED5_HOME=/usr/local/red5
  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
 
Now start the service
/etc/init.d/red5 start (or, my preference) service red5 start

check status
/etc/init.d/red5 status (or, my preference) service red5 status
red5 (pid  XXXXX) is running…
 
STEP 4
 
Now test the RED5 installation by opening following URL in browser
http://yourip:5080/

Friday, April 16, 2010

Installing ANT 1.8.1



U

UPDATED 09/23/2010 to 1.8.1, links to a working download again :)




Download and setup ANT:

cd /usr/src
  wget http://mirror.cc.columbia.edu/pub/software/apache//ant/binaries/apache-ant-1.8.1-bin.tar.gz
  tar -zxvf apache-ant-1.8.1-bin.tar.gz 
  mv apache-ant-1.8.1 /usr/local/ant

Export Variables for Ant:

export ANT_HOME=/usr/local/ant
export PATH=$PATH:/usr/local/ant/bin
 
You should do the same thing in /etc/bashrc so that you don't have to keep exporting everything everytime you login:

echo ‘export ANT_HOME=/usr/local/ant’ >> /etc/bashrc
  echo ‘export PATH=$PATH:/usr/local/ant/bin’ >> /etc/bashrc
  
That should be all...

Wednesday, April 7, 2010

Compile 32 bit C Code On Your 64 bit Linux Workstation

So, you need to compile for a 32 bit server (or whatever similar scenario you may encounter)? Well, if you are using gcc, there is a simple solution:

$ gcc -m32 -o output32 yourfile.c

And, the reverse, as you may have guessed already:

$ gcc -m64 -o output64 yourfile.c

Note: You may need to install the gcc multilibs for this to work properly.

Have an excellent evening all,

Kenny

Back in the Saddle

So, after a 3 year hiatus from my career as a Software Engineer, I am officially returning to the profession. You can expect the same stellar commentary, and relentless rants about the industry and everything related as before.

It was a great break though! I spent the last 3 years as a professional musician. I played guitar in a rock band for money. Not great money, mind you, but it paid the bills. If it didn't require so much travel to keep the money coming in, I may have even kept at it for a while longer. I got to see some amazing places, and I met so many new close friends along the road, that I would never trade those years for anything.

Perhaps a few articles might sneak in here detailing some of my adventures on the road. In the meantime, let's get reacquainted, I hope to see a lot of the same folks lurking around here, and I look forward to some great discussions!