diff options
Diffstat (limited to 'create_region.sh')
| -rwxr-xr-x | create_region.sh | 84 |
1 files changed, 84 insertions, 0 deletions
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 | |||
