AIX: rc.ajaxterm

rc.ajaxterm for AIX

A bunch of additional tests can be included, you can add syslog records etc...

You can use it from /etc/rc.d/rc2.d on AIX by creating the usual Sxx... Kxx... links.

#! /usr/bin/ksh
#
# Control script for ajaxterm
# (c) LGee
#
# Variables
PATH=/usr/bin:/usr/sbin
a_user=ajaxterm
a_root=/path/to/wwwroot/ajaxterm
a_index=ajaxterm.html
a_pid=/var/tmp/ajaxterm.pid
a_stderr=/path/to/logs/ajaxterm/ajaxterm.err
# Using python supplied by the IBM XIV storage host attachment kit
python_path=/opt/xpyv/bin
# Main
case "$1" in
  start)
    su - $a_user -c "${python_path}/python ${a_root}/ajaxterm.py \
      -d \
      -i $a_index \
      -P$a_pid \
      -l 2> $a_stderr" \
        || echo " ajaxterm/start ERROR"
    ;;
  stop)
    if ! [ -f $a_pid ]; then
      echo " ajaxterm/stop: not running"
    fi
    kill -9 $(<$a_pid) 2>/dev/null || rm -f $a_pid
    ;;
  status)
    if ! [ -f $a_pid ]; then
      echo " ajaxterm/status: OFFLINE"
    elif [ -t $(ps -p $(<$a_pid) -o pid=) ]; then
      echo " ajaxterm/status: OFFLINE"
    else
      echo " ajaxterm/status: ONLINE"
    fi
    ;;
  *)
    echo "Usage: rc.ajaxterm start|stop|status"
    ;;
esac