diff options
Diffstat (limited to 'start-sim')
| -rwxr-xr-x | start-sim | 19 |
1 files changed, 12 insertions, 7 deletions
| @@ -9,6 +9,13 @@ osversion="current" | |||
| 9 | bindir=/opt/opensim/${osversion}/bin | 9 | bindir=/opt/opensim/${osversion}/bin |
| 10 | quiet="" | 10 | quiet="" |
| 11 | 11 | ||
| 12 | if [ $USER = "opensim" ] | ||
| 13 | then | ||
| 14 | SUDO="" | ||
| 15 | else | ||
| 16 | SUDO="sudo -Hu opensim" | ||
| 17 | fi | ||
| 18 | |||
| 12 | if [ "$1" = "-q" ] | 19 | if [ "$1" = "-q" ] |
| 13 | then | 20 | then |
| 14 | quiet="true" | 21 | quiet="true" |
| @@ -39,12 +46,6 @@ cd ${bindir} | |||
| 39 | if ( ${screen_command} -q list-sessions 2>/dev/null | grep -q ${console_name}: ); then | 46 | if ( ${screen_command} -q list-sessions 2>/dev/null | grep -q ${console_name}: ); then |
| 40 | true | 47 | true |
| 41 | else | 48 | else |
| 42 | if [ $USER = "opensim" ] | ||
| 43 | then | ||
| 44 | SUDO="" | ||
| 45 | else | ||
| 46 | SUDO="sudo -Hu opensim" | ||
| 47 | fi | ||
| 48 | # The sudo is only so that the session is owned by opensim, otherwise it's owned by whoewer ran this script, which is a likely security hole. | 49 | # The sudo is only so that the session is owned by opensim, otherwise it's owned by whoewer ran this script, which is a likely security hole. |
| 49 | # After the session is created, we rely on the /var/run/opensim directory to be group sticky, so that anyone in the opensim group can attach to the tmux socket. | 50 | # After the session is created, we rely on the /var/run/opensim directory to be group sticky, so that anyone in the opensim group can attach to the tmux socket. |
| 50 | $SUDO ${screen_command} new-session -d -s ${console_name} | 51 | $SUDO ${screen_command} new-session -d -s ${console_name} |
| @@ -76,7 +77,11 @@ case $(basename $0) in | |||
| 76 | # Check if it's already running. | 77 | # Check if it's already running. |
| 77 | if [ ! -e /var/run/opensim/${tgt}.pid ] | 78 | if [ ! -e /var/run/opensim/${tgt}.pid ] |
| 78 | then | 79 | then |
| 79 | ${screen_command} new-window -dn "[${title}]" -t "${screen_session}" "${cmd}" | 80 | # Double check if it's REALLY running. |
| 81 | if [ "x$(ps -p $(cat /var/run/opensim/sim90.pid) --no-headers -o comm)" = "x" ]; then | ||
| 82 | $SUDO rm -f /var/run/opensim/${tgt}.pid | ||
| 83 | ${screen_command} new-window -dn "[${title}]" -t "${screen_session}" "${cmd}" | ||
| 84 | fi | ||
| 80 | fi | 85 | fi |
| 81 | ;& | 86 | ;& |
| 82 | 87 | ||
