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/install/secure.sh | 4 ++++ scripts/show-console | 2 +- scripts/start-sim | 24 ++++++++++++------------ 3 files changed, 17 insertions(+), 13 deletions(-) (limited to 'scripts') diff --git a/scripts/install/secure.sh b/scripts/install/secure.sh index 48255b6..43ed679 100755 --- a/scripts/install/secure.sh +++ b/scripts/install/secure.sh @@ -18,3 +18,7 @@ sudo chmod a+x ${OS_PATH}/current/scripts/start-sim sudo chmod ug+rwx ${OS_PATH}/config sudo chmod g+s ${OS_PATH}/config sudo chmod 600 ${OS_PATH}/config/*.ini + +chmod ug+rwx ${OS_PATH}/caches +chmod o-rwx ${OS_PATH}/caches +chmod g+s ${OS_PATH}/caches diff --git a/scripts/show-console b/scripts/show-console index ddeba86..5818e70 100755 --- a/scripts/show-console +++ b/scripts/show-console @@ -1,3 +1,3 @@ #!/bin/bash -tmux -S /var/run/opensim/opensim-tmux.socket select-window -t "OpenSim_console" \; attach-session -t "OpenSim_console" +tmux -S ../../caches/opensim-tmux.socket select-window -t "OpenSimSC_console" \; attach-session -t "OpenSimSC_console" 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