aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/start-sim-in-rest
diff options
context:
space:
mode:
authorDavid Walter Seikel2011-11-26 20:07:01 +1000
committerDavid Walter Seikel2011-11-26 20:07:01 +1000
commitc193946f0562bf690b6ee4afe4fa7506a74ce568 (patch)
tree71c3c9c8323dce3c3e3a81023fdcba9c40164eaf /start-sim-in-rest
parentMake it safe. (diff)
downloadIGnoble-c193946f0562bf690b6ee4afe4fa7506a74ce568.zip
IGnoble-c193946f0562bf690b6ee4afe4fa7506a74ce568.tar.gz
IGnoble-c193946f0562bf690b6ee4afe4fa7506a74ce568.tar.bz2
IGnoble-c193946f0562bf690b6ee4afe4fa7506a74ce568.tar.xz
Better screen handling.
Diffstat (limited to 'start-sim-in-rest')
-rwxr-xr-xstart-sim-in-rest71
1 files changed, 38 insertions, 33 deletions
diff --git a/start-sim-in-rest b/start-sim-in-rest
index 4738c2e..e29490d 100755
--- a/start-sim-in-rest
+++ b/start-sim-in-rest
@@ -8,17 +8,18 @@ Screaming="true"
8#Screaming="" 8#Screaming=""
9 9
10USER=$(whoami) 10USER=$(whoami)
11console_name="OpenSim_console"
12screen_session=opensim/${console_name}
13screen_check="screen -ls opensim/"
14osversion="current"
15bindir=/opt/opensim/${osversion}/bin
16quiet=""
11 17
12console_name=screen_console 18if [ "$1" = "-q" ]
13if [ "$USER" = "opensim" ]
14then 19then
15 screen_session=opensim/${console_name} 20 quiet="true"
16 screen_check="screen -ls opensim/" 21 shift 1
17else
18 screen_session=${console_name}
19 screen_check="screen -ls"
20fi 22fi
21osversion="current"
22 23
23if [ "x$1" = "x" ]; then 24if [ "x$1" = "x" ]; then
24 pathname=$(pwd) 25 pathname=$(pwd)
@@ -36,14 +37,22 @@ if [ "x$tgt" = "x" ]; then
36 exit 1 37 exit 1
37fi 38fi
38 39
40if [ $USER = "opensim" ]
41then
42 SUDO=""
43else
44 SUDO="sudo -Hu opensim"
45fi
46
47cd ${bindir}
39if [ "x$Screaming" = "xtrue" ] 48if [ "x$Screaming" = "xtrue" ]
40then 49then
41 if ($screen_check | grep -q ${console_name}); then 50 if ($screen_check | grep -q ${console_name}); then
42 echo "INFO: Screen already running" 51 echo "INFO: Screen already running"
43 true 52 true
44 else 53 else
45 echo "DEBUG: Starting screen" 54 echo "DEBUG: Starting screen"
46 screen -d -m -S ${console_name} 55 $SUDO screen -d -m -S ${console_name}
47 fi 56 fi
48fi 57fi
49 58
@@ -52,39 +61,35 @@ if [ "x$tgt" = "xrobust" ]; then
52else 61else
53 exe="OpenSim" 62 exe="OpenSim"
54fi 63fi
64
55inidir=/opt/opensim/config/${tgt} 65inidir=/opt/opensim/config/${tgt}
56bindir=/opt/opensim/${osversion}/bin
57cmd="/usr/bin/mono ${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config $NeedARest" 66cmd="/usr/bin/mono ${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config $NeedARest"
67title=$(head -n 1 ${inidir}/Regions/sim.ini )
58 68
59# Check if it's already running. 69# Check if it's already running.
60if [ ! -e /var/run/opensim/${tgt} ] 70if [ ! -e /var/run/opensim/${tgt} ]
61then 71then
62 if [ "x$Screaming" = "xtrue" ] 72 if [ "x$Screaming" = "xtrue" ]
63 then 73 then
64 tmpfile=`mktemp` 74 echo "INFO: start process and connect to screen (opensim) $title"
65 echo "chdir ${bindir}" > ${tmpfile} 75 $SUDO screen -r ${screen_session} -p "-" -X screen -t "${title}" ${cmd}
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 76 else
74 cd ${bindir}
75 $cmd 77 $cmd
76 fi 78 fi
77fi 79fi
78 80
79# Either way, need to start up the console after. 81if [ "x$quiet" = "x" ]
80if [ "x$Screaming" = "xtrue" ]
81then 82then
82 echo "Starting screen client." 83 # Either way, need to start up the console after.
84 if [ "x$Screaming" = "xtrue" ]
85 then
86 echo "Starting screen client."
83 screen -r ${screen_session} -A 87 screen -r ${screen_session} -A
84elif [ "x$NeedARest" != "x" ] 88 elif [ "x$NeedARest" != "x" ]
85then 89 then
86 echo "Starting rest client." 90 echo "Starting rest client."
87 cd ${inidir} 91 cd ${inidir}
88 /usr/bin/mono ${bindir}/OpenSim.ConsoleClient.exe -logconfig=${inidir}/${exe}.exe.config 92 /usr/bin/mono ${bindir}/OpenSim.ConsoleClient.exe -logconfig=${inidir}/${exe}.exe.config
93 fi
89fi 94fi
90 95