aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-12-09 15:26:31 +1000
committerDavid Walter Seikel2016-12-09 15:26:31 +1000
commitb9be46dd0e3919da221c0f8dc02155f83495c22b (patch)
treeebff7b92a0d76b9e0ff7974b98ab2b2b80858921
parentOnly move the writable directories if they haven't been moved yet. (diff)
downloadopensim-SC_OLD-b9be46dd0e3919da221c0f8dc02155f83495c22b.zip
opensim-SC_OLD-b9be46dd0e3919da221c0f8dc02155f83495c22b.tar.gz
opensim-SC_OLD-b9be46dd0e3919da221c0f8dc02155f83495c22b.tar.bz2
opensim-SC_OLD-b9be46dd0e3919da221c0f8dc02155f83495c22b.tar.xz
Script to create a sim. I should test it.
-rwxr-xr-xscripts/create_sim.sh89
1 files changed, 89 insertions, 0 deletions
diff --git a/scripts/create_sim.sh b/scripts/create_sim.sh
new file mode 100755
index 0000000..d82dcc7
--- /dev/null
+++ b/scripts/create_sim.sh
@@ -0,0 +1,89 @@
1#!/bin/bash
2
3NAME=$1
4LOCATION=$2
5URL=$3
6IP=$4
7SIZE=$5
8
9
10OSPATH="/opt/opensim"
11cd $OSPATH/config
12
13k=0
14for i in $(seq 50 99)
15do
16 j=$(printf "sim%02d" $i)
17 if [ -e "$j" ]
18 then
19 k=$i
20 fi
21done
22
23if [ "x$NAME" = "x" ]
24then
25 NAME="No name sim $RANDOM" # Should be unique per grid.
26 echo "WARNING setting the sim name to [$NAME], this may not be what you want."
27fi
28# Sanitize the name. Not removing [ or ], couldn't get that to work, only important for Windows.
29sim=$(echo "${NAME}" | sed -e 's/[\\/:\*\?"<>\|@#$%&\0\x01-\x1F\x27\x40\x60\x7F. ]/_/g' -e 's/^$/NONAME/')
30
31if [ "x$LOCATION" = "x" ]
32then
33 LOCATION="$RANDOM,$RANDOM" # again UNIQUE (i.e. ONLY ONE) per grid in THIS case!
34 echo "WARNING setting the Location to $LOCATION, this may not be what you want."
35fi
36
37if [ "x$IP" = "x" ]
38then
39 # 0.0.0.0 will work for a single sim per physical machine, otherwise we need the real internal IP.
40 IP="0.0.0.0"
41 echo "WARNING setting the InternalAddress to $IP, this may not be what you want."
42# echo " 0.0.0.0 will work for a single sim per physical machine, otherwise we need the real internal IP."
43# According to the OpenSim docs, 0.0.0.0 means to listen on all NICs the machine has, which should work fine.
44fi
45
46# Here we make use of an external IP finding service. Careful, it may move.
47if [ "x$URL" = "x" ]
48then
49# 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.
50 URL="SYSTEMIP"
51 echo "WARNING setting the ExternalHostName to $URL, this may not be what you want."
52fi
53
54if [ "x$SIZE" = "x" ]
55then
56 SIZE="256"
57fi
58
59NUM=$(printf "%02d" $(($k + 1)) )
60PORT=$(( 9005 + ($k * 5) )) # 9002 is used for HTTP/UDP so START with port 9003! CAUTION Diva/D2 starts at port 9000.
61UUID=$(uuidgen)
62
63echo "Creating sim$NUM on port $PORT @ $LOCATION - $NAME."
64
65cp -r sim_skeleton sim$NUM
66
67cd sim$NUM
68mv My_sim.xml ${sim}.xml
69sed -i "s@SIM_NAME@$NAME@g" ${sim}.xml
70sed -i "s@SIM_UUID@$UUID@g" ${sim}.xml
71sed -i "s@SIM_POS@$LOCATION@g" ${sim}.xml
72sed -i "s@SIM_IP@$IP@g" ${sim}.xml
73sed -i "s@SIM_INT_PORT@$(( $PORT + 1 ))@g" ${sim}.xml
74sed -i "s@SIM_URL@$URL@g" ${sim}.xml
75sed -i "s@SIM_SIZE@$SIZE@g" ${sim}.xml
76
77ln -s ../../current/scripts/common.sh common.sh
78ln -s ../../current/scripts/start-sim start-sim
79cp -P start-sim backup-sim
80cp -P start-sim stop-sim
81
82sed -i "s@SIM_NUMBER@$NUM@g" ThisSim.ini
83sed -i "s@SIM_PORT@$PORT@g" ${sim}.xml
84
85
86cp ../../current/scripts/opensim-monit.conf opensim-monit.conf
87sed -i "s@SIM_NUMBER@$NUM@g" opensim-monit.conf
88sudo chown -R opensim:opensim ..
89sudo chmod -R g+w ..