aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2011-11-26 10:09:51 +1000
committerDavid Walter Seikel2011-11-26 10:09:51 +1000
commitebc84ad13f6d3f1911672b1a2d449d8cddf1ae2f (patch)
treeb25d5ce40da4019db2b7f1552eda19d91677365c
downloadIGnoble-ebc84ad13f6d3f1911672b1a2d449d8cddf1ae2f.zip
IGnoble-ebc84ad13f6d3f1911672b1a2d449d8cddf1ae2f.tar.gz
IGnoble-ebc84ad13f6d3f1911672b1a2d449d8cddf1ae2f.tar.bz2
IGnoble-ebc84ad13f6d3f1911672b1a2d449d8cddf1ae2f.tar.xz
First commit.
-rw-r--r--README62
-rwxr-xr-xcreate_region.sh84
-rwxr-xr-xgo_live.sh17
-rwxr-xr-xinstall_opensim.sh90
-rw-r--r--opensim-crontab.txt11
-rw-r--r--opensim-monit.conf34
-rwxr-xr-xstart-sim-in-rest43
7 files changed, 341 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..d0573db
--- /dev/null
+++ b/README
@@ -0,0 +1,62 @@
1Use this to create a sim that links into Infinite Grid from Linux.
2
3I'ts been tested on Umuntu 10.04, YMMV.
4
5Follow these steps.
6
7Go to -
8
9http://wiki.infinitegrid.org/index.php/Howto_Link_your_Opensim_region_to_Infinite_Grid
10
11and follow the directions to create an admin user account. You can skip
12that bit if you already have a suitable user with sudo access.
13
14Note that these scripts pretty much follow that above wiki description,
15with some exceptions. REST is used for console access, instead of
16screen. The configuration information per sim has been rearranged so
17that there is only ONE copy of the OpenSim installation.
18
19Next you need to figure out what password you want to use for OpenSims
20access to the database. We will call this "DatabasePassword". Run the
21following script -
22
23./install_opensim.sh DatabasePassword
24
25This will do most of the work fo you, except for creating sims. A
26separate script is here for sim creation, you can use it to create many
27sims. You will need -
28
29Your host name, or it could be your IP, we will use "sims.example.net".
30
31A name for your sim, we will use "My new sim". It should be unique on
32the grid.
33
34A location for your sim, we will use "1234,5678". You can use the
35Infinite Grid web based map to poke around and find a good location.
36Choose an empty spot.
37
38Optionally, you might need your IP address if you are creating more than
39one sim, we will use "1.2.3.4".
40
41Once you have all that information sorted out, run this script if ONLY
42hosting a single sim on this computer -
43
44./create_sim.sh "My new sim" "1234,5678" "sims.example.net"
45
46Or this if you plan on running more than one sim -
47
48./create_sim.sh "My new sim" "1234,5678" "sims.example.net" "1.2.3.4"
49
50No you can go to /opt/opensim/config/sim01 and run the following script
51to start it up -
52
53./start-sim-in-rest
54
55You will see the REST console. You can run the REST console again by
56running that command once more.
57
58Once it's all tested, you can use this to finish things off (back in
59this directory) -
60
61./go_live.sh
62
diff --git a/create_region.sh b/create_region.sh
new file mode 100755
index 0000000..f13eaef
--- /dev/null
+++ b/create_region.sh
@@ -0,0 +1,84 @@
1#!/bin/bash
2
3NAME=$1
4LOCATION=$2
5URL=$3
6IP=$4
7
8cd /opt/opensim/config
9
10k=0
11for i in $(seq 99)
12do
13 j=$(printf "sim%02d" $i)
14 if [ -e "$j" ]
15 then
16 k=$i
17 fi
18done
19
20if [ "x$NAME" = "x" ]
21then
22 NAME="No name sim $RANDOM" # Should be unique per grid.
23fi
24
25if [ "x$LOCATION" = "x" ]
26then
27 LOCATION="$RANDOM,$RANDOM" # again UNIQUE (i.e. ONLY ONE) per grid in THIS case!
28fi
29
30if [ "x$URL" = "x" ]
31then
32 URL=$(hostname) # URL is best (without the HTTP://), but IP (e.g. 88.109.81.55) works too.
33fi
34
35if [ "x$IP" = "x" ]
36then
37 IP="0.0.0.0" # 0.0.0.0 will work for a single sim per physical machine, otherwise we need the real internal IP.
38fi
39
40NUM=$(printf "%02d" $(($k + 1)) )
41PORT=$(( 9005 + ($k * 5) )) # 9002 is used for HTTP/UDP so START with port 9003! CAUTION Diva/D2 starts at port 9000.
42UUID=$(uuidgen)
43
44echo "Creating sim$NUM on port $PORT @ $LOCATION - $NAME."
45
46mkdir -p sim$NUM/Regions
47cd sim$NUM
48cat > Regions/sim.ini << zzzzEOFzzzz
49[$NAME]
50RegionUUID = $UUID
51Location = $LOCATION
52InternalAddress = 0.0.0.0
53InternalPort = $(( $PORT + 1 ))
54AllowAlternatePorts = False
55ExternalHostName = $URL
56zzzzEOFzzzz
57
58ln -s ../../setup/start-sim-in-rest start-sim-in-rest
59#ln -s ../../current current
60cp ../../current/bin/OpenSim.exe.config OpenSim.exe.config
61sed -i "s@<file value=\"OpenSim.log\" />@<file value=\"/var/log/opensim/sim$NUM.log\" />@" OpenSim.exe.config
62
63#cp current/bin/OpenSim.ini OpenSim.ini
64#sed -i "s@regionload_regionsdir=\"/opt/opensim/config\"@regionload_regionsdir=\"/opt/opensim/config/sim$NUM/Regions\"@" OpenSim.ini
65#sed -i "s@; PIDFile = \"/var/run/opensim/opensim.pid\"@PIDFile = \"/var/run/opensim/sim$NUM.pid\"@" OpenSim.ini
66#sed -i "s@;http_listener_port = 9000@http_listener_port = $(( $PORT + 0))@" OpenSim.ini
67#sed -i "s@; console_port = 0@console_port = $(( $PORT + 2 ))@" OpenSim.ini
68
69cat > ThisSim.ini << zzzzEOFzzzz
70[Startup]
71 PIDFile = "/var/run/opensim/sim$NUM.pid"
72 regionload_regionsdir="/opt/opensim/config/sim$NUM/Regions"
73
74[Network]
75 console_port = $(( $PORT + 2 ))
76 http_listener_port = $(( $PORT + 0))
77zzzzEOFzzzz
78
79cp ../../current/bin/OpenSim.ConsoleClient.ini OpenSim.ConsoleClient.ini
80sed -i "s@; port = 9002@port = $(( $PORT + 2 ))@" OpenSim.ConsoleClient.ini
81
82cp ../../setup/opensim-monit.conf opensim-monit.conf
83sed -i "s@sim01@sim$NUM@g" opensim-monit.conf
84
diff --git a/go_live.sh b/go_live.sh
new file mode 100755
index 0000000..65e4a08
--- /dev/null
+++ b/go_live.sh
@@ -0,0 +1,17 @@
1#!/bin/bash
2
3for i in $(seq 99)
4do
5 j=$(printf "sim%02d" $i)
6 if [ -e "/opt/opensim/config/$j" ]
7 then
8 sudo chown -R opensim:opensim /opt/opensim/config/$j
9 sudo ln -s /opt/opensim/config/$j/opensim-monit.conf /etc/monit/conf.d/$j.conf
10 fi
11done
12
13sudo chmod 755 /var/log/opensim
14sudo chmod 755 /var/run/opensim
15sudo chown -R opensim:opensim /opt/opensim/opensim-0.7.1.1-infinitegrid-03
16sudo chown -R opensim:opensim /opt/opensim/modules
17
diff --git a/install_opensim.sh b/install_opensim.sh
new file mode 100755
index 0000000..0c8c659
--- /dev/null
+++ b/install_opensim.sh
@@ -0,0 +1,90 @@
1#!/bin/bash
2
3if [ x$1 = x ]
4then
5 MYSQL_PASSWORD="OpenSimSucks"
6else
7 MYSQL_PASSWORD=$1
8fi
9USER=$(whoami)
10
11sudo apt-get install mysql-server screen mono-complete monit mc
12sudo /etc/init.d/mysql restart
13
14echo "Setting up mySQL"
15mysql -u root -p -h localhost << zzzzEOFzzz
16drop database opensim;
17create database opensim;
18drop user opensim;
19drop user 'opensim'@'localhost';
20FLUSH PRIVILEGES;
21create user opensim identified by '$MYSQL_PASSWORD';
22create user 'opensim'@'localhost' identified by '$MYSQL_PASSWORD';
23grant all on opensim.* to opensim;
24grant all on opensim.* to 'opensim'@'localhost';
25FLUSH PRIVILEGES;
26zzzzEOFzzz
27
28echo "Setting up OpenSim"
29sudo deluser opensim
30sudo adduser --system --shell /bin/false --group opensim
31sudo mkdir -p /var/log/opensim
32sudo chown opensim:opensim /var/log/opensim
33sudo chmod 777 /var/log/opensim
34sudo mkdir -p /var/run/opensim
35sudo chown opensim:opensim /var/run/opensim
36sudo chmod 777 /var/run/opensim
37sudo mkdir -p /opt/opensim
38sudo chown $USER:$USER /opt/opensim
39
40cd /opt/opensim
41wget https://github.com/downloads/infinitegrid/InfiniteGrid-Opensim/opensim-0.7.1.1-infinitegrid-03.tar.bz2
42tar xjf opensim-0.7.1.1-infinitegrid-03.tar.bz2
43ln -s opensim-0.7.1.1-infinitegrid-03 current
44mkdir -p config
45mkdir -p modules
46mkdir -p setup
47cp setup/opensim-crontab.txt config
48cat setup/opensim-crontab.txt | sudo crontab -u opensim -
49
50cd current/bin
51mv OpenSim.Forge.Currency.dll ../../modules/
52ln -s ../../modules/OpenSim.Forge.Currency.dll OpenSim.Forge.Currency.dll
53mv OpenSimSearch.Modules.dll ../../modules/
54ln -s ../../modules/OpenSimSearch.Modules.dll OpenSimSearch.Modules.dll
55mv NSLModules.Messaging.MuteList.dll ../../modules/
56ln -s ../../modules/NSLModules.Messaging.MuteList.dll NSLModules.Messaging.MuteList.dll
57mv OpenSimProfile.Modules.dll ../../modules/
58ln -s ../../modules/OpenSimProfile.Modules.dll OpenSimProfile.Modules.dll
59#sudo chown -R opensim:opensim ../../modules
60ln -s ../../config config
61
62cat > OpenSim.ConsoleClient.ini << zzzzEOFzzzz
63[Startup]
64 ; Set here or use the -user command-line switch
65 user = RestingUser
66
67 ; Set here or use the -host command-line switch
68 host = localhost
69
70 ; Set here or use the -port command-line switch
71 ; port = 9002
72
73 ; Set here or use the -pass command-line switch
74 ; Please be aware that this is not secure since the password is in the clear
75 ; we recommend the use of -pass wherever possible
76 pass = SecretRestingPLace
77zzzzEOFzzzz
78
79sed -i 's@<appender name="LogFileAppender" type="log4net.Appender.FileAppender">@<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">@' OpenSim.exe.config
80sed -i 's@; ConsoleUser = "Test"@ConsoleUser = "RestingUser"@' OpenSim.ini
81sed -i 's@; ConsolePass = "secret"@ConsolePass = "SecretRestingPlace"@' OpenSim.ini
82
83cd config-include/
84sed -i 's@Include-Storage = "config-include/storage/SQLiteStandalone.ini";@; Include-Storage = "config-include/storage/SQLiteStandalone.ini";@' GridCommon.ini
85sed -i 's@; StorageProvider = "OpenSim.Data.MySQL.dll"@StorageProvider = "OpenSim.Data.MySQL.dll"@' GridCommon.ini
86sed -i "s@; ConnectionString = \"Data Source=localhost;Database=opensim;User ID=opensim;Password=\*\*\*\*;\"@ConnectionString = \"Data Source=localhost;Database=opensim;User ID=opensim;Password=$MYSQL_PASSWORD;\"@" GridCommon.ini
87
88cd ../../..
89#sudo chown -R opensim:opensim opensim-0.7.1.1-infinitegrid-03
90
diff --git a/opensim-crontab.txt b/opensim-crontab.txt
new file mode 100644
index 0000000..ab694f7
--- /dev/null
+++ b/opensim-crontab.txt
@@ -0,0 +1,11 @@
1# to see current crontab for opensim
2# $ sudo crontab -u opensim -l
3#
4# to install this crontab for opensim:
5# $ cat /opt/opensim/config/opensim-crontab.txt | sudo crontab -u opensim -
6#
7# at midnight, remove old logs, files created 3 or more days ago
8#0 0 * * * find /var/log/opensim -ctime +1 -delete
9# experimental version using savelog -c cycles all opensim log files over 7 days
100 0 * * * /usr/bin/savelog -c 7 /var/log/opensim/*.log
11
diff --git a/opensim-monit.conf b/opensim-monit.conf
new file mode 100644
index 0000000..e300720
--- /dev/null
+++ b/opensim-monit.conf
@@ -0,0 +1,34 @@
1# manage the OpenSim process for Your Sim
2#
3# usage:
4# monit start your_sim
5# monit stop your_sim
6# monit restart your_sim
7#
8# see 'daemon' setting in /etc/monit/monitrc for the cycle length.
9# on ubuntu/debian, this is overridden by the CHECK_INTERVALS var in
10# /etc/default/monit . the below assumes you've set it to 30 seconds.
11#
12# if process dies, will restart sim within 30 seconds. if process
13# dies 5 times in as many tries, will stop trying and send email
14# alert.
15#
16# if SimFPS drops to 0 for 2 minutes, restart.
17#
18# if process CPU usage stays above 300% for 2 minutes, restart.
19#
20# see ../README for configuration instructions.
21#
22check process sim01 with pidfile /var/run/opensim/sim01.pid
23 start program = "/bin/bash -c 'cd /opt/opensim/config/sim01 && /opt/opensim/sim01/start-sim-in-rest'"
24 as uid opensim and gid opensim
25 stop program = "/bin/kill -9 `cat /var/run/opensim/sim01.pid`"
26# if cpu usage > 300% for 4 cycles then restart
27# if 5 restarts within 5 cycles then timeout
28# if failed url http://127.0.0.1:9005/jsonSimStats/
29# and content != '"SimFPS":0.0,' for 4 cycles
30# then restart
31# if failed url http://127.0.0.1:9008/jsonSimStats/
32# and content == '"SimFPS":' for 4 cycles
33# then restart
34
diff --git a/start-sim-in-rest b/start-sim-in-rest
new file mode 100755
index 0000000..d6aac2c
--- /dev/null
+++ b/start-sim-in-rest
@@ -0,0 +1,43 @@
1#!/bin/bash
2
3osversion="current"
4NeedARest=" -console=rest"
5NeedARest=""
6
7if [ x$1 = x ]; then
8 pathname=$(pwd)
9 tgt=$(basename $pathname)
10elif [ -d ./$1 ]; then
11 tgt=$1
12elif [ -d ./sim$1 ]; then
13 tgt=sim$1
14fi
15
16if [ x$tgt = x ]; then
17 echo "usage:"
18 echo " $ start-sim-in-rest <sim>"
19 echo "where <sim> is one of: " robust sim[0-9][0-9]
20 exit 1
21fi
22
23inidir=/opt/opensim/config/${tgt}
24bindir=/opt/opensim/${osversion}/bin
25if [ x$tgt = xrobust ]; then
26 exe="Robust"
27else
28 exe="OpenSim"
29fi
30
31if [ ! -e /var/run/opensim/${tgt} ]
32then
33 cd ${bindir}
34 /usr/bin/mono ${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config $NeedARest
35fi
36
37if [ "x$NeedARest" = x }
38then
39 echo "Starting rest client."
40 cd ${inidir}
41 /usr/bin/mono ${bindir}/OpenSim.ConsoleClient.exe -logconfig=${inidir}/${exe}.exe.config
42fi
43