diff options
-rwxr-xr-x | scripts/create_sim.sh | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/scripts/create_sim.sh b/scripts/create_sim.sh index d82dcc7..0681067 100755 --- a/scripts/create_sim.sh +++ b/scripts/create_sim.sh | |||
@@ -1,21 +1,23 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | source common.sh | ||
4 | getPrgDir | ||
5 | |||
3 | NAME=$1 | 6 | NAME=$1 |
4 | LOCATION=$2 | 7 | LOCATION=$2 |
5 | URL=$3 | 8 | URL=$3 |
6 | IP=$4 | 9 | IP=$4 |
7 | SIZE=$5 | 10 | SIZE=$5 |
8 | 11 | ||
9 | |||
10 | OSPATH="/opt/opensim" | 12 | OSPATH="/opt/opensim" |
11 | cd $OSPATH/config | 13 | cd $OSPATH/config |
12 | 14 | ||
13 | k=0 | 15 | k=0 |
14 | for i in $(seq 50 99) | 16 | for i in $(seq -w 1 99) |
15 | do | 17 | do |
16 | j=$(printf "sim%02d" $i) | 18 | j=$(num2name "$i") |
17 | if [ -e "$j" ] | 19 | if [ -e "$j" ] |
18 | then | 20 | then |
19 | k=$i | 21 | k=$i |
20 | fi | 22 | fi |
21 | done | 23 | done |
@@ -26,7 +28,7 @@ then | |||
26 | echo "WARNING setting the sim name to [$NAME], this may not be what you want." | 28 | echo "WARNING setting the sim name to [$NAME], this may not be what you want." |
27 | fi | 29 | fi |
28 | # Sanitize the name. Not removing [ or ], couldn't get that to work, only important for Windows. | 30 | # 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/') | 31 | sim=$(sanitize $NAME) |
30 | 32 | ||
31 | if [ "x$LOCATION" = "x" ] | 33 | if [ "x$LOCATION" = "x" ] |
32 | then | 34 | then |
@@ -43,9 +45,9 @@ then | |||
43 | # According to the OpenSim docs, 0.0.0.0 means to listen on all NICs the machine has, which should work fine. | 45 | # According to the OpenSim docs, 0.0.0.0 means to listen on all NICs the machine has, which should work fine. |
44 | fi | 46 | fi |
45 | 47 | ||
46 | # Here we make use of an external IP finding service. Careful, it may move. | ||
47 | if [ "x$URL" = "x" ] | 48 | if [ "x$URL" = "x" ] |
48 | then | 49 | then |
50 | # Here we make use of an external IP finding service. Careful, it may move. | ||
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. | 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. |
50 | URL="SYSTEMIP" | 52 | URL="SYSTEMIP" |
51 | echo "WARNING setting the ExternalHostName to $URL, this may not be what you want." | 53 | echo "WARNING setting the ExternalHostName to $URL, this may not be what you want." |
@@ -56,8 +58,14 @@ then | |||
56 | SIZE="256" | 58 | SIZE="256" |
57 | fi | 59 | fi |
58 | 60 | ||
59 | NUM=$(printf "%02d" $(($k + 1)) ) | 61 | # Wow, the hoops we have to jump through to avoid octal. |
60 | PORT=$(( 9005 + ($k * 5) )) # 9002 is used for HTTP/UDP so START with port 9003! CAUTION Diva/D2 starts at port 9000. | 62 | if [ 9 -gt $k ]; then |
63 | NUM=$(printf '0%1s' $(( 10#$k + 1 )) ) | ||
64 | else | ||
65 | NUM=$(printf '%2s' $(( 10#$k + 1 )) ) | ||
66 | fi | ||
67 | |||
68 | PORT=$(( 9005 + (10#$k * 5) )) # 9002 is used for HTTP/UDP so START with port 9003! CAUTION Diva/D2 starts at port 9000. | ||
61 | UUID=$(uuidgen) | 69 | UUID=$(uuidgen) |
62 | 70 | ||
63 | echo "Creating sim$NUM on port $PORT @ $LOCATION - $NAME." | 71 | echo "Creating sim$NUM on port $PORT @ $LOCATION - $NAME." |
@@ -80,10 +88,9 @@ cp -P start-sim backup-sim | |||
80 | cp -P start-sim stop-sim | 88 | cp -P start-sim stop-sim |
81 | 89 | ||
82 | sed -i "s@SIM_NUMBER@$NUM@g" ThisSim.ini | 90 | sed -i "s@SIM_NUMBER@$NUM@g" ThisSim.ini |
83 | sed -i "s@SIM_PORT@$PORT@g" ${sim}.xml | 91 | sed -i "s@SIM_PORT@$PORT@g" ThisSim.ini |
84 | 92 | ||
85 | |||
86 | cp ../../current/scripts/opensim-monit.conf opensim-monit.conf | ||
87 | sed -i "s@SIM_NUMBER@$NUM@g" opensim-monit.conf | 93 | sed -i "s@SIM_NUMBER@$NUM@g" opensim-monit.conf |
94 | |||
88 | sudo chown -R opensim:opensim .. | 95 | sudo chown -R opensim:opensim .. |
89 | sudo chmod -R g+w .. | 96 | sudo chmod -R g+w .. |