anytermd web-based console

Since at my job I can’t connect anywhere outside of the network over ssh, I’ve had to resort to using a web-based console. There’s an application called Anyterm that works great in that arena. Since I connect from a single IP address via proxy, I’ve blocked connections to my home machine from every IP except for that one, in /etc/hosts.allow & /etc/hosts.deny.

There’s one thing missing with anyterm, and that’s the fact that it has no initialization scripts. I use CentOS Linux, which is basically the same as Red Hat Enterprise Linux. I slapped together a script to go into /etc/init.d and here it is:

#!/bin/bash
#
# Init file for anytermd server daemon
#
# chkconfig: 2345 55 25
# description: Anyterm server daemon
#
# processname: anytermd
# pidfile: /var/run/anytermd.pid

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

# pull in sysconfig settings
[ -f /etc/sysconfig/anytermd ] && . /etc/sysconfig/anytermd

RETVAL=0
prog=”anytermd”

# Some functions to make the below more readable
ANYTERMD=/usr/local/bin/anytermd
PID_FILE=/var/run/anytermd.pid

runlevel=$(set — $(runlevel); eval “echo \$$#” )

OPTIONS=”-u $USER -a trivial”

start()
{
echo -n $”Starting $prog: ”
$ANYTERMD $OPTIONS && success || failure
RETVAL=$?
[ “$RETVAL” = 0 ] && touch /var/lock/subsys/anytermd
echo
}

stop()
{
echo -n $”Stopping $prog: ”
if [ -n “`pidfileofproc $ANYTERMD`” ] ; then
killproc $ANYTERMD
else
failure $”Stopping $prog”
fi
RETVAL=$?
# if we are in halt or reboot runlevel kill all running sessions
# so the TCP connections are closed cleanly
if [ “x$runlevel” = x0 -o “x$runlevel” = x6 ] ; then
killall $prog 2>/dev/null
fi
[ “$RETVAL” = 0 ] && rm -f /var/lock/subsys/anytermd
echo
}

reload()
{
echo -n $”Reloading $prog: ”
if [ -n “`pidfileofproc $ANYTERMD`” ] ; then
killproc $ANYTERMD -HUP
else
failure $”Reloading $prog”
fi
RETVAL=$?
echo
}
case “$1” in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
reload)
reload
;;
condrestart)
if [ -f /var/lock/subsys/anytermd ] ; then
if [ “$RETVAL” = 0 ] ; then
stop
# avoid race
sleep 3
start
fi
fi
;;
status)
status $ANYTERMD
RETVAL=$?
;;
*)
echo $”Usage: $0 {start|stop|restart|reload|condrestart|status}”
RETVAL=1
esac
exit $RETVAL

Afterwards, creating the file /etc/sysconfig/anytermd and slapping the variable USER in there with the userid of the user the application should run as. Mine is USER=nlund

Afterwards, run “chkconfig –add anytermd” to add anytermd to the initialization stack. Then, run “chkconfig anytermd on” to set anytermd to start upon boot.
After that, all I have to do is go to http://myip:8080 and up comes challenge/response section of anyterm.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s