From 53baef9042cb30d29a66933da105029101b455d3 Mon Sep 17 00:00:00 2001 From: onefang Date: Thu, 23 May 2019 21:50:45 +1000 Subject: Management scripts encounters the real world, needs patching up. --- scripts/start-sim | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'scripts/start-sim') 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 getPrgDir USER=$(whoami) -console_name="OpenSim_console" -tmux_command="tmux -S /var/run/opensim/opensim-tmux.socket" +console_name="OpenSimSC_console" +tmux_command="tmux -S ${PRGDIR}/../../caches/opensim-tmux.socket" tmux_session=${console_name} tmux_window="${tmux_command} select-window -t ${tmux_session}" tmux_send="${tmux_command} send-keys -t ${tmux_session}" @@ -22,11 +22,11 @@ function wait_for_text() done } -if [ $USER = "opensim" ] +if [ $USER = "${OS_USER}" ] then SUDO="" else - SUDO="sudo -Hu opensim" + SUDO="sudo -Hu ${OS_USER}" fi if [ "$1" = "-q" ] @@ -80,7 +80,7 @@ case $(basename $0) in cmd="mono ${exe}.exe -inidirectory=../../config/${tgt} " # Check if it's already running. - if [ -e /var/run/opensim/${tgt}.pid ] + if [ -e ${PRGDIR}/../../caches/${tgt}.pid ] then # Double check if it's REALLY running. if [ "x$(ps -p $(cat ${PRGDIR}/../../caches/${tgt}.pid) --no-headers -o comm)" = "x" ]; then @@ -88,12 +88,12 @@ case $(basename $0) in fi fi # Now see if it's really really running. lol - if [ ! -e /var/run/opensim/${tgt}.pid ] + if [ ! -e ${PRGDIR}/../../caches/${tgt}.pid ] then if [ "x$tgt" = "xROBUST" ]; then -# TODO - the problem here is that the > bit is executed as onefang, not as opensim. +# TODO - the problem here is that the > bit is executed as the user, not as opensim. $SUDO cat ${PRGDIR}/../../config/config.ini ${PRGDIR}/../../config/Robust.ini.template >${PRGDIR}/../../config/Robust.ini -# $SUDO chown -R opensim:opensim ${PRGDIR}/../../config/Robust.ini +# $SUDO chown -R ${OS_USER}:${OS_USER} ${PRGDIR}/../../config/Robust.ini chmod 640 ${PRGDIR}/../../config/Robust.ini ${tmux_command} split-window -hp 50 -t "${tmux_session}:" "${cmd}" else @@ -124,7 +124,7 @@ case $(basename $0) in ;; "backup-sim") - if [ -e /var/run/opensim/${tgt}.pid ]; then + if [ -e ${PRGDIR}/../../caches/${tgt}.pid ]; then cd ${PRGDIR} $SUDO ${PRGDIR}/gitAR.sh o "${title}" sim=$(sanitize "${title}") @@ -141,7 +141,7 @@ case $(basename $0) in ;; "stop-sim") - if [ -e /var/run/opensim/${tgt}.pid ]; then + if [ -e ${PRGDIR}/../../caches/${tgt}.pid ]; then ${tmux_send}:"${title}" "alert WARNING - Emergency shutdown in one minute!" Enter ${tmux_send}:"${title}" "alert WARNING - Emergency shutdown in one minute!" Enter sleep 30 @@ -150,9 +150,9 @@ case $(basename $0) in sleep 30 ${tmux_send}:"${title}" "shutdown" Enter sleep 30 - if [ -e /var/run/opensim/${tgt}.pid ]; then + if [ -e ${PRGDIR}/../../caches/${tgt}.pid ]; then echo "Killing it with extreme prejudice!" - kill -TERM `cat /var/run/opensim/${tgt}.pid` + kill -TERM `cat ${PRGDIR}/../../caches/${tgt}.pid` fi else echo "Sim ${title} is not running, so not stopping." -- cgit v1.1