diff options
Diffstat (limited to 'start-sim')
| -rwxr-xr-x | start-sim | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/start-sim b/start-sim new file mode 100755 index 0000000..3313f57 --- /dev/null +++ b/start-sim | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | # Pick one of these depending on how you want your access. | ||
| 4 | # NOTE - REST does not work. B-( | ||
| 5 | #NeedARest=" -console=rest" | ||
| 6 | NeedARest="" | ||
| 7 | Screaming="true" | ||
| 8 | #Screaming="" | ||
| 9 | |||
| 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="" | ||
| 17 | |||
| 18 | if [ "$1" = "-q" ] | ||
| 19 | then | ||
| 20 | quiet="true" | ||
| 21 | shift 1 | ||
| 22 | fi | ||
| 23 | |||
| 24 | if [ "x$1" = "x" ]; then | ||
| 25 | pathname=$(pwd) | ||
| 26 | tgt=$(basename $pathname) | ||
| 27 | elif [ -d "./$1" ]; then | ||
| 28 | tgt=$1 | ||
| 29 | elif [ -d "./sim$1" ]; then | ||
| 30 | tgt=sim$1 | ||
| 31 | fi | ||
| 32 | |||
| 33 | if [ "x$tgt" = "x" ]; then | ||
| 34 | echo "usage:" | ||
| 35 | echo " $ start-sim-in-rest <sim>" | ||
| 36 | echo "where <sim> is one of: " robust sim[0-9][0-9] | ||
| 37 | exit 1 | ||
| 38 | fi | ||
| 39 | |||
| 40 | if [ $USER = "opensim" ] | ||
| 41 | then | ||
| 42 | SUDO="" | ||
| 43 | else | ||
| 44 | SUDO="sudo -Hu opensim" | ||
| 45 | fi | ||
| 46 | |||
| 47 | cd ${bindir} | ||
| 48 | if [ "x$Screaming" = "xtrue" ] | ||
| 49 | then | ||
| 50 | if ($screen_check | grep -q ${console_name}); then | ||
| 51 | echo "INFO: Screen already running" | ||
| 52 | true | ||
| 53 | else | ||
| 54 | echo "DEBUG: Starting screen" | ||
| 55 | $SUDO screen -d -m -S ${console_name} | ||
| 56 | fi | ||
| 57 | fi | ||
| 58 | |||
| 59 | if [ "x$tgt" = "xrobust" ]; then | ||
| 60 | exe="Robust" | ||
| 61 | else | ||
| 62 | exe="OpenSim" | ||
| 63 | fi | ||
| 64 | |||
| 65 | inidir=/opt/opensim/config/${tgt} | ||
| 66 | cmd="/usr/bin/mono ${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config $NeedARest" | ||
| 67 | title=$(head -n 1 ${inidir}/Regions/sim.ini ) | ||
| 68 | |||
| 69 | # Check if it's already running. | ||
| 70 | if [ ! -e /var/run/opensim/${tgt}.pid ] | ||
| 71 | then | ||
| 72 | if [ "x$Screaming" = "xtrue" ] | ||
| 73 | then | ||
| 74 | echo "INFO: start process and connect to screen (opensim) $title" | ||
| 75 | $SUDO screen -r ${screen_session} -p "-" -X screen -t "${title}" ${cmd} | ||
| 76 | else | ||
| 77 | $cmd | ||
| 78 | fi | ||
| 79 | fi | ||
| 80 | |||
| 81 | if [ "x$quiet" = "x" ] | ||
| 82 | then | ||
| 83 | # Either way, need to start up the console after. | ||
| 84 | if [ "x$Screaming" = "xtrue" ] | ||
| 85 | then | ||
| 86 | echo "Starting screen client." | ||
| 87 | screen -r ${screen_session} -A | ||
| 88 | elif [ "x$NeedARest" != "x" ] | ||
| 89 | then | ||
| 90 | echo "Starting rest client." | ||
| 91 | cd ${inidir} | ||
| 92 | /usr/bin/mono ${bindir}/OpenSim.ConsoleClient.exe -logconfig=${inidir}/${exe}.exe.config | ||
| 93 | fi | ||
| 94 | fi | ||
| 95 | |||
