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 | |
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.
-rwxr-xr-x | InstallItAll.sh | 10 | ||||
-rwxr-xr-x | scripts/install/secure.sh | 4 | ||||
-rwxr-xr-x | scripts/show-console | 2 | ||||
-rwxr-xr-x | scripts/start-sim | 24 |
4 files changed, 22 insertions, 18 deletions
diff --git a/InstallItAll.sh b/InstallItAll.sh index 6467ff8..b7077b8 100755 --- a/InstallItAll.sh +++ b/InstallItAll.sh | |||
@@ -49,14 +49,14 @@ echo "Setting up OpenSim users. This next prompt asks for your MySQL root users | |||
49 | # "create user if not exists" doesn't exist until MySQL 5.7, so we have to put up with a warning, which we can ignore. | 49 | # "create user if not exists" doesn't exist until MySQL 5.7, so we have to put up with a warning, which we can ignore. |
50 | mysql -u root -p -h localhost << zzzzEOFzzz | 50 | mysql -u root -p -h localhost << zzzzEOFzzz |
51 | create database if not exists $MYSQL_DB; | 51 | create database if not exists $MYSQL_DB; |
52 | create user '$OS_USER' identified by '$MYSQL_PASSWORD'; | 52 | create user '$MYSQL_USER' identified by '$MYSQL_PASSWORD'; |
53 | create user '$OS_USER'@localhost identified by '$MYSQL_PASSWORD'; | 53 | create user '$MYSQL_USER'@localhost identified by '$MYSQL_PASSWORD'; |
54 | grant all on $MYSQL_DB.* to '$OS_USER'; | 54 | grant all on $MYSQL_DB.* to '$MYSQL_USER'; |
55 | grant all on $MYSQL_DB.* to '$OS_USER'@localhost; | 55 | grant all on $MYSQL_DB.* to '$MYSQL_USER'@localhost; |
56 | FLUSH PRIVILEGES; | 56 | FLUSH PRIVILEGES; |
57 | zzzzEOFzzz | 57 | zzzzEOFzzz |
58 | 58 | ||
59 | sudo adduser --system --shell /bin/false --group ${OS_USER} | 59 | sudo adduser --system --group ${OS_USER} |
60 | sudo addgroup ${USER} ${OS_USER} | 60 | sudo addgroup ${USER} ${OS_USER} |
61 | 61 | ||
62 | 62 | ||
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 | |||
18 | sudo chmod ug+rwx ${OS_PATH}/config | 18 | sudo chmod ug+rwx ${OS_PATH}/config |
19 | sudo chmod g+s ${OS_PATH}/config | 19 | sudo chmod g+s ${OS_PATH}/config |
20 | sudo chmod 600 ${OS_PATH}/config/*.ini | 20 | sudo chmod 600 ${OS_PATH}/config/*.ini |
21 | |||
22 | chmod ug+rwx ${OS_PATH}/caches | ||
23 | chmod o-rwx ${OS_PATH}/caches | ||
24 | 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 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | tmux -S /var/run/opensim/opensim-tmux.socket select-window -t "OpenSim_console" \; attach-session -t "OpenSim_console" | 3 | 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 | |||
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." |