aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/create_sim.sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xcreate_sim.sh110
1 files changed, 110 insertions, 0 deletions
diff --git a/create_sim.sh b/create_sim.sh
new file mode 100755
index 0000000..8f089fa
--- /dev/null
+++ b/create_sim.sh
@@ -0,0 +1,110 @@
1#!/bin/bash
2
3NAME=$1
4LOCATION=$2
5URL=$3
6IP=$4
7
8OSPATH="/opt/opensim"
9cd $OSPATH/config
10
11k=0
12for i in $(seq 99)
13do
14 j=$(printf "sim%02d" $i)
15 if [ -e "$j" ]
16 then
17 k=$i
18 fi
19done
20
21if [ "x$NAME" = "x" ]
22then
23 NAME="No name sim $RANDOM" # Should be unique per grid.
24 echo "WARNING setting the sim name to [$NAME], this may not be what you want."
25fi
26
27if [ "x$LOCATION" = "x" ]
28then
29 LOCATION="$RANDOM,$RANDOM" # again UNIQUE (i.e. ONLY ONE) per grid in THIS case!
30 echo "WARNING setting the Location to $LOCATION, this may not be what you want."
31fi
32
33if [ "x$IP" = "x" ]
34then
35 # 0.0.0.0 will work for a single sim per physical machine, otherwise we need the real internal IP.
36 IP="0.0.0.0"
37 echo "WARNING setting the InternalAddress to $IP, this may not be what you want."
38# echo " 0.0.0.0 will work for a single sim per physical machine, otherwise we need the real internal IP."
39# According to the OpenSim docs, 0.0.0.0 means to listen on all NICs the machine has, which should work fine.
40fi
41
42# Here we make use of an external IP finding service. Careful, it may move.
43if [ "x$URL" = "x" ]
44then
45 URL=$(wget -q http://automation.whatismyip.com/n09230945.asp -O -) # URL is best (without the HTTP://), but IP (e.g. 88.109.81.55) works too.
46 echo "WARNING setting the ExternalHostName to $URL, this may not be what you want."
47fi
48
49NUM=$(printf "%02d" $(($k + 1)) )
50PORT=$(( 9005 + ($k * 5) )) # 9002 is used for HTTP/UDP so START with port 9003! CAUTION Diva/D2 starts at port 9000.
51UUID=$(uuidgen)
52
53echo "Creating sim$NUM on port $PORT @ $LOCATION - $NAME."
54
55mkdir -p sim$NUM/Regions
56cd sim$NUM
57cat > Regions/sim.ini << zzzzEOFzzzz
58[$NAME]
59RegionUUID = $UUID
60Location = $LOCATION
61InternalAddress = $IP
62InternalPort = $(( $PORT + 1 ))
63AllowAlternatePorts = False
64ExternalHostName = $URL
65zzzzEOFzzzz
66
67ln -s ../../setup/start-sim start-sim
68cp start-sim stop-sim
69cp start-sim backup-sim
70cp start-sim sim-console
71cp ../../current/bin/OpenSim.exe.config OpenSim.exe.config
72sed -i 's@<appender name="LogFileAppender" type="log4net.Appender.FileAppender">@<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">@' OpenSim.exe.config
73sed -i "s@<file value=\"OpenSim.log\" />@<file value=\"/var/log/opensim/sim$NUM.log\" />@" OpenSim.exe.config
74
75cat > ThisSim.ini << zzzzEOFzzzz
76[Startup]
77 PIDFile = "/var/run/opensim/sim$NUM.pid"
78 regionload_regionsdir="$OSPATH/config/sim$NUM/Regions"
79 DecodedSculptMapPath = "caches/sim$NUM/j2kDecodeCache"
80
81[Network]
82 console_port = $(( $PORT + 2 ))
83 http_listener_port = $(( $PORT + 0))
84
85[AssetCache]
86 ;; Damn, this gets overidden later by the FlotsamCache.ini file.
87 ;; At least it says it can be shared by multiple instances.
88 ; CacheDirectory = "caches/sim$NUM/assetcache"
89
90[XEngine]
91 ScriptEnginesPath = "caches/sim$NUM/ScriptEngines"
92
93[GridService]
94 MapTileDirectory = "caches/sim$NUM/maptiles"
95
96[DataSnapshot]
97 snapshot_cache_directory = "caches/sim$NUM/DataSnapshot"
98
99[Includes]
100 Include-Common = config/common.ini
101
102zzzzEOFzzzz
103cp ../OpenSim.ConsoleClient.ini OpenSim.ConsoleClient.ini
104sed -i "s@; port = 9002@port = $(( $PORT + 2 ))@" OpenSim.ConsoleClient.ini
105
106cp ../../setup/opensim-monit.conf opensim-monit.conf
107sed -i "s@sim01@sim$NUM@g" opensim-monit.conf
108sudo chown -R opensim:opensim ..
109sudo chmod -R g+w ..
110