User:Whyroc

From OpenSimulator

Revision as of 07:54, 16 March 2008 by Whyroc (Talk | contribs)

Jump to: navigation, search

Startup script for OpenSim Grid

Hopefully someone can use this.. works for me!

It opens and closes servers or attaches to screen sessions.

based on: http://gentoo-wiki.com/TIP_Using_screen

I’m using MySql and a local grid setup.

To use this script:

copy this text and paste it into a new file on your server with a .sh extension, ie ’sess.sh’

enter ‘./sess.sh’ at the command line once to start all the servers, it may take a minute to return to the command line

enter ‘./sess.sh’ again (or hit the up arrow key) to either attach to one of the servers or to close all servers

to attach to a server, enter its number or name

to close all servers hit any other key

#!/bin/bash

# filters the screen -ls output to show the sesssions
sessions=`screen -ls | sed -ne 's/[[:space:]]//' -ne 's/((Attached)|(Detached))// p'`
res=`echo "$sessions" | wc -w`

if [[ "$res" == "0" ]]
then
echo "  No servers detected starting Grid..."

cd /usr/local/opensim2/bin
sleep 5
screen -S user -d -m  mono OpenSim.Grid.UserServer.exe
sleep 5
screen -S grid  -d -m mono OpenSim.Grid.GridServer.exe
sleep 5
screen -S asset  -d -m mono OpenSim.Grid.AssetServer.exe
sleep 5
screen -S inv  -d -m mono OpenSim.Grid.InventoryServer.exe
sleep 5
screen -S sim  -d -m mono OpenSim.exe

exit
fi

echo ''
echo "  CURRENT SESSIONS  - enter session number to connect, any other key will stop servers"
echo "  ------------------------"
#screen -ls | sed -ne 's/[[:space:]]//' -ne 's/((Attached)|(Detached))// p' | cat -n
echo "$sessions" | cat -n
echo "  ------------------------"
echo ''

#if first argument is not specified, script will ask for number of screen

if [ -z $1 ]
then
echo -n "  Reattach to session: "
read session
else
session=$1
fi

#attach to specified session
linenum=0
name=`screen -ls | sed -ne 's/[[:space:]]//' -ne 's/((Attached)|(Detached))// p' |
while read line
do
let "linenum += 1"
if [[ "$linenum" -eq "$session" ]]
then
echo $line
break
fi
done`

if [[ "$name" != "" ]]
then
screen -d -r "$name"
else
echo "  Could not reattach to '$session' shutting down"

screen -S sim -r -m  -X quit
screen -S inv -r -m  -X quit
screen -S asset -r -m  -X quit
screen -S grid -r -m  -X quit
screen -S user -r -m  -X quit

fi
Personal tools
General
About This Wiki