diff options
| author | David Walter Seikel | 2011-11-26 20:07:01 +1000 |
|---|---|---|
| committer | David Walter Seikel | 2011-11-26 20:07:01 +1000 |
| commit | c193946f0562bf690b6ee4afe4fa7506a74ce568 (patch) | |
| tree | 71c3c9c8323dce3c3e3a81023fdcba9c40164eaf | |
| parent | Make it safe. (diff) | |
| download | IGnoble-c193946f0562bf690b6ee4afe4fa7506a74ce568.zip IGnoble-c193946f0562bf690b6ee4afe4fa7506a74ce568.tar.gz IGnoble-c193946f0562bf690b6ee4afe4fa7506a74ce568.tar.bz2 IGnoble-c193946f0562bf690b6ee4afe4fa7506a74ce568.tar.xz | |
Better screen handling.
| -rwxr-xr-x | install_opensim.sh | 3 | ||||
| -rw-r--r-- | opensim-monit.conf | 2 | ||||
| -rw-r--r-- | opensim.screenrc | 1 | ||||
| -rwxr-xr-x | start-sim-in-rest | 71 |
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" | |||
| 26 | sudo adduser --system --shell /bin/false --group opensim | 26 | sudo adduser --system --shell /bin/false --group opensim |
| 27 | sudo addgroup $USER opensim | 27 | sudo addgroup $USER opensim |
| 28 | sudo cp opensim.screenrc /home/opensim/.screenrc | 28 | sudo cp opensim.screenrc /home/opensim/.screenrc |
| 29 | sudo chown $USER /home/opensim/.screenrc | ||
| 30 | echo -e "acladd root,$USER\n" >> /home/opensim/.screenrc | ||
| 31 | sudo chown opensim:opensim /home/opensim/.screenrc | ||
| 29 | sudo chmod 644 /home/opensim/.screenrc | 32 | sudo chmod 644 /home/opensim/.screenrc |
| 30 | sudo mkdir -p /var/log/opensim | 33 | sudo mkdir -p /var/log/opensim |
| 31 | sudo chown opensim:opensim /var/log/opensim | 34 | sudo 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 | # |
| 22 | check process sim01 with pidfile /var/run/opensim/sim01.pid | 22 | check 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 | |||
| 16 | bind 'q' quit | 16 | bind 'q' quit |
| 17 | 17 | ||
| 18 | multiuser on | 18 | multiuser on |
| 19 | acladd 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 | ||
| 10 | USER=$(whoami) | 10 | USER=$(whoami) |
| 11 | console_name="OpenSim_console" | ||
| 12 | screen_session=opensim/${console_name} | ||
| 13 | screen_check="screen -ls opensim/" | ||
| 14 | osversion="current" | ||
| 15 | bindir=/opt/opensim/${osversion}/bin | ||
| 16 | quiet="" | ||
| 11 | 17 | ||
| 12 | console_name=screen_console | 18 | if [ "$1" = "-q" ] |
| 13 | if [ "$USER" = "opensim" ] | ||
| 14 | then | 19 | then |
| 15 | screen_session=opensim/${console_name} | 20 | quiet="true" |
| 16 | screen_check="screen -ls opensim/" | 21 | shift 1 |
| 17 | else | ||
| 18 | screen_session=${console_name} | ||
| 19 | screen_check="screen -ls" | ||
| 20 | fi | 22 | fi |
| 21 | osversion="current" | ||
| 22 | 23 | ||
| 23 | if [ "x$1" = "x" ]; then | 24 | if [ "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 |
| 37 | fi | 38 | fi |
| 38 | 39 | ||
| 40 | if [ $USER = "opensim" ] | ||
| 41 | then | ||
| 42 | SUDO="" | ||
| 43 | else | ||
| 44 | SUDO="sudo -Hu opensim" | ||
| 45 | fi | ||
| 46 | |||
| 47 | cd ${bindir} | ||
| 39 | if [ "x$Screaming" = "xtrue" ] | 48 | if [ "x$Screaming" = "xtrue" ] |
| 40 | then | 49 | then |
| 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 |
| 48 | fi | 57 | fi |
| 49 | 58 | ||
| @@ -52,39 +61,35 @@ if [ "x$tgt" = "xrobust" ]; then | |||
| 52 | else | 61 | else |
| 53 | exe="OpenSim" | 62 | exe="OpenSim" |
| 54 | fi | 63 | fi |
| 64 | |||
| 55 | inidir=/opt/opensim/config/${tgt} | 65 | 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" | 66 | cmd="/usr/bin/mono ${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config $NeedARest" |
| 67 | title=$(head -n 1 ${inidir}/Regions/sim.ini ) | ||
| 58 | 68 | ||
| 59 | # Check if it's already running. | 69 | # Check if it's already running. |
| 60 | if [ ! -e /var/run/opensim/${tgt} ] | 70 | if [ ! -e /var/run/opensim/${tgt} ] |
| 61 | then | 71 | then |
| 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 |
| 77 | fi | 79 | fi |
| 78 | 80 | ||
| 79 | # Either way, need to start up the console after. | 81 | if [ "x$quiet" = "x" ] |
| 80 | if [ "x$Screaming" = "xtrue" ] | ||
| 81 | then | 82 | then |
| 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 |
| 84 | elif [ "x$NeedARest" != "x" ] | 88 | elif [ "x$NeedARest" != "x" ] |
| 85 | then | 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 | ||
| 89 | fi | 94 | fi |
| 90 | 95 | ||
