aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/scripts/install/create_sim.sh
diff options
context:
space:
mode:
authoronefang2019-05-21 04:41:57 +1000
committeronefang2019-05-21 04:41:57 +1000
commit8723177732fe0843116a81b5c935cb440799e243 (patch)
tree94b2018d492c321c6ae69c79e812353a1d831fbf /scripts/install/create_sim.sh
parentTypo-- (diff)
downloadopensim-SC_OLD-8723177732fe0843116a81b5c935cb440799e243.zip
opensim-SC_OLD-8723177732fe0843116a81b5c935cb440799e243.tar.gz
opensim-SC_OLD-8723177732fe0843116a81b5c935cb440799e243.tar.bz2
opensim-SC_OLD-8723177732fe0843116a81b5c935cb440799e243.tar.xz
Move install related scripts and stuff into their own directory.
Diffstat (limited to 'scripts/install/create_sim.sh')
-rwxr-xr-xscripts/install/create_sim.sh96
1 files changed, 96 insertions, 0 deletions
diff --git a/scripts/install/create_sim.sh b/scripts/install/create_sim.sh
new file mode 100755
index 0000000..0681067
--- /dev/null
+++ b/scripts/install/create_sim.sh
@@ -0,0 +1,96 @@
1#!/bin/bash
2
3source common.sh
4getPrgDir
5
6NAME=$1
7LOCATION=$2
8URL=$3
9IP=$4
10SIZE=$5
11
12OSPATH="/opt/opensim"
13cd $OSPATH/config
14
15k=0
16for i in $(seq -w 1 99)
17do
18 j=$(num2name "$i")
19 if [ -e "$j" ]
20 then
21 k=$i
22 fi
23done
24
25if [ "x$NAME" = "x" ]
26then
27 NAME="No name sim $RANDOM" # Should be unique per grid.
28 echo "WARNING setting the sim name to [$NAME], this may not be what you want."
29fi
30# Sanitize the name. Not removing [ or ], couldn't get that to work, only important for Windows.
31sim=$(sanitize $NAME)
32
33if [ "x$LOCATION" = "x" ]
34then
35 LOCATION="$RANDOM,$RANDOM" # again UNIQUE (i.e. ONLY ONE) per grid in THIS case!
36 echo "WARNING setting the Location to $LOCATION, this may not be what you want."
37fi
38
39if [ "x$IP" = "x" ]
40then
41 # 0.0.0.0 will work for a single sim per physical machine, otherwise we need the real internal IP.
42 IP="0.0.0.0"
43 echo "WARNING setting the InternalAddress to $IP, this may not be what you want."
44# echo " 0.0.0.0 will work for a single sim per physical machine, otherwise we need the real internal IP."
45# According to the OpenSim docs, 0.0.0.0 means to listen on all NICs the machine has, which should work fine.
46fi
47
48if [ "x$URL" = "x" ]
49then
50# Here we make use of an external IP finding service. Careful, it may move.
51# 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.
52 URL="SYSTEMIP"
53 echo "WARNING setting the ExternalHostName to $URL, this may not be what you want."
54fi
55
56if [ "x$SIZE" = "x" ]
57then
58 SIZE="256"
59fi
60
61# Wow, the hoops we have to jump through to avoid octal.
62if [ 9 -gt $k ]; then
63 NUM=$(printf '0%1s' $(( 10#$k + 1 )) )
64else
65 NUM=$(printf '%2s' $(( 10#$k + 1 )) )
66fi
67
68PORT=$(( 9005 + (10#$k * 5) )) # 9002 is used for HTTP/UDP so START with port 9003! CAUTION Diva/D2 starts at port 9000.
69UUID=$(uuidgen)
70
71echo "Creating sim$NUM on port $PORT @ $LOCATION - $NAME."
72
73cp -r sim_skeleton sim$NUM
74
75cd sim$NUM
76mv My_sim.xml ${sim}.xml
77sed -i "s@SIM_NAME@$NAME@g" ${sim}.xml
78sed -i "s@SIM_UUID@$UUID@g" ${sim}.xml
79sed -i "s@SIM_POS@$LOCATION@g" ${sim}.xml
80sed -i "s@SIM_IP@$IP@g" ${sim}.xml
81sed -i "s@SIM_INT_PORT@$(( $PORT + 1 ))@g" ${sim}.xml
82sed -i "s@SIM_URL@$URL@g" ${sim}.xml
83sed -i "s@SIM_SIZE@$SIZE@g" ${sim}.xml
84
85ln -s ../../current/scripts/common.sh common.sh
86ln -s ../../current/scripts/start-sim start-sim
87cp -P start-sim backup-sim
88cp -P start-sim stop-sim
89
90sed -i "s@SIM_NUMBER@$NUM@g" ThisSim.ini
91sed -i "s@SIM_PORT@$PORT@g" ThisSim.ini
92
93sed -i "s@SIM_NUMBER@$NUM@g" opensim-monit.conf
94
95sudo chown -R opensim:opensim ..
96sudo chmod -R g+w ..