diff options
-rw-r--r-- | README | 62 | ||||
-rwxr-xr-x | create_region.sh | 84 | ||||
-rwxr-xr-x | go_live.sh | 17 | ||||
-rwxr-xr-x | install_opensim.sh | 90 | ||||
-rw-r--r-- | opensim-crontab.txt | 11 | ||||
-rw-r--r-- | opensim-monit.conf | 34 | ||||
-rwxr-xr-x | start-sim-in-rest | 43 |
7 files changed, 341 insertions, 0 deletions
@@ -0,0 +1,62 @@ | |||
1 | Use this to create a sim that links into Infinite Grid from Linux. | ||
2 | |||
3 | I'ts been tested on Umuntu 10.04, YMMV. | ||
4 | |||
5 | Follow these steps. | ||
6 | |||
7 | Go to - | ||
8 | |||
9 | http://wiki.infinitegrid.org/index.php/Howto_Link_your_Opensim_region_to_Infinite_Grid | ||
10 | |||
11 | and follow the directions to create an admin user account. You can skip | ||
12 | that bit if you already have a suitable user with sudo access. | ||
13 | |||
14 | Note that these scripts pretty much follow that above wiki description, | ||
15 | with some exceptions. REST is used for console access, instead of | ||
16 | screen. The configuration information per sim has been rearranged so | ||
17 | that there is only ONE copy of the OpenSim installation. | ||
18 | |||
19 | Next you need to figure out what password you want to use for OpenSims | ||
20 | access to the database. We will call this "DatabasePassword". Run the | ||
21 | following script - | ||
22 | |||
23 | ./install_opensim.sh DatabasePassword | ||
24 | |||
25 | This will do most of the work fo you, except for creating sims. A | ||
26 | separate script is here for sim creation, you can use it to create many | ||
27 | sims. You will need - | ||
28 | |||
29 | Your host name, or it could be your IP, we will use "sims.example.net". | ||
30 | |||
31 | A name for your sim, we will use "My new sim". It should be unique on | ||
32 | the grid. | ||
33 | |||
34 | A location for your sim, we will use "1234,5678". You can use the | ||
35 | Infinite Grid web based map to poke around and find a good location. | ||
36 | Choose an empty spot. | ||
37 | |||
38 | Optionally, you might need your IP address if you are creating more than | ||
39 | one sim, we will use "1.2.3.4". | ||
40 | |||
41 | Once you have all that information sorted out, run this script if ONLY | ||
42 | hosting a single sim on this computer - | ||
43 | |||
44 | ./create_sim.sh "My new sim" "1234,5678" "sims.example.net" | ||
45 | |||
46 | Or 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 | |||
50 | No you can go to /opt/opensim/config/sim01 and run the following script | ||
51 | to start it up - | ||
52 | |||
53 | ./start-sim-in-rest | ||
54 | |||
55 | You will see the REST console. You can run the REST console again by | ||
56 | running that command once more. | ||
57 | |||
58 | Once it's all tested, you can use this to finish things off (back in | ||
59 | this 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 | |||
3 | NAME=$1 | ||
4 | LOCATION=$2 | ||
5 | URL=$3 | ||
6 | IP=$4 | ||
7 | |||
8 | cd /opt/opensim/config | ||
9 | |||
10 | k=0 | ||
11 | for i in $(seq 99) | ||
12 | do | ||
13 | j=$(printf "sim%02d" $i) | ||
14 | if [ -e "$j" ] | ||
15 | then | ||
16 | k=$i | ||
17 | fi | ||
18 | done | ||
19 | |||
20 | if [ "x$NAME" = "x" ] | ||
21 | then | ||
22 | NAME="No name sim $RANDOM" # Should be unique per grid. | ||
23 | fi | ||
24 | |||
25 | if [ "x$LOCATION" = "x" ] | ||
26 | then | ||
27 | LOCATION="$RANDOM,$RANDOM" # again UNIQUE (i.e. ONLY ONE) per grid in THIS case! | ||
28 | fi | ||
29 | |||
30 | if [ "x$URL" = "x" ] | ||
31 | then | ||
32 | URL=$(hostname) # URL is best (without the HTTP://), but IP (e.g. 88.109.81.55) works too. | ||
33 | fi | ||
34 | |||
35 | if [ "x$IP" = "x" ] | ||
36 | then | ||
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. | ||
38 | fi | ||
39 | |||
40 | NUM=$(printf "%02d" $(($k + 1)) ) | ||
41 | PORT=$(( 9005 + ($k * 5) )) # 9002 is used for HTTP/UDP so START with port 9003! CAUTION Diva/D2 starts at port 9000. | ||
42 | UUID=$(uuidgen) | ||
43 | |||
44 | echo "Creating sim$NUM on port $PORT @ $LOCATION - $NAME." | ||
45 | |||
46 | mkdir -p sim$NUM/Regions | ||
47 | cd sim$NUM | ||
48 | cat > Regions/sim.ini << zzzzEOFzzzz | ||
49 | [$NAME] | ||
50 | RegionUUID = $UUID | ||
51 | Location = $LOCATION | ||
52 | InternalAddress = 0.0.0.0 | ||
53 | InternalPort = $(( $PORT + 1 )) | ||
54 | AllowAlternatePorts = False | ||
55 | ExternalHostName = $URL | ||
56 | zzzzEOFzzzz | ||
57 | |||
58 | ln -s ../../setup/start-sim-in-rest start-sim-in-rest | ||
59 | #ln -s ../../current current | ||
60 | cp ../../current/bin/OpenSim.exe.config OpenSim.exe.config | ||
61 | sed -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 | |||
69 | cat > 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)) | ||
77 | zzzzEOFzzzz | ||
78 | |||
79 | cp ../../current/bin/OpenSim.ConsoleClient.ini OpenSim.ConsoleClient.ini | ||
80 | sed -i "s@; port = 9002@port = $(( $PORT + 2 ))@" OpenSim.ConsoleClient.ini | ||
81 | |||
82 | cp ../../setup/opensim-monit.conf opensim-monit.conf | ||
83 | sed -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 | |||
3 | for i in $(seq 99) | ||
4 | do | ||
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 | ||
11 | done | ||
12 | |||
13 | sudo chmod 755 /var/log/opensim | ||
14 | sudo chmod 755 /var/run/opensim | ||
15 | sudo chown -R opensim:opensim /opt/opensim/opensim-0.7.1.1-infinitegrid-03 | ||
16 | sudo 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 | |||
3 | if [ x$1 = x ] | ||
4 | then | ||
5 | MYSQL_PASSWORD="OpenSimSucks" | ||
6 | else | ||
7 | MYSQL_PASSWORD=$1 | ||
8 | fi | ||
9 | USER=$(whoami) | ||
10 | |||
11 | sudo apt-get install mysql-server screen mono-complete monit mc | ||
12 | sudo /etc/init.d/mysql restart | ||
13 | |||
14 | echo "Setting up mySQL" | ||
15 | mysql -u root -p -h localhost << zzzzEOFzzz | ||
16 | drop database opensim; | ||
17 | create database opensim; | ||
18 | drop user opensim; | ||
19 | drop user 'opensim'@'localhost'; | ||
20 | FLUSH PRIVILEGES; | ||
21 | create user opensim identified by '$MYSQL_PASSWORD'; | ||
22 | create user 'opensim'@'localhost' identified by '$MYSQL_PASSWORD'; | ||
23 | grant all on opensim.* to opensim; | ||
24 | grant all on opensim.* to 'opensim'@'localhost'; | ||
25 | FLUSH PRIVILEGES; | ||
26 | zzzzEOFzzz | ||
27 | |||
28 | echo "Setting up OpenSim" | ||
29 | sudo deluser opensim | ||
30 | sudo adduser --system --shell /bin/false --group opensim | ||
31 | sudo mkdir -p /var/log/opensim | ||
32 | sudo chown opensim:opensim /var/log/opensim | ||
33 | sudo chmod 777 /var/log/opensim | ||
34 | sudo mkdir -p /var/run/opensim | ||
35 | sudo chown opensim:opensim /var/run/opensim | ||
36 | sudo chmod 777 /var/run/opensim | ||
37 | sudo mkdir -p /opt/opensim | ||
38 | sudo chown $USER:$USER /opt/opensim | ||
39 | |||
40 | cd /opt/opensim | ||
41 | wget https://github.com/downloads/infinitegrid/InfiniteGrid-Opensim/opensim-0.7.1.1-infinitegrid-03.tar.bz2 | ||
42 | tar xjf opensim-0.7.1.1-infinitegrid-03.tar.bz2 | ||
43 | ln -s opensim-0.7.1.1-infinitegrid-03 current | ||
44 | mkdir -p config | ||
45 | mkdir -p modules | ||
46 | mkdir -p setup | ||
47 | cp setup/opensim-crontab.txt config | ||
48 | cat setup/opensim-crontab.txt | sudo crontab -u opensim - | ||
49 | |||
50 | cd current/bin | ||
51 | mv OpenSim.Forge.Currency.dll ../../modules/ | ||
52 | ln -s ../../modules/OpenSim.Forge.Currency.dll OpenSim.Forge.Currency.dll | ||
53 | mv OpenSimSearch.Modules.dll ../../modules/ | ||
54 | ln -s ../../modules/OpenSimSearch.Modules.dll OpenSimSearch.Modules.dll | ||
55 | mv NSLModules.Messaging.MuteList.dll ../../modules/ | ||
56 | ln -s ../../modules/NSLModules.Messaging.MuteList.dll NSLModules.Messaging.MuteList.dll | ||
57 | mv OpenSimProfile.Modules.dll ../../modules/ | ||
58 | ln -s ../../modules/OpenSimProfile.Modules.dll OpenSimProfile.Modules.dll | ||
59 | #sudo chown -R opensim:opensim ../../modules | ||
60 | ln -s ../../config config | ||
61 | |||
62 | cat > 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 | ||
77 | zzzzEOFzzzz | ||
78 | |||
79 | sed -i 's@<appender name="LogFileAppender" type="log4net.Appender.FileAppender">@<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">@' OpenSim.exe.config | ||
80 | sed -i 's@; ConsoleUser = "Test"@ConsoleUser = "RestingUser"@' OpenSim.ini | ||
81 | sed -i 's@; ConsolePass = "secret"@ConsolePass = "SecretRestingPlace"@' OpenSim.ini | ||
82 | |||
83 | cd config-include/ | ||
84 | sed -i 's@Include-Storage = "config-include/storage/SQLiteStandalone.ini";@; Include-Storage = "config-include/storage/SQLiteStandalone.ini";@' GridCommon.ini | ||
85 | sed -i 's@; StorageProvider = "OpenSim.Data.MySQL.dll"@StorageProvider = "OpenSim.Data.MySQL.dll"@' GridCommon.ini | ||
86 | sed -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 | |||
88 | cd ../../.. | ||
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 | ||
10 | 0 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 | # | ||
22 | check 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 | |||
3 | osversion="current" | ||
4 | NeedARest=" -console=rest" | ||
5 | NeedARest="" | ||
6 | |||
7 | if [ x$1 = x ]; then | ||
8 | pathname=$(pwd) | ||
9 | tgt=$(basename $pathname) | ||
10 | elif [ -d ./$1 ]; then | ||
11 | tgt=$1 | ||
12 | elif [ -d ./sim$1 ]; then | ||
13 | tgt=sim$1 | ||
14 | fi | ||
15 | |||
16 | if [ 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 | ||
21 | fi | ||
22 | |||
23 | inidir=/opt/opensim/config/${tgt} | ||
24 | bindir=/opt/opensim/${osversion}/bin | ||
25 | if [ x$tgt = xrobust ]; then | ||
26 | exe="Robust" | ||
27 | else | ||
28 | exe="OpenSim" | ||
29 | fi | ||
30 | |||
31 | if [ ! -e /var/run/opensim/${tgt} ] | ||
32 | then | ||
33 | cd ${bindir} | ||
34 | /usr/bin/mono ${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config $NeedARest | ||
35 | fi | ||
36 | |||
37 | if [ "x$NeedARest" = x } | ||
38 | then | ||
39 | echo "Starting rest client." | ||
40 | cd ${inidir} | ||
41 | /usr/bin/mono ${bindir}/OpenSim.ConsoleClient.exe -logconfig=${inidir}/${exe}.exe.config | ||
42 | fi | ||
43 | |||