diff options
author | David Walter Seikel | 2016-12-09 15:26:31 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-12-09 15:26:31 +1000 |
commit | b9be46dd0e3919da221c0f8dc02155f83495c22b (patch) | |
tree | ebff7b92a0d76b9e0ff7974b98ab2b2b80858921 | |
parent | Only move the writable directories if they haven't been moved yet. (diff) | |
download | opensim-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-x | scripts/create_sim.sh | 89 |
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 | |||
3 | NAME=$1 | ||
4 | LOCATION=$2 | ||
5 | URL=$3 | ||
6 | IP=$4 | ||
7 | SIZE=$5 | ||
8 | |||
9 | |||
10 | OSPATH="/opt/opensim" | ||
11 | cd $OSPATH/config | ||
12 | |||
13 | k=0 | ||
14 | for i in $(seq 50 99) | ||
15 | do | ||
16 | j=$(printf "sim%02d" $i) | ||
17 | if [ -e "$j" ] | ||
18 | then | ||
19 | k=$i | ||
20 | fi | ||
21 | done | ||
22 | |||
23 | if [ "x$NAME" = "x" ] | ||
24 | then | ||
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." | ||
27 | fi | ||
28 | # Sanitize the name. Not removing [ or ], couldn't get that to work, only important for Windows. | ||
29 | sim=$(echo "${NAME}" | sed -e 's/[\\/:\*\?"<>\|@#$%&\0\x01-\x1F\x27\x40\x60\x7F. ]/_/g' -e 's/^$/NONAME/') | ||
30 | |||
31 | if [ "x$LOCATION" = "x" ] | ||
32 | then | ||
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." | ||
35 | fi | ||
36 | |||
37 | if [ "x$IP" = "x" ] | ||
38 | then | ||
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. | ||
44 | fi | ||
45 | |||
46 | # Here we make use of an external IP finding service. Careful, it may move. | ||
47 | if [ "x$URL" = "x" ] | ||
48 | then | ||
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." | ||
52 | fi | ||
53 | |||
54 | if [ "x$SIZE" = "x" ] | ||
55 | then | ||
56 | SIZE="256" | ||
57 | fi | ||
58 | |||
59 | NUM=$(printf "%02d" $(($k + 1)) ) | ||
60 | PORT=$(( 9005 + ($k * 5) )) # 9002 is used for HTTP/UDP so START with port 9003! CAUTION Diva/D2 starts at port 9000. | ||
61 | UUID=$(uuidgen) | ||
62 | |||
63 | echo "Creating sim$NUM on port $PORT @ $LOCATION - $NAME." | ||
64 | |||
65 | cp -r sim_skeleton sim$NUM | ||
66 | |||
67 | cd sim$NUM | ||
68 | mv My_sim.xml ${sim}.xml | ||
69 | sed -i "s@SIM_NAME@$NAME@g" ${sim}.xml | ||
70 | sed -i "s@SIM_UUID@$UUID@g" ${sim}.xml | ||
71 | sed -i "s@SIM_POS@$LOCATION@g" ${sim}.xml | ||
72 | sed -i "s@SIM_IP@$IP@g" ${sim}.xml | ||
73 | sed -i "s@SIM_INT_PORT@$(( $PORT + 1 ))@g" ${sim}.xml | ||
74 | sed -i "s@SIM_URL@$URL@g" ${sim}.xml | ||
75 | sed -i "s@SIM_SIZE@$SIZE@g" ${sim}.xml | ||
76 | |||
77 | ln -s ../../current/scripts/common.sh common.sh | ||
78 | ln -s ../../current/scripts/start-sim start-sim | ||
79 | cp -P start-sim backup-sim | ||
80 | cp -P start-sim stop-sim | ||
81 | |||
82 | sed -i "s@SIM_NUMBER@$NUM@g" ThisSim.ini | ||
83 | sed -i "s@SIM_PORT@$PORT@g" ${sim}.xml | ||
84 | |||
85 | |||
86 | cp ../../current/scripts/opensim-monit.conf opensim-monit.conf | ||
87 | sed -i "s@SIM_NUMBER@$NUM@g" opensim-monit.conf | ||
88 | sudo chown -R opensim:opensim .. | ||
89 | sudo chmod -R g+w .. | ||