diff options
Diffstat (limited to 'start-sim-in-rest')
-rwxr-xr-x | start-sim-in-rest | 71 |
1 files changed, 38 insertions, 33 deletions
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 | ||