Ogltree Install Instructions

From OpenSimulator

Jump to: navigation, search


Instructions:
1.	Install expect and sudo packages
	apt-get install expect
	apt-get install sudo
2.	Create a special user account with a password and using the bash shell.
	NOTE: replace all occurrances (below) of <SPECIALUSER> and <PASSWORD>
		with the name of your special user and it's password.
3.	make a '/root/scripts' directory and install the following scripts in it:
	3.a	restartOpenSim
	3.b	expect.in
	3.c	LOS
	3.d	KOS
4.	create the '/home/OSimLogs' directory to contain the OpenSim logs.
5.	set up the crontab for root using the entry found below.
Addendum:
	I am working on using monit to monitor the OpenSim and automatically run /root/scripts/KOS
	whenever required. At the moment I have to login to the server as root and run 'KOS'
	manually when OpenSim hangs up.
Explanation:
	The cronjob makes sure that restartOpenSim is running. It attempts to start it every 10 minutes.
	The script itself goes to great lengths to ensure that only one instance of it actually runs.
	If it ever dies you will have to remove the file '/root/scripts/ROS.running' to allow a fresh
	instance of it to run.
	the restartOpenSim script will (if needed) start expect running the expect.in script.
	expect will spawn a login shell and login to the special user account. This will cause the
	execution of sudo to run LOS which in turn will launch OpenSim with logging to '/home/OSimLogs'
	directory. The log files will be date and time stamped.
------------  restartOpenSim script  ----------------------------------------------
#!/bin/bash

if [ -f "/root/scripts/ROS.running" ]
then
	exit 0
fi
RES=`ps -ef |grep -i restartOpenSim |grep -v grep |grep bash |wc -l |awk '{print \$1}'`
if [ "$RES" -gt "3" ]
then
	echo "RES=$RES aborting"
	exit 0
fi
echo 1 >/root/scripts/ROS.running
while [ 1 ]
do
	RES1=`ps -ef |grep "mono OpenSim.exe" |grep -v grep`
	if [ "$RES1" = "" ]
	then
		RES2=`who |grep <SPECIALUSER>`
		if [ "$RES2" = "" ]
		then
			RES3=`ps -ef |grep <SPECIALUSER> |grep -v grep`
			if [ "$RES3" = "" ]
			then
				echo "running LOS"
				expect -f /root/scripts/expect.in
				sleep 5
			fi
		fi
	fi
	sleep 10
done
------------  expect.in script  ----------------------------------------------
spawn login
expect Login:
send <SPECIALUSER\r
expect Password:
send <PASSWORD>\r
expect "by applicable law."
wait 255
send exit
wait 500
------------  LOS script  ----------------------------------------------
#!/bin/sh
# LOS
RES=`tty`
DT=`date +%Y%m%d_%H%M`
echo "In LOS tty=$RES" >>/root/scripts/LOS.out
cd /root/opensim/bin; mono OpenSim.exe > /home/OSimLogs/OSimLog.$DT
------------  KOS script  ----------------------------------------------
#!/bin/bash

MON=`ps -ef |grep "mono OpenSim" |grep -v grep |awk '{print \$2}'`
ULI=`ps -ef |grep <SPECIALUSER> |grep -v grep |grep bash |awk '{print \$2}'`
EXP=`ps -ef |grep expect |grep -v grep |awk '{print \$2}'`
if [ "$MON" != "" ]
then
	kill -9 $MON
fi
if [ "$ULI" != "" ]
then
	kill -9 $ULI
fi
if [ "$EXP" != "" ]
then
	kill -9 $EXP
fi
-----------------------------------------------------------------------
---------  Excerpt from <SPECIALUSER>'s .bashrc  ----------------------
RES=`tty`
DT=`date`
echo "${DT}: Simmer logged in with tty = $RES" >>/home/Simmer/loginlog
sudo /root/scripts/LOS
-----------------------------------------------------------------------
---------------  /etc/sudoers file ------------------------------------
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults        env_reset

# Host alias specification

# User alias specification
User_Alias      OPENSIM=<SPECIALUSER>

# Cmnd alias specification
Cmnd_Alias      OSIM = /root/scripts/LOS

# User privilege specification
root    ALL=(ALL) ALL
OPENSIM         db4151109=NOPASSWD:OSIM
--------------------------------------------------------------------
---------------  root's crontab entry  -----------------------------
0,10,20,30,40,50 * * * * /root/scripts/restartOpenSim 2>>/root/scripts/restart.err >>/root/scripts/restart.out
--------------------------------------------------------------------
Personal tools
General
About This Wiki