diff options
author | onefang | 2019-05-23 21:50:45 +1000 |
---|---|---|
committer | onefang | 2019-05-23 21:50:45 +1000 |
commit | 53baef9042cb30d29a66933da105029101b455d3 (patch) | |
tree | 0710e1a0bfdb3b92c2daa65e2eb28558295e6f5a /scripts/start-sim | |
parent | Update the tmux config. (diff) | |
download | opensim-SC-53baef9042cb30d29a66933da105029101b455d3.zip opensim-SC-53baef9042cb30d29a66933da105029101b455d3.tar.gz opensim-SC-53baef9042cb30d29a66933da105029101b455d3.tar.bz2 opensim-SC-53baef9042cb30d29a66933da105029101b455d3.tar.xz |
Management scripts encounters the real world, needs patching up.
Diffstat (limited to 'scripts/start-sim')
-rwxr-xr-x | scripts/start-sim | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/scripts/start-sim b/scripts/start-sim index e82547a..3c6370f 100755 --- a/scripts/start-sim +++ b/scripts/start-sim | |||
@@ -4,8 +4,8 @@ source common.sh | |||
4 | getPrgDir | 4 | getPrgDir |
5 | 5 | ||
6 | USER=$(whoami) | 6 | USER=$(whoami) |
7 | console_name="OpenSim_console" | 7 | console_name="OpenSimSC_console" |
8 | tmux_command="tmux -S /var/run/opensim/opensim-tmux.socket" | 8 | tmux_command="tmux -S ${PRGDIR}/../../caches/opensim-tmux.socket" |
9 | tmux_session=${console_name} | 9 | tmux_session=${console_name} |
10 | tmux_window="${tmux_command} select-window -t ${tmux_session}" | 10 | tmux_window="${tmux_command} select-window -t ${tmux_session}" |
11 | tmux_send="${tmux_command} send-keys -t ${tmux_session}" | 11 | tmux_send="${tmux_command} send-keys -t ${tmux_session}" |
@@ -22,11 +22,11 @@ function wait_for_text() | |||
22 | done | 22 | done |
23 | } | 23 | } |
24 | 24 | ||
25 | if [ $USER = "opensim" ] | 25 | if [ $USER = "${OS_USER}" ] |
26 | then | 26 | then |
27 | SUDO="" | 27 | SUDO="" |
28 | else | 28 | else |
29 | SUDO="sudo -Hu opensim" | 29 | SUDO="sudo -Hu ${OS_USER}" |
30 | fi | 30 | fi |
31 | 31 | ||
32 | if [ "$1" = "-q" ] | 32 | if [ "$1" = "-q" ] |
@@ -80,7 +80,7 @@ case $(basename $0) in | |||
80 | cmd="mono ${exe}.exe -inidirectory=../../config/${tgt} " | 80 | cmd="mono ${exe}.exe -inidirectory=../../config/${tgt} " |
81 | 81 | ||
82 | # Check if it's already running. | 82 | # Check if it's already running. |
83 | if [ -e /var/run/opensim/${tgt}.pid ] | 83 | if [ -e ${PRGDIR}/../../caches/${tgt}.pid ] |
84 | then | 84 | then |
85 | # Double check if it's REALLY running. | 85 | # Double check if it's REALLY running. |
86 | if [ "x$(ps -p $(cat ${PRGDIR}/../../caches/${tgt}.pid) --no-headers -o comm)" = "x" ]; then | 86 | if [ "x$(ps -p $(cat ${PRGDIR}/../../caches/${tgt}.pid) --no-headers -o comm)" = "x" ]; then |
@@ -88,12 +88,12 @@ case $(basename $0) in | |||
88 | fi | 88 | fi |
89 | fi | 89 | fi |
90 | # Now see if it's really really running. lol | 90 | # Now see if it's really really running. lol |
91 | if [ ! -e /var/run/opensim/${tgt}.pid ] | 91 | if [ ! -e ${PRGDIR}/../../caches/${tgt}.pid ] |
92 | then | 92 | then |
93 | if [ "x$tgt" = "xROBUST" ]; then | 93 | if [ "x$tgt" = "xROBUST" ]; then |
94 | # TODO - the problem here is that the > bit is executed as onefang, not as opensim. | 94 | # TODO - the problem here is that the > bit is executed as the user, not as opensim. |
95 | $SUDO cat ${PRGDIR}/../../config/config.ini ${PRGDIR}/../../config/Robust.ini.template >${PRGDIR}/../../config/Robust.ini | 95 | $SUDO cat ${PRGDIR}/../../config/config.ini ${PRGDIR}/../../config/Robust.ini.template >${PRGDIR}/../../config/Robust.ini |
96 | # $SUDO chown -R opensim:opensim ${PRGDIR}/../../config/Robust.ini | 96 | # $SUDO chown -R ${OS_USER}:${OS_USER} ${PRGDIR}/../../config/Robust.ini |
97 | chmod 640 ${PRGDIR}/../../config/Robust.ini | 97 | chmod 640 ${PRGDIR}/../../config/Robust.ini |
98 | ${tmux_command} split-window -hp 50 -t "${tmux_session}:" "${cmd}" | 98 | ${tmux_command} split-window -hp 50 -t "${tmux_session}:" "${cmd}" |
99 | else | 99 | else |
@@ -124,7 +124,7 @@ case $(basename $0) in | |||
124 | ;; | 124 | ;; |
125 | 125 | ||
126 | "backup-sim") | 126 | "backup-sim") |
127 | if [ -e /var/run/opensim/${tgt}.pid ]; then | 127 | if [ -e ${PRGDIR}/../../caches/${tgt}.pid ]; then |
128 | cd ${PRGDIR} | 128 | cd ${PRGDIR} |
129 | $SUDO ${PRGDIR}/gitAR.sh o "${title}" | 129 | $SUDO ${PRGDIR}/gitAR.sh o "${title}" |
130 | sim=$(sanitize "${title}") | 130 | sim=$(sanitize "${title}") |
@@ -141,7 +141,7 @@ case $(basename $0) in | |||
141 | ;; | 141 | ;; |
142 | 142 | ||
143 | "stop-sim") | 143 | "stop-sim") |
144 | if [ -e /var/run/opensim/${tgt}.pid ]; then | 144 | if [ -e ${PRGDIR}/../../caches/${tgt}.pid ]; then |
145 | ${tmux_send}:"${title}" "alert WARNING - Emergency shutdown in one minute!" Enter | 145 | ${tmux_send}:"${title}" "alert WARNING - Emergency shutdown in one minute!" Enter |
146 | ${tmux_send}:"${title}" "alert WARNING - Emergency shutdown in one minute!" Enter | 146 | ${tmux_send}:"${title}" "alert WARNING - Emergency shutdown in one minute!" Enter |
147 | sleep 30 | 147 | sleep 30 |
@@ -150,9 +150,9 @@ case $(basename $0) in | |||
150 | sleep 30 | 150 | sleep 30 |
151 | ${tmux_send}:"${title}" "shutdown" Enter | 151 | ${tmux_send}:"${title}" "shutdown" Enter |
152 | sleep 30 | 152 | sleep 30 |
153 | if [ -e /var/run/opensim/${tgt}.pid ]; then | 153 | if [ -e ${PRGDIR}/../../caches/${tgt}.pid ]; then |
154 | echo "Killing it with extreme prejudice!" | 154 | echo "Killing it with extreme prejudice!" |
155 | kill -TERM `cat /var/run/opensim/${tgt}.pid` | 155 | kill -TERM `cat ${PRGDIR}/../../caches/${tgt}.pid` |
156 | fi | 156 | fi |
157 | else | 157 | else |
158 | echo "Sim ${title} is not running, so not stopping." | 158 | echo "Sim ${title} is not running, so not stopping." |