diff options
Diffstat (limited to 'start-sim')
-rwxr-xr-x | start-sim | 83 |
1 files changed, 40 insertions, 43 deletions
@@ -1,12 +1,5 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 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) | 3 | USER=$(whoami) |
11 | console_name="OpenSim_console" | 4 | console_name="OpenSim_console" |
12 | screen_session=opensim/${console_name} | 5 | screen_session=opensim/${console_name} |
@@ -32,7 +25,7 @@ fi | |||
32 | 25 | ||
33 | if [ "x$tgt" = "x" ]; then | 26 | if [ "x$tgt" = "x" ]; then |
34 | echo "usage:" | 27 | echo "usage:" |
35 | echo " $ start-sim-in-rest <sim>" | 28 | echo " $ $(basename $0) <sim>" |
36 | echo "where <sim> is one of: " robust sim[0-9][0-9] | 29 | echo "where <sim> is one of: " robust sim[0-9][0-9] |
37 | exit 1 | 30 | exit 1 |
38 | fi | 31 | fi |
@@ -49,15 +42,10 @@ export MONO_PATH=${bindir} | |||
49 | # Then we would not have to do this, and subsequently write all over the damn bin directory. | 42 | # Then we would not have to do this, and subsequently write all over the damn bin directory. |
50 | cd ${bindir} | 43 | cd ${bindir} |
51 | 44 | ||
52 | if [ "x$Screaming" = "xtrue" ] | 45 | if ($screen_check | grep -q ${console_name}); then |
53 | then | 46 | true |
54 | if ($screen_check | grep -q ${console_name}); then | 47 | else |
55 | echo "INFO: Screen already running" | 48 | $SUDO screen -d -m -S ${console_name} |
56 | true | ||
57 | else | ||
58 | echo "DEBUG: Starting screen" | ||
59 | $SUDO screen -d -m -S ${console_name} | ||
60 | fi | ||
61 | fi | 49 | fi |
62 | 50 | ||
63 | if [ "x$tgt" = "xrobust" ]; then | 51 | if [ "x$tgt" = "xrobust" ]; then |
@@ -67,33 +55,42 @@ else | |||
67 | fi | 55 | fi |
68 | 56 | ||
69 | inidir=/opt/opensim/config/${tgt} | 57 | inidir=/opt/opensim/config/${tgt} |
70 | cmd="/usr/bin/mono ${bindir}/${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config $NeedARest" | 58 | # Grab the first line of the sim.ini file, it should be the sim name in square brackets. |
71 | title=$(head -n 1 ${inidir}/Regions/sim.ini ) | 59 | title=$(head -n 1 ${inidir}/Regions/sim.ini ) |
60 | # Strip off spaces at either end. | ||
61 | shopt -s extglob | ||
62 | title=${title##*( )} | ||
63 | title=${title%%*( )} | ||
64 | shopt -u extglob | ||
65 | # Strip off the square brackets at either end. | ||
66 | title=${title:1:$(( ${#title} - 2 ))} | ||
72 | 67 | ||
73 | # Check if it's already running. | 68 | case $(basename $0) in |
74 | if [ ! -e /var/run/opensim/${tgt}.pid ] | 69 | "start-sim") |
75 | then | 70 | cmd="/usr/bin/mono ${bindir}/${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config" |
76 | if [ "x$Screaming" = "xtrue" ] | ||
77 | then | ||
78 | echo "INFO: start process and connect to screen (opensim) $title" | ||
79 | $SUDO screen -r ${screen_session} -p "-" -X screen -t "${title}" ${cmd} | ||
80 | else | ||
81 | $cmd | ||
82 | fi | ||
83 | fi | ||
84 | 71 | ||
85 | if [ "x$quiet" = "x" ] | 72 | # Check if it's already running. |
86 | then | 73 | if [ ! -e /var/run/opensim/${tgt}.pid ] |
87 | # Either way, need to start up the console after. | 74 | then |
88 | if [ "x$Screaming" = "xtrue" ] | 75 | $SUDO screen -r ${screen_session} -p "-" -X screen -t "[${title}]" ${cmd} |
89 | then | 76 | fi |
90 | echo "Starting screen client." | 77 | ;& |
91 | screen -r ${screen_session} -A | 78 | |
92 | elif [ "x$NeedARest" != "x" ] | 79 | "sim-console") |
93 | then | 80 | if [ "x$quiet" = "x" ] |
94 | echo "Starting rest client." | 81 | then |
95 | cd ${inidir} | 82 | screen -r ${screen_session} -p "[${title}]" -A |
96 | /usr/bin/mono ${bindir}/OpenSim.ConsoleClient.exe -logconfig=${inidir}/${exe}.exe.config | 83 | fi |
97 | fi | 84 | ;; |
98 | fi | 85 | |
86 | "backup-sim") | ||
87 | # Substitute underscores for spaces in the title, then add the full date and time to create the OAR file name. | ||
88 | cmd="save oar ${inidir}/../../backups/${title// /_}-$(date '+%F_%T').oar" | ||
89 | sudo -Hu opensim screen -r opensim/OpenSim_console -p "[${title}]" -X stuff "${cmd}$(/bin/echo -ne '\015')" | ||
90 | ;; | ||
91 | |||
92 | "stop-sim") | ||
93 | sudo -Hu opensim screen -r opensim/OpenSim_console -p "[${title}]" -X stuff "shutdown$(/bin/echo -ne '\015')" | ||
94 | ;; | ||
95 | esac | ||
99 | 96 | ||