aboutsummaryrefslogtreecommitdiffstatshomepage
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
parentMake it safe. (diff)
downloadIGnoble-c193946f0562bf690b6ee4afe4fa7506a74ce568.zip
IGnoble-c193946f0562bf690b6ee4afe4fa7506a74ce568.tar.gz
IGnoble-c193946f0562bf690b6ee4afe4fa7506a74ce568.tar.bz2
IGnoble-c193946f0562bf690b6ee4afe4fa7506a74ce568.tar.xz
Better screen handling.
-rwxr-xr-xinstall_opensim.sh3
-rw-r--r--opensim-monit.conf2
-rw-r--r--opensim.screenrc1
-rwxr-xr-xstart-sim-in-rest71
4 files changed, 42 insertions, 35 deletions
diff --git a/install_opensim.sh b/install_opensim.sh
index 47ce76f..69c5b88 100755
--- a/install_opensim.sh
+++ b/install_opensim.sh
@@ -26,6 +26,9 @@ echo "Setting up OpenSim"
26sudo adduser --system --shell /bin/false --group opensim 26sudo adduser --system --shell /bin/false --group opensim
27sudo addgroup $USER opensim 27sudo addgroup $USER opensim
28sudo cp opensim.screenrc /home/opensim/.screenrc 28sudo cp opensim.screenrc /home/opensim/.screenrc
29sudo chown $USER /home/opensim/.screenrc
30echo -e "acladd root,$USER\n" >> /home/opensim/.screenrc
31sudo chown opensim:opensim /home/opensim/.screenrc
29sudo chmod 644 /home/opensim/.screenrc 32sudo chmod 644 /home/opensim/.screenrc
30sudo mkdir -p /var/log/opensim 33sudo mkdir -p /var/log/opensim
31sudo chown opensim:opensim /var/log/opensim 34sudo chown opensim:opensim /var/log/opensim
diff --git a/opensim-monit.conf b/opensim-monit.conf
index e300720..f28c76c 100644
--- a/opensim-monit.conf
+++ b/opensim-monit.conf
@@ -20,7 +20,7 @@
20# see ../README for configuration instructions. 20# see ../README for configuration instructions.
21# 21#
22check process sim01 with pidfile /var/run/opensim/sim01.pid 22check process sim01 with pidfile /var/run/opensim/sim01.pid
23 start program = "/bin/bash -c 'cd /opt/opensim/config/sim01 && /opt/opensim/sim01/start-sim-in-rest'" 23 start program = "/bin/bash -c 'cd /opt/opensim/config/sim01 && /opt/opensim/sim01/start-sim-in-rest -q'"
24 as uid opensim and gid opensim 24 as uid opensim and gid opensim
25 stop program = "/bin/kill -9 `cat /var/run/opensim/sim01.pid`" 25 stop program = "/bin/kill -9 `cat /var/run/opensim/sim01.pid`"
26# if cpu usage > 300% for 4 cycles then restart 26# if cpu usage > 300% for 4 cycles then restart
diff --git a/opensim.screenrc b/opensim.screenrc
index 01a4f26..961e66b 100644
--- a/opensim.screenrc
+++ b/opensim.screenrc
@@ -16,5 +16,4 @@ hardstatus string '%{= kw}[ %{= kb}%H%{= kw} ][%= %{= kw}%?%-Lw%?%{= kW}%n*%f %t
16bind 'q' quit 16bind 'q' quit
17 17
18multiuser on 18multiuser on
19acladd root
20 19
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