Automating Tasks

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
m (Windows)
(oslogdel.sh)
 
(51 intermediate revisions by 13 users not shown)
Line 1: Line 1:
==Automate Grid Startup==
+
{{Quicklinks}}
===Windows===
+
 
 +
= Automated Grid Startup =
 +
== Linux/Mac OS X ==
 +
=== See ===
 +
* /etc/init.d daemon script -> [[Startup script linux|startup script]]
 +
* [[Automated Upgrade LINUX]]
 +
* [[Autorestart With Upstart|upstart]]
 +
* [[Linux Service with sytemd|systemd]]
 +
 
 +
=== Basic scripts ===
 +
* Use Screen Command
 +
 
 +
Use the screen command to automate startup
 +
 
 +
* Setup screen command and setup shell file
 +
 
 +
Linux install:
 +
 
 +
apt-get install screen (ubuntu)
 +
pacman -S screen (archlinux)
 +
 
 +
Mac OS X: Download either MacPorts, http://www.macports.org/, or Fink, http://www.finkproject.org/ to download *nix packages MacPorts
 +
 
 +
sudo port install screen
 +
 
 +
Fink
 +
 
 +
* Create file runsim.sh
 +
 
 +
#!/bin/sh
 +
cd opensim/bin
 +
screen -S Robust -d -m  mono OpenSim.Robust.exe
 +
sleep 10
 +
screen -S OpenSimulator -d -m mono OpenSim.exe -gridmode=true
 +
 
 +
See Also --> [[Smart Prestart LINUX]]
 +
 
 +
* '''Bash Scripts:'''
 +
* Start multiple instances and backup critical files prior to startup
 +
* Automated Shutdown of multiple instances with a 2 minute pre-warning to users in-world.
 +
* NB This can be used to stuff other functions into OpenSimulator Console as well.
 +
 
 +
=== Startup and access servers ===
 +
./runsim.sh
 +
 
 +
If you have permission issues
 +
chmod 755 runsim.sh
 +
 
 +
To see a list of the servers in screen:
 +
screen -ls or screen -list
 +
 
 +
Output will look like the following:
 +
There are screens on:
 +
      8419.OpenSim  (Detached)
 +
      8403.Robust  (Detached)
 +
 
 +
To access server
 +
screen -r 8419.OpenSim
 +
screen -r 8403.Robust
 +
 
 +
To exit screen, leaving server running, and to return to shell
 +
ctrl-a d
 +
 
 +
=== osstart.sh ===
 +
 
 +
example: osstart.sh OpenSim
 +
 
 +
(Directory name = screen name)
 +
 
 +
Real examples:
 +
 
 +
/opt/osstart.sh sim1
 +
 
 +
/opt/osstart.sh sim2
 +
 
 +
/opt/osstart.sh sim3
 +
 
 +
/opt/osstart.sh sim...
 +
 
 +
#!/bin/bash
 +
sleep 3
 +
if [ -d $1 ]; then
 +
  echo "$(tput setaf 4)OpenSim: $(tput setab 7)$1 Start$(tput sgr 0)"
 +
  cd /opt/$1/bin
 +
  screen -fa -S $1 -d -U -m mono OpenSim.exe
 +
else
 +
  echo "$(tput setaf 2)The following screens were started$(tput sgr 0)"
 +
  screen -ls
 +
    exit 1
 +
fi
 +
 
 +
=== osgridstart.sh ===
 +
 
 +
#!/bin/bash
 +
sleep 3
 +
robust="/opt/robust/"
 +
if [ -d "$robust" ]; then
 +
  # Take action if $robust exists. #
 +
  echo "$(tput setaf 4)OpenSim: $(tput setab 3)RobustServer Start$(tput sgr 0)"
 +
  cd /opt/robust/bin
 +
  screen -fa -S RO -d -U -m mono Robust.exe
 +
else
 +
  echo "$(tput setaf 2)The following screens were started $(tput sgr 0)RO $(tput setaf 2)and $(tput sgr 0)OS$(tput setaf 2).$(tput sgr 0)"
 +
  screen -ls
 +
    exit 1
 +
fi
 +
sleep 10
 +
money="/opt/robust/"
 +
if [ -d "$money" ]; then
 +
  # Take action if $robust exists. #
 +
  echo "$(tput setaf 4)OpenSim: $(tput setab 3)MoneyServer Start$(tput sgr 0)"
 +
  cd /opt/robust/bin
 +
  screen -fa -S MO -d -U -m mono MoneyServer.exe
 +
else
 +
  echo "$(tput setaf 2)The following screens were started $(tput sgr 0)RO $(tput setaf 2)and $(tput sgr 0)OS$(tput setaf 2).$(tput sgr 0)"
 +
  screen -ls
 +
    exit 1
 +
fi
 +
cd /opt
 +
# echo " Wait 40 seconds and then start regions."
 +
sleep 40
 +
echo "$(tput setaf 2)OpenSim: $(tput setab 0)Welcome Region start$(tput sgr 0)"
 +
/opt/osstart.sh sim1
 +
echo "$(tput setaf 2)OpenSim: $(tput setab 0)Start all other regions$(tput sgr 0)"
 +
/opt/osstart.sh sim2
 +
/opt/osstart.sh sim3
 +
/opt/osstart.sh sim4
 +
/opt/osstart.sh sim5
 +
/opt/osstart.sh sim6
 +
/opt/osstart.sh sim7
 +
/opt/osstart.sh sim8
 +
/opt/osstart.sh sim9
 +
/opt/osstart.sh sim10
 +
echo "$(tput setaf 2)List started screens$(tput sgr 0)"
 +
screen -ls
 +
 
 +
=== Shutdown Servers ===
 +
Either manually access each sceen
 +
screen -r 8419.OpenSim
 +
shutdown
 +
 
 +
Or
 +
screen -S OpenSim -p 0 -X eval "stuff 'shutdown'^M"
 +
 
 +
Or use (only in the event of a crash!)
 +
killall screen
 +
 
 +
Or
 +
for i in `ps afxu | grep -i "mono.*OpenSim" | grep -v grep | awk {'print $2'}`; do kill $i; done
 +
 
 +
Or to shut down each session clean, make a stop script, stopgrid.sh
 +
#!/bin/bash
 +
screen -S Robust -X quit
 +
sleep 10
 +
screen -S OpenSim -X quit
 +
 
 +
=== osstop.sh ===
 +
example: osstop.sh OpenSim
 +
 
 +
(Directory name = screen name)
 +
 
 +
real example:
 +
 
 +
/opt/osstop.sh sim1
 +
 
 +
/opt/osstop.sh sim2
 +
 
 +
/opt/osstop.sh sim...
 +
 
 +
#!/bin/bash
 +
sleep 10
 +
if screen -list | grep -q $1; then
 +
  echo "$(tput setaf 1)OpenSim: $(tput setab 7)Regionen OpenSimulator $1 Beenden$(tput sgr 0)"
 +
  screen -S $1 -p 0 -X eval "stuff 'shutdown'^M"
 +
else
 +
  echo "$(tput setaf 1)OpenSim: $(tput setab 7)Regionen OpenSimulator $1 nicht vorhanden$(tput sgr 0)"
 +
fi
 +
 
 +
 
 +
=== osgridstop.sh ===
 +
 
 +
#!/bin/bash
 +
sleep 3
 +
echo "$(tput setaf 1)OpenSim: $(tput setab 6)Stop regions$(tput sgr 0)"
 +
/opt/osstop.sh sim2
 +
/opt/osstop.sh sim3
 +
/opt/osstop.sh sim4
 +
/opt/osstop.sh sim5
 +
/opt/osstop.sh sim6
 +
/opt/osstop.sh sim7
 +
/opt/osstop.sh sim8
 +
/opt/osstop.sh sim9
 +
/opt/osstop.sh sim10
 +
sleep 30
 +
echo "$(tput setaf 1)OpenSim: $(tput setab 6)Stop the Welcome Region$(tput sgr 0)"
 +
/opt/osstop.sh sim1
 +
if screen -list | grep -q "MO"; then
 +
  echo "$(tput setaf 1)OpenSim: $(tput setab 3)Exit MoneyServer$(tput sgr 0)"
 +
  screen -S MO -p 0 -X eval "stuff 'shutdown'^M"
 +
else
 +
  echo "$(tput setaf 1)OpenSim: $(tput setab 3)MoneyServer does not exist$(tput sgr 0)"
 +
fi
 +
sleep 30
 +
if screen -list | grep -q "RO"; then
 +
  echo "$(tput setaf 1)OpenSim: $(tput setab 3)Exit RobustServer$(tput sgr 0)"
 +
  screen -S RO -p 0 -X eval "stuff 'shutdown'^M"
 +
else
 +
  echo "$(tput setaf 1)OpenSim: $(tput setab 3)RobustServer does not exist$(tput sgr 0)"
 +
fi
 +
sleep 30
 +
echo " List screens"
 +
screen -ls
 +
echo "$(tput setaf 1)$(tput setab 7)Wait 60 seconds and then kill all open screens$(tput sgr 0)"
 +
sleep 60
 +
killall screen
 +
 
 +
=== oslogdel.sh ===
 +
deletes log files (unfortunately the log files get unbearably large.)
 +
 
 +
example: oslogdel.sh OpenSim
 +
 
 +
real example:
 +
 
 +
/opt/oslogdel.sh robust
 +
 
 +
/opt/oslogdel.sh sim1
 +
 
 +
/opt/oslogdel.sh sim2
 +
 
 +
/opt/oslogdel.sh sim...
 +
 
 +
#!/bin/bash
 +
sleep 3
 +
cd /opt
 +
if [ -d $1 ]; then
 +
  echo "$(tput setaf 1)OpenSim: $(tput setab 7)log $1 deleted$(tput sgr 0)"
 +
  cd /opt/$1/bin
 +
  # echo "/opt/$1/bin"
 +
  rm *.log
 +
else
 +
  echo "$(tput setaf 1)logs not found $(tput sgr 0)"
 +
  exit 1
 +
fi
 +
 
 +
=== Simulator Watchdog ===
 +
Watches the simulator process under Linux
 +
 
 +
Adding an entry to call a simple script to check the process table can restart regions that crash to the command line. Here [[User_talk:BlueWall]] is a script to accomplish this with a sample cron entry for one minute intervals. While it will not fix 100% of the crashes, it will get most cases, and help keep the grid healthy. If you have questions, you can usually find me on irc.freenode.net #opensim or #osgrid
 +
 
 +
--[[User:BlueWall|BlueWall]] 15:53, 19 June 2008 (PDT)
 +
 
 +
=== Automate Updates ===
 +
==== Linux (CentOS-5) ====
 +
This script will save your settings, grab the latest release of OpenSim, build OpenSim, and restore your settings to the new release. It creates the new release in a new directory allowing you to revert to the previous release by just changing the 'current' link to point to whichever release you want to run.
 +
 
 +
'''Note:'''
 +
''This may not work well if updating from versions that are quite far apart. Minor updates should work well. Sometimes you have to clear out the SAVEDIR to prevent very old files from messing up a new update.''
 +
 
 +
This script assumes you are using the SVN release number as the OpenSimulator directory with a link called 'current' pointing to it. So, you might, for example, have a directory called '/home/opensim/7577' and a link 'current -> 7577'. This script also uses a save folder for moving settings from the old release to the new.
 +
 
 +
You will also want to compare the 'OpenSim.ini' and the 'OpenSim.ini.example' by hand after running this update script. There are often changes in this file needed for the new release. The 'diff -bB' command helps a lot in this comparison.
 +
 
 +
<pre>
 +
#!/bin/bash -x
 +
 
 +
CWD=`pwd`
 +
MWD="/home/opensim"  # Main Working Directory
 +
SAVEDIR="$MWD/save"  # Save Directory
 +
 
 +
if [ ! -d $SAVEDIR ]; then mkdir $SAVEDIR; fi
 +
if [ ! -d $SAVEDIR/Regions ]; then mkdir $SAVEDIR/Regions; fi
 +
if [ ! -d $SAVEDIR/DataSnapshot ]; then mkdir $SAVEDIR/DataSnapshot; fi
 +
if [ ! -d $SAVEDIR/config-include ]; then mkdir $SAVEDIR/config-include; fi
 +
 
 +
cd $MWD
 +
 
 +
# save current settings
 +
cp current/bin/*.xml $SAVEDIR
 +
cp current/bin/*.db $SAVEDIR
 +
cp current/bin/*.ini $SAVEDIR
 +
cp current/bin/config-include/*.ini $SAVEDIR/config-include/
 +
cp current/bin/Regions/*xml $SAVEDIR/Regions/
 +
cp current/bin/DataSnapshot/*xml $SAVEDIR/DataSnapshot/
 +
 
 +
# Get fresh copy of OpenSimulator
 +
REV=`svn info http://opensimulator.org/svn/opensim/trunk | fgrep Revision | awk '{print $2}'`
 +
svn -r $REV co http://opensimulator.org/svn/opensim/trunk $REV
 +
rm current
 +
ln -s $REV current
 +
cd current
 +
./runprebuild.sh
 +
nant
 +
cd bin
 +
# restore settings
 +
if [ ! -d ./DataSnapshot ]; then mkdir ./DataSnapshot; fi
 +
cp $SAVEDIR/*.xml .
 +
cp $SAVEDIR/*.db .
 +
cp $SAVEDIR/*.ini .
 +
cp $SAVEDIR/config-include/* config-include/
 +
cp $SAVEDIR/Regions/* Regions/
 +
cp $SAVEDIR/DataSnapshot/* DataSnapshot/
 +
cd $MWD
 +
cd current
 +
#
 +
cd $CWD
 +
</pre>
 +
 
 +
== Windows ==
 
Create a batch file to start up your grid, e.g. startGrid.bat ;
 
Create a batch file to start up your grid, e.g. startGrid.bat ;
  
Line 9: Line 316:
 
  :: %PROGRAMFILES% expands to your normal application path
 
  :: %PROGRAMFILES% expands to your normal application path
 
  :: On an English system this is normally C:\Program Files
 
  :: On an English system this is normally C:\Program Files
 +
:: If you run a 64-bit Windows, with OpenSimulator as a 32-bit
 +
:: application, substitute with %PROGRAMFILES(X86)%
 
   
 
   
  Echo Starting User Server...
+
  Echo Starting Robust Server...
  start "UserServer" /MIN /D "%PROGRAMFILES%\OpenSim" OpenSim.Grid.UserServer.exe
+
  start "Robust" /MIN /D "%PROGRAMFILES%\OpenSim" OpenSim.Robust.exe
sleep 5
+
Echo Starting Grid Server...
+
start "GridServer" /MIN /D "%PROGRAMFILES%\OpenSim" OpenSim.Grid.GridServer.exe
+
sleep 5
+
Echo Starting Asset Server...
+
start "AssetServer" /MIN /D "%PROGRAMFILES%\OpenSim" OpenSim.Grid.AssetServer.exe
+
sleep 5
+
Echo Starting Inventory Server...
+
start "InventoryServer" /MIN /D "%PROGRAMFILES%\OpenSim" OpenSim.Grid.InventoryServer.exe
+
 
  sleep 5
 
  sleep 5
 
  Echo Starting Region Server...
 
  Echo Starting Region Server...
Line 27: Line 327:
 
  :END
 
  :END
  
 
+
PS! Check that you have sleep command installed, I'm unsure if all Windows versions have that.<br />
PS! Check that you have sleep command installed, I'm unsure if all Windows versions have that.<br>
+
 
If sleep is not installed one can use a localhost ping instead to replace "sleep 3".
 
If sleep is not installed one can use a localhost ping instead to replace "sleep 3".
 
  PING -n 4 127.0.0.1>nul
 
  PING -n 4 127.0.0.1>nul
This knowledgebase article describes how to add a batch file to startup of Windows (before logon).<br>
+
This knowledgebase article describes how to add a batch file to startup of Windows (before logon).<br />
[http://support.microsoft.com/kb/q243486/ http://support.microsoft.com/kb/q243486/]<br>
+
[http://support.microsoft.com/kb/q243486/ http://support.microsoft.com/kb/q243486/]<br />
Note that you have to start all applications and answer the configuration questions once before adding it to any startup.<br>
+
Note that you have to start all applications and answer the configuration questions once before adding it to any startup.<br />
<br>
+
<br />
 
If you start the server before logon then there will be no window to close if you want to shut down the server, so you can create a "StopGrid.BAT" with:
 
If you start the server before logon then there will be no window to close if you want to shut down the server, so you can create a "StopGrid.BAT" with:
 
  taskkill /FI "IMAGENAME eq OpenSim.*"
 
  taskkill /FI "IMAGENAME eq OpenSim.*"
Line 57: Line 356:
 
   
 
   
 
  :n1
 
  :n1
  Echo Stopping Inventory Server...
+
  Echo Stopping Robust Server...
  taskkill /T /IM OpenSim.Grid.InventoryServer.exe > NUL 2>&1
+
  taskkill /T /IM OpenSim.Grid.Robust.exe > NUL 2>&1
  If ERRORLEVEL 128 Echo Inventory Server was not running! & Echo. & Goto n2
+
  If ERRORLEVEL 128 Echo Robust Server was not running! & Echo. & Goto n2
 
  :r2
 
  :r2
  If ERRORLEVEL 1 taskkill /T /F /IM OpenSim.Grid.InventoryServer.exe > NUL 2>&1
+
  If ERRORLEVEL 1 taskkill /T /F /IM OpenSim.Grid.Robust.exe > NUL 2>&1
  If ERRORLEVEL 0 Echo Inventory Server stopped. & Echo. & Goto n2
+
  If ERRORLEVEL 0 Echo Robust Server stopped. & Echo. & Goto n2
Goto r2
+
 
+
:n2
+
Echo Stopping Asset Server...
+
taskkill /T /IM OpenSim.Grid.AssetServer.exe > NUL 2>&1
+
If ERRORLEVEL 128 Echo Asset Server was not running! & Echo. & Goto n3
+
:r3
+
If ERRORLEVEL 1 taskkill /T /F /IM OpenSim.Grid.AssetServer.exe > NUL 2>&1
+
If ERRORLEVEL 0 Echo Asset Server stopped. & Echo. & Goto n3
+
Goto r3
+
+
:n3
+
Echo Stopping Grid Server...
+
taskkill /T /IM OpenSim.Grid.GridServer.exe > NUL 2>&1
+
If ERRORLEVEL 128 Echo Grid Server was not running! & Echo. & Goto n4
+
:r4
+
If ERRORLEVEL 1 taskkill /T /F /IM OpenSim.Grid.GridServer.exe > NUL 2>&1
+
If ERRORLEVEL 0 Echo Grid Server stopped. & Echo. & Goto n4
+
Goto r4
+
+
:n4
+
Echo Stopping User Server...
+
taskkill /T /IM OpenSim.Grid.UserServer.exe > NUL 2>&1
+
If ERRORLEVEL 128 Echo User Server was not running! & Echo. & Goto END
+
:r5
+
If ERRORLEVEL 1 taskkill /T /F /IM OpenSim.Grid.UserServer.exe > NUL 2>&1
+
If ERRORLEVEL 0 Echo User Server stopped. & Echo. & Goto END
+
Goto r5
+
+
 
  :END
 
  :END
(Batch edits, [[User:Suz|Suz]] 04:46, 27 May 2008 (PDT))
 
  
===Linux/Mac OS X===
+
=== See also ===
You can use this [[startup_script_linux|startup script]]
+
* [[Smart Prestart WIN]]
* Use Screen Command
+
* [[Automated Upgrade WIN]]
Use the screen command to automate startup
+
* Setup screen command and setup shell file
+
Linux install:
+
apt-get install screen (ubuntu)
+
pacman -S screen (archlinux)
+
Mac OS X: Download either MacPorts, http://www.macports.org/, or Fink, http://www.finkproject.org/ to download *nix packages
+
MacPorts
+
sudo port install screen
+
Fink
+
Need command line for Fink.
+
* Create file runsim.sh
+
#!/bin/sh
+
cd opensim/bin
+
sleep 3
+
screen -S UserServer -d -m  mono OpenSim.Grid.UserServer.exe
+
sleep 3
+
screen -S GridServer -d -m mono OpenSim.Grid.GridServer.exe
+
sleep 3
+
screen -S AssetServer -d -m mono OpenSim.Grid.AssetServer.exe
+
sleep 3
+
screen -S InventoryServer -d -m mono OpenSim.Grid.InventoryServer.exe
+
sleep 3
+
screen -S OpenSim -d -m mono OpenSim.exe -gridmode=true
+
 
+
===Startup and access servers===
+
./runsim.sh
+
 
+
If you have permission issues
+
chmod 755 runsim.sh
+
 
+
To see a list of the servers in screen:
+
screen -ls or screen -list
+
 
+
Output will look like the following:
+
There are screens on:
+
      8419.OpenSim  (Detached)
+
      8403.InventoryServer  (Detached)
+
      8378.AssetServer  (Detached)
+
      8360.GridServer  (Detached)
+
      8347.UserServer  (Detached)
+
 
+
To access server
+
screen -r 8419.OpenSim
+
screen -r 8403.InventoryServer
+
etc.
+
 
+
To exit screen, leaving server running, and to return to shell
+
ctrl-a d
+
 
+
===Shutdown Servers===
+
Either manually access each sceen
+
screen -r 8419.OpenSim
+
shutdown
+
 
+
Or use
+
killall mono
+
Or
+
for i in `ps afxu | grep -i "mono.*OpenSim" | grep -v grep | awk {'print $2'}`; do kill $i; done
+
 
+
Or to shut down each session clean, make a stop script, stopgrid.sh
+
#!/bin/bash
+
screen -S InventoryServer -X eval "stuff shutdown^M"
+
sleep 5
+
screen -S AssetServer -X eval "stuff shutdown^M"
+
sleep 5
+
screen -S GridServer -X eval "stuff shutdown^M"
+
sleep 5
+
screen -S UserServer -X eval "stuff shutdown^M"
+
This depends on the screen NAME to be the same as in the startup script described above!
+
--[[User:Suz|Suz]] 01:42, 18 May 2008 (PDT)
+

Latest revision as of 00:47, 20 March 2021

Contents

[edit] Automated Grid Startup

[edit] Linux/Mac OS X

[edit] See

[edit] Basic scripts

  • Use Screen Command

Use the screen command to automate startup

  • Setup screen command and setup shell file

Linux install:

apt-get install screen (ubuntu)
pacman -S screen (archlinux)

Mac OS X: Download either MacPorts, http://www.macports.org/, or Fink, http://www.finkproject.org/ to download *nix packages MacPorts

sudo port install screen

Fink

  • Create file runsim.sh
#!/bin/sh
cd opensim/bin
screen -S Robust -d -m  mono OpenSim.Robust.exe
sleep 10
screen -S OpenSimulator -d -m mono OpenSim.exe -gridmode=true

See Also --> Smart Prestart LINUX

  • Bash Scripts:
  • Start multiple instances and backup critical files prior to startup
  • Automated Shutdown of multiple instances with a 2 minute pre-warning to users in-world.
  • NB This can be used to stuff other functions into OpenSimulator Console as well.

[edit] Startup and access servers

./runsim.sh

If you have permission issues

chmod 755 runsim.sh

To see a list of the servers in screen:

screen -ls or screen -list

Output will look like the following:

There are screens on:
     8419.OpenSim  (Detached)
     8403.Robust  (Detached)

To access server

screen -r 8419.OpenSim
screen -r 8403.Robust

To exit screen, leaving server running, and to return to shell

ctrl-a d

[edit] osstart.sh

example: osstart.sh OpenSim

(Directory name = screen name)

Real examples:

/opt/osstart.sh sim1

/opt/osstart.sh sim2

/opt/osstart.sh sim3

/opt/osstart.sh sim...

#!/bin/bash
sleep 3
if [ -d $1 ]; then
  echo "$(tput setaf 4)OpenSim: $(tput setab 7)$1 Start$(tput sgr 0)"
  cd /opt/$1/bin
  screen -fa -S $1 -d -U -m mono OpenSim.exe
else
  echo "$(tput setaf 2)The following screens were started$(tput sgr 0)"
  screen -ls
   exit 1
fi

[edit] osgridstart.sh

#!/bin/bash
sleep 3
robust="/opt/robust/"
if [ -d "$robust" ]; then
  # Take action if $robust exists. #
  echo "$(tput setaf 4)OpenSim: $(tput setab 3)RobustServer Start$(tput sgr 0)"
  cd /opt/robust/bin
  screen -fa -S RO -d -U -m mono Robust.exe
else
  echo "$(tput setaf 2)The following screens were started $(tput sgr 0)RO $(tput setaf 2)and $(tput sgr 0)OS$(tput setaf 2).$(tput sgr 0)"
  screen -ls
   exit 1
fi
sleep 10
money="/opt/robust/"
if [ -d "$money" ]; then
  # Take action if $robust exists. #
  echo "$(tput setaf 4)OpenSim: $(tput setab 3)MoneyServer Start$(tput sgr 0)"
  cd /opt/robust/bin
  screen -fa -S MO -d -U -m mono MoneyServer.exe
else
  echo "$(tput setaf 2)The following screens were started $(tput sgr 0)RO $(tput setaf 2)and $(tput sgr 0)OS$(tput setaf 2).$(tput sgr 0)"
  screen -ls
   exit 1
fi
cd /opt
# echo " Wait 40 seconds and then start regions."
sleep 40
echo "$(tput setaf 2)OpenSim: $(tput setab 0)Welcome Region start$(tput sgr 0)"
/opt/osstart.sh sim1
echo "$(tput setaf 2)OpenSim: $(tput setab 0)Start all other regions$(tput sgr 0)"
/opt/osstart.sh sim2
/opt/osstart.sh sim3
/opt/osstart.sh sim4
/opt/osstart.sh sim5
/opt/osstart.sh sim6
/opt/osstart.sh sim7
/opt/osstart.sh sim8
/opt/osstart.sh sim9
/opt/osstart.sh sim10
echo "$(tput setaf 2)List started screens$(tput sgr 0)"
screen -ls

[edit] Shutdown Servers

Either manually access each sceen

screen -r 8419.OpenSim
shutdown

Or

screen -S OpenSim -p 0 -X eval "stuff 'shutdown'^M"

Or use (only in the event of a crash!)

killall screen

Or

for i in `ps afxu | grep -i "mono.*OpenSim" | grep -v grep | awk {'print $2'}`; do kill $i; done

Or to shut down each session clean, make a stop script, stopgrid.sh

#!/bin/bash
screen -S Robust -X quit
sleep 10
screen -S OpenSim -X quit

[edit] osstop.sh

example: osstop.sh OpenSim

(Directory name = screen name)

real example:

/opt/osstop.sh sim1

/opt/osstop.sh sim2

/opt/osstop.sh sim...

#!/bin/bash
sleep 10
if screen -list | grep -q $1; then
  echo "$(tput setaf 1)OpenSim: $(tput setab 7)Regionen OpenSimulator $1 Beenden$(tput sgr 0)"
  screen -S $1 -p 0 -X eval "stuff 'shutdown'^M"
else
  echo "$(tput setaf 1)OpenSim: $(tput setab 7)Regionen OpenSimulator $1 nicht vorhanden$(tput sgr 0)"
fi


[edit] osgridstop.sh

#!/bin/bash
sleep 3
echo "$(tput setaf 1)OpenSim: $(tput setab 6)Stop regions$(tput sgr 0)"
/opt/osstop.sh sim2
/opt/osstop.sh sim3
/opt/osstop.sh sim4
/opt/osstop.sh sim5
/opt/osstop.sh sim6
/opt/osstop.sh sim7
/opt/osstop.sh sim8
/opt/osstop.sh sim9
/opt/osstop.sh sim10
sleep 30
echo "$(tput setaf 1)OpenSim: $(tput setab 6)Stop the Welcome Region$(tput sgr 0)"
/opt/osstop.sh sim1
if screen -list | grep -q "MO"; then
  echo "$(tput setaf 1)OpenSim: $(tput setab 3)Exit MoneyServer$(tput sgr 0)"
  screen -S MO -p 0 -X eval "stuff 'shutdown'^M"
else
  echo "$(tput setaf 1)OpenSim: $(tput setab 3)MoneyServer does not exist$(tput sgr 0)"
fi
sleep 30
if screen -list | grep -q "RO"; then
  echo "$(tput setaf 1)OpenSim: $(tput setab 3)Exit RobustServer$(tput sgr 0)"
  screen -S RO -p 0 -X eval "stuff 'shutdown'^M"
else
  echo "$(tput setaf 1)OpenSim: $(tput setab 3)RobustServer does not exist$(tput sgr 0)"
fi
sleep 30
echo " List screens"
screen -ls
echo "$(tput setaf 1)$(tput setab 7)Wait 60 seconds and then kill all open screens$(tput sgr 0)"
sleep 60
killall screen

[edit] oslogdel.sh

deletes log files (unfortunately the log files get unbearably large.)

example: oslogdel.sh OpenSim

real example:

/opt/oslogdel.sh robust

/opt/oslogdel.sh sim1

/opt/oslogdel.sh sim2

/opt/oslogdel.sh sim...

#!/bin/bash
sleep 3
cd /opt
if [ -d $1 ]; then
  echo "$(tput setaf 1)OpenSim: $(tput setab 7)log $1 deleted$(tput sgr 0)"
  cd /opt/$1/bin
  # echo "/opt/$1/bin"
  rm *.log
else
  echo "$(tput setaf 1)logs not found $(tput sgr 0)"
  exit 1
fi

[edit] Simulator Watchdog

Watches the simulator process under Linux

Adding an entry to call a simple script to check the process table can restart regions that crash to the command line. Here User_talk:BlueWall is a script to accomplish this with a sample cron entry for one minute intervals. While it will not fix 100% of the crashes, it will get most cases, and help keep the grid healthy. If you have questions, you can usually find me on irc.freenode.net #opensim or #osgrid

--BlueWall 15:53, 19 June 2008 (PDT)

[edit] Automate Updates

[edit] Linux (CentOS-5)

This script will save your settings, grab the latest release of OpenSim, build OpenSim, and restore your settings to the new release. It creates the new release in a new directory allowing you to revert to the previous release by just changing the 'current' link to point to whichever release you want to run.

Note: This may not work well if updating from versions that are quite far apart. Minor updates should work well. Sometimes you have to clear out the SAVEDIR to prevent very old files from messing up a new update.

This script assumes you are using the SVN release number as the OpenSimulator directory with a link called 'current' pointing to it. So, you might, for example, have a directory called '/home/opensim/7577' and a link 'current -> 7577'. This script also uses a save folder for moving settings from the old release to the new.

You will also want to compare the 'OpenSim.ini' and the 'OpenSim.ini.example' by hand after running this update script. There are often changes in this file needed for the new release. The 'diff -bB' command helps a lot in this comparison.

#!/bin/bash -x

CWD=`pwd`
MWD="/home/opensim"  # Main Working Directory
SAVEDIR="$MWD/save"  # Save Directory

if [ ! -d $SAVEDIR ]; then mkdir $SAVEDIR; fi
if [ ! -d $SAVEDIR/Regions ]; then mkdir $SAVEDIR/Regions; fi
if [ ! -d $SAVEDIR/DataSnapshot ]; then mkdir $SAVEDIR/DataSnapshot; fi
if [ ! -d $SAVEDIR/config-include ]; then mkdir $SAVEDIR/config-include; fi

cd $MWD

# save current settings
cp current/bin/*.xml $SAVEDIR
cp current/bin/*.db $SAVEDIR
cp current/bin/*.ini $SAVEDIR
cp current/bin/config-include/*.ini $SAVEDIR/config-include/
cp current/bin/Regions/*xml $SAVEDIR/Regions/
cp current/bin/DataSnapshot/*xml $SAVEDIR/DataSnapshot/

# Get fresh copy of OpenSimulator
REV=`svn info http://opensimulator.org/svn/opensim/trunk | fgrep Revision | awk '{print $2}'`
svn -r $REV co http://opensimulator.org/svn/opensim/trunk $REV
rm current
ln -s $REV current
cd current
./runprebuild.sh
nant
cd bin
# restore settings
if [ ! -d ./DataSnapshot ]; then mkdir ./DataSnapshot; fi
cp $SAVEDIR/*.xml .
cp $SAVEDIR/*.db .
cp $SAVEDIR/*.ini .
cp $SAVEDIR/config-include/* config-include/
cp $SAVEDIR/Regions/* Regions/
cp $SAVEDIR/DataSnapshot/* DataSnapshot/
cd $MWD
cd current
#
cd $CWD

[edit] Windows

Create a batch file to start up your grid, e.g. startGrid.bat ;

 @Echo OFF

For /F "Usebackq" %%i In (`Tasklist ^| Find /C "OpenSim"`) Do If /I %%i GTR 0 Echo There are %%i OpenSimulator processes running already. I quit! & Goto END

:: %PROGRAMFILES% expands to your normal application path
:: On an English system this is normally C:\Program Files
:: If you run a 64-bit Windows, with OpenSimulator as a 32-bit
:: application, substitute with %PROGRAMFILES(X86)%

Echo Starting Robust Server...
start "Robust" /MIN /D "%PROGRAMFILES%\OpenSim" OpenSim.Robust.exe
sleep 5
Echo Starting Region Server...
start "RegionServer" /MIN /D "%PROGRAMFILES%\OpenSim" OpenSim.exe -gridmode=true

:END

PS! Check that you have sleep command installed, I'm unsure if all Windows versions have that.
If sleep is not installed one can use a localhost ping instead to replace "sleep 3".

PING -n 4 127.0.0.1>nul

This knowledgebase article describes how to add a batch file to startup of Windows (before logon).
http://support.microsoft.com/kb/q243486/
Note that you have to start all applications and answer the configuration questions once before adding it to any startup.

If you start the server before logon then there will be no window to close if you want to shut down the server, so you can create a "StopGrid.BAT" with:

taskkill /FI "IMAGENAME eq OpenSim.*"
sleep 3
taskkill /FI "IMAGENAME eq OpenSim.*"
sleep 3
taskkill /F /FI "IMAGENAME eq OpenSim.*"

Or a more advanced batch that shut server processes down in the opposite order as recommended in the manual.

@Echo OFF

For /F "Usebackq" %%i In (`Tasklist ^| Find /C "OpenSim"`) Do If /I %%i EQU 0 Echo There are no OpenSimulator processes running. Nothing to stop.. & Goto END


Echo Stopping Region Server...
taskkill /T /IM OpenSim.exe > NUL 2>&1
If ERRORLEVEL 128 Echo Region Server was not running! & Echo. & Goto n1
:r1
If ERRORLEVEL 1 taskkill /T /F /IM OpenSim.exe > NUL 2>&1
If ERRORLEVEL 0 Echo Region Server stopped. & Echo. & Goto n1
Goto r1

:n1
Echo Stopping Robust Server...
taskkill /T /IM OpenSim.Grid.Robust.exe > NUL 2>&1
If ERRORLEVEL 128 Echo Robust Server was not running! & Echo. & Goto n2
:r2
If ERRORLEVEL 1 taskkill /T /F /IM OpenSim.Grid.Robust.exe > NUL 2>&1
If ERRORLEVEL 0 Echo Robust Server stopped. & Echo. & Goto n2
:END

[edit] See also

General
About This Wiki