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