From c74547ae05f97850cc888a2563c56cd326dd38ea Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 27 Nov 2011 19:28:39 +1000 Subject: Rename the start up script. --- start-sim | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100755 start-sim (limited to 'start-sim') diff --git a/start-sim b/start-sim new file mode 100755 index 0000000..3313f57 --- /dev/null +++ b/start-sim @@ -0,0 +1,95 @@ +#!/bin/bash + +# Pick one of these depending on how you want your access. +# NOTE - REST does not work. B-( +#NeedARest=" -console=rest" +NeedARest="" +Screaming="true" +#Screaming="" + +USER=$(whoami) +console_name="OpenSim_console" +screen_session=opensim/${console_name} +screen_check="screen -ls opensim/" +osversion="current" +bindir=/opt/opensim/${osversion}/bin +quiet="" + +if [ "$1" = "-q" ] +then + quiet="true" + shift 1 +fi + +if [ "x$1" = "x" ]; then + pathname=$(pwd) + tgt=$(basename $pathname) +elif [ -d "./$1" ]; then + tgt=$1 +elif [ -d "./sim$1" ]; then + tgt=sim$1 +fi + +if [ "x$tgt" = "x" ]; then + echo "usage:" + echo " $ start-sim-in-rest " + echo "where is one of: " robust sim[0-9][0-9] + exit 1 +fi + +if [ $USER = "opensim" ] +then + SUDO="" +else + SUDO="sudo -Hu opensim" +fi + +cd ${bindir} +if [ "x$Screaming" = "xtrue" ] +then + if ($screen_check | grep -q ${console_name}); then + echo "INFO: Screen already running" + true + else + echo "DEBUG: Starting screen" + $SUDO screen -d -m -S ${console_name} + fi +fi + +if [ "x$tgt" = "xrobust" ]; then + exe="Robust" +else + exe="OpenSim" +fi + +inidir=/opt/opensim/config/${tgt} +cmd="/usr/bin/mono ${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config $NeedARest" +title=$(head -n 1 ${inidir}/Regions/sim.ini ) + +# Check if it's already running. +if [ ! -e /var/run/opensim/${tgt}.pid ] +then + if [ "x$Screaming" = "xtrue" ] + then + echo "INFO: start process and connect to screen (opensim) $title" + $SUDO screen -r ${screen_session} -p "-" -X screen -t "${title}" ${cmd} + else + $cmd + fi +fi + +if [ "x$quiet" = "x" ] +then + # Either way, need to start up the console after. + if [ "x$Screaming" = "xtrue" ] + then + echo "Starting screen client." + screen -r ${screen_session} -A + elif [ "x$NeedARest" != "x" ] + then + echo "Starting rest client." + cd ${inidir} + /usr/bin/mono ${bindir}/OpenSim.ConsoleClient.exe -logconfig=${inidir}/${exe}.exe.config + fi +fi + -- cgit v1.1