aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/start-sim
diff options
context:
space:
mode:
Diffstat (limited to 'start-sim')
-rwxr-xr-xstart-sim95
1 files changed, 95 insertions, 0 deletions
diff --git a/start-sim b/start-sim
new file mode 100755
index 0000000..3313f57
--- /dev/null
+++ b/start-sim
@@ -0,0 +1,95 @@
1#!/bin/bash
2
3# Pick one of these depending on how you want your access.
4# NOTE - REST does not work. B-(
5#NeedARest=" -console=rest"
6NeedARest=""
7Screaming="true"
8#Screaming=""
9
10USER=$(whoami)
11console_name="OpenSim_console"
12screen_session=opensim/${console_name}
13screen_check="screen -ls opensim/"
14osversion="current"
15bindir=/opt/opensim/${osversion}/bin
16quiet=""
17
18if [ "$1" = "-q" ]
19then
20 quiet="true"
21 shift 1
22fi
23
24if [ "x$1" = "x" ]; then
25 pathname=$(pwd)
26 tgt=$(basename $pathname)
27elif [ -d "./$1" ]; then
28 tgt=$1
29elif [ -d "./sim$1" ]; then
30 tgt=sim$1
31fi
32
33if [ "x$tgt" = "x" ]; then
34 echo "usage:"
35 echo " $ start-sim-in-rest <sim>"
36 echo "where <sim> is one of: " robust sim[0-9][0-9]
37 exit 1
38fi
39
40if [ $USER = "opensim" ]
41then
42 SUDO=""
43else
44 SUDO="sudo -Hu opensim"
45fi
46
47cd ${bindir}
48if [ "x$Screaming" = "xtrue" ]
49then
50 if ($screen_check | grep -q ${console_name}); then
51 echo "INFO: Screen already running"
52 true
53 else
54 echo "DEBUG: Starting screen"
55 $SUDO screen -d -m -S ${console_name}
56 fi
57fi
58
59if [ "x$tgt" = "xrobust" ]; then
60 exe="Robust"
61else
62 exe="OpenSim"
63fi
64
65inidir=/opt/opensim/config/${tgt}
66cmd="/usr/bin/mono ${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config $NeedARest"
67title=$(head -n 1 ${inidir}/Regions/sim.ini )
68
69# Check if it's already running.
70if [ ! -e /var/run/opensim/${tgt}.pid ]
71then
72 if [ "x$Screaming" = "xtrue" ]
73 then
74 echo "INFO: start process and connect to screen (opensim) $title"
75 $SUDO screen -r ${screen_session} -p "-" -X screen -t "${title}" ${cmd}
76 else
77 $cmd
78 fi
79fi
80
81if [ "x$quiet" = "x" ]
82then
83 # Either way, need to start up the console after.
84 if [ "x$Screaming" = "xtrue" ]
85 then
86 echo "Starting screen client."
87 screen -r ${screen_session} -A
88 elif [ "x$NeedARest" != "x" ]
89 then
90 echo "Starting rest client."
91 cd ${inidir}
92 /usr/bin/mono ${bindir}/OpenSim.ConsoleClient.exe -logconfig=${inidir}/${exe}.exe.config
93 fi
94fi
95