diff options
author | onefang | 2019-09-11 16:36:50 +1000 |
---|---|---|
committer | onefang | 2019-09-11 16:36:50 +1000 |
commit | 50cd1ffd32f69228e566f2b0b89f86ea0d9fe489 (patch) | |
tree | 52f2ab0c04f1a5d7d6ac5dc872981b4b156447e7 /scripts | |
parent | Renamed branch to SledjChisl. (diff) | |
parent | Bump to release flavour, build 0. (diff) | |
download | opensim-SC-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.zip opensim-SC-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.gz opensim-SC-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.bz2 opensim-SC-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.xz |
Merge branch 'SledjChisl'
Diffstat (limited to '')
-rw-r--r-- | example/config/ROBUST/opensim-monit.conf (renamed from scripts/opensim-monit.conf) | 6 | ||||
-rwxr-xr-x | scripts/backup-inventories.sh | 2 | ||||
-rwxr-xr-x | scripts/backup-sims.sh | 5 | ||||
-rwxr-xr-x | scripts/common.sh | 11 | ||||
-rwxr-xr-x | scripts/create_sim.sh | 96 | ||||
-rwxr-xr-x | scripts/fix_var_run.sh | 6 | ||||
-rwxr-xr-x | scripts/install/create_sim.sh | 75 | ||||
-rwxr-xr-x | scripts/install/go_live.sh (renamed from scripts/go_live.sh) | 2 | ||||
-rw-r--r-- | scripts/install/group_migrate.sql (renamed from scripts/group_migrate.sql) | 0 | ||||
-rw-r--r-- | scripts/install/opensim-monit.conf (renamed from config/ROBUST/opensim-monit.conf) | 17 | ||||
-rw-r--r-- | scripts/install/opensim.tmux.conf | 97 | ||||
-rwxr-xr-x | scripts/install/secure.sh | 26 | ||||
-rw-r--r-- | scripts/opensim.tmux.conf | 52 | ||||
-rwxr-xr-x | scripts/show-console | 2 | ||||
-rwxr-xr-x | scripts/start-sim | 109 |
15 files changed, 299 insertions, 207 deletions
diff --git a/scripts/opensim-monit.conf b/example/config/ROBUST/opensim-monit.conf index 7785056..adce46d 100644 --- a/scripts/opensim-monit.conf +++ b/example/config/ROBUST/opensim-monit.conf | |||
@@ -21,10 +21,10 @@ | |||
21 | # | 21 | # |
22 | # Hmmmm, seems that monit changing to a user and running bash -l is different from sudo changing to a user and running bash -l. | 22 | # Hmmmm, seems that monit changing to a user and running bash -l is different from sudo changing to a user and running bash -l. |
23 | # | 23 | # |
24 | check process sim01 with pidfile /var/run/opensim/sim01.pid | 24 | check process ROBUST with pidfile OS_PATH/caches/ROBUST.pid |
25 | start program = "/usr/bin/sudo -Hu opensim /bin/bash -lc 'cd /opt/opensim/config/sim01 && /opt/opensim/config/sim01/start-sim -q'" | 25 | start program = "/usr/bin/sudo -Hu opensim /bin/bash -lc 'cd OS_PATH/config/ROBUST && OS_PATH/config/ROBUST/start-sim -q'" |
26 | as uid root and gid root | 26 | as uid root and gid root |
27 | stop program = "/usr/bin/sudo -Hu opensim /bin/bash -lc 'cd /opt/opensim/config/sim01 && /opt/opensim/config/sim01/stop-sim'" with timeout 600 seconds | 27 | stop program = "/usr/bin/sudo -Hu opensim /bin/bash -lc 'cd OS_PATH/config/ROBUST && OS_PATH/config/ROBUST/stop-sim'" with timeout 600 seconds |
28 | if cpu usage > 50% for 4 cycles then restart | 28 | if cpu usage > 50% for 4 cycles then restart |
29 | # if 5 restarts within 5 cycles then timeout | 29 | # if 5 restarts within 5 cycles then timeout |
30 | # if failed url http://127.0.0.1:9005/jsonSimStats/ | 30 | # if failed url http://127.0.0.1:9005/jsonSimStats/ |
diff --git a/scripts/backup-inventories.sh b/scripts/backup-inventories.sh index db4d7f4..e4e7158 100755 --- a/scripts/backup-inventories.sh +++ b/scripts/backup-inventories.sh | |||
@@ -9,7 +9,7 @@ while read -d ';' p; do | |||
9 | k=$(echo ${p} | cut -d '=' -f 1) | 9 | k=$(echo ${p} | cut -d '=' -f 1) |
10 | v=$(echo ${p} | cut -d '=' -f 2) | 10 | v=$(echo ${p} | cut -d '=' -f 2) |
11 | creds[${k}]="${v}" | 11 | creds[${k}]="${v}" |
12 | done < <(grep ConnectionString ${PRGDIR}/../config/config.ini | cut -d '"' -f 2) | 12 | done < <(grep ConnectionString ${PRGDIR}/../../config/config.ini | cut -d '"' -f 2) |
13 | # The above seems the best way to get bash to let the creds assignments survive outside the loop. | 13 | # The above seems the best way to get bash to let the creds assignments survive outside the loop. |
14 | 14 | ||
15 | # Only backup those that have not logged on since their last backup, but returning prims from sims will bypass this check. | 15 | # Only backup those that have not logged on since their last backup, but returning prims from sims will bypass this check. |
diff --git a/scripts/backup-sims.sh b/scripts/backup-sims.sh index b14acca..06cb780 100755 --- a/scripts/backup-sims.sh +++ b/scripts/backup-sims.sh | |||
@@ -5,10 +5,9 @@ getPrgDir | |||
5 | 5 | ||
6 | for i in $(seq -w 1 99) | 6 | for i in $(seq -w 1 99) |
7 | do | 7 | do |
8 | j=$(num2name ${i}) | 8 | if [ -e "${PRGDIR}/../../config/sim${i}" ] |
9 | if [ -e "${PRGDIR}/../config/${j}" ] | ||
10 | then | 9 | then |
11 | pushd ${PRGDIR}/../config/${j} >/dev/null | 10 | pushd ${PRGDIR}/../../config/sim${i} >/dev/null |
12 | # Find out the size of the last backup, base our later sleep on that, but do it now before backup-sim packs it away. | 11 | # Find out the size of the last backup, base our later sleep on that, but do it now before backup-sim packs it away. |
13 | sizeSleep=`sleepPerSize o "$(getSimName ${i})"` | 12 | sizeSleep=`sleepPerSize o "$(getSimName ${i})"` |
14 | ./backup-sim | 13 | ./backup-sim |
diff --git a/scripts/common.sh b/scripts/common.sh index 2ec19ce..6aeb8b5 100755 --- a/scripts/common.sh +++ b/scripts/common.sh | |||
@@ -1,5 +1,7 @@ | |||
1 | #!/bin/echo Don't run this file, it's for common functions." | 1 | #!/bin/echo Don't run this file, it's for common functions." |
2 | 2 | ||
3 | OS_PATH="/opt/opensim_SC" | ||
4 | OS_USER="opensimsc" | ||
3 | 5 | ||
4 | # Figure out where we are, most of this mess is to troll through soft links. | 6 | # Figure out where we are, most of this mess is to troll through soft links. |
5 | # PRGDIR=$(getPrgDir) | 7 | # PRGDIR=$(getPrgDir) |
@@ -26,9 +28,7 @@ getPrgDir() | |||
26 | # name=$(num2name 1) | 28 | # name=$(num2name 1) |
27 | num2name() | 29 | num2name() |
28 | { | 30 | { |
29 | # Using a string format, coz using a number format ends with an octal error, coz 08 isn't a valid octal number. | 31 | /usr/bin/printf 'sim%02d' "$1" |
30 | # Why isn't octal dead already? | ||
31 | printf 'sim%02s' "$1" | ||
32 | } | 32 | } |
33 | 33 | ||
34 | 34 | ||
@@ -40,11 +40,11 @@ sanitize() | |||
40 | } | 40 | } |
41 | 41 | ||
42 | 42 | ||
43 | # Grab the first Section line of the sims .xml file, cut it down to the name. | 43 | # Grab the first Section line of the sims .ini file, cut it down to the name. |
44 | # name=$(getSimName 1) | 44 | # name=$(getSimName 1) |
45 | getSimName() | 45 | getSimName() |
46 | { | 46 | { |
47 | grep "<Section " ${PRGDIR}/../../config/$(num2name $1)/*.xml | head -n 1 | cut -d '"' -f 2 | 47 | grep "RegionName" ${PRGDIR}/../../config/sim$1/*.ini | head -n 1 | cut -d '"' -f 2 |
48 | } | 48 | } |
49 | 49 | ||
50 | 50 | ||
@@ -73,4 +73,3 @@ sleepPerSize() | |||
73 | echo 200 | 73 | echo 200 |
74 | fi | 74 | fi |
75 | } | 75 | } |
76 | |||
diff --git a/scripts/create_sim.sh b/scripts/create_sim.sh deleted file mode 100755 index 0681067..0000000 --- a/scripts/create_sim.sh +++ /dev/null | |||
@@ -1,96 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | source common.sh | ||
4 | getPrgDir | ||
5 | |||
6 | NAME=$1 | ||
7 | LOCATION=$2 | ||
8 | URL=$3 | ||
9 | IP=$4 | ||
10 | SIZE=$5 | ||
11 | |||
12 | OSPATH="/opt/opensim" | ||
13 | cd $OSPATH/config | ||
14 | |||
15 | k=0 | ||
16 | for i in $(seq -w 1 99) | ||
17 | do | ||
18 | j=$(num2name "$i") | ||
19 | if [ -e "$j" ] | ||
20 | then | ||
21 | k=$i | ||
22 | fi | ||
23 | done | ||
24 | |||
25 | if [ "x$NAME" = "x" ] | ||
26 | then | ||
27 | NAME="No name sim $RANDOM" # Should be unique per grid. | ||
28 | echo "WARNING setting the sim name to [$NAME], this may not be what you want." | ||
29 | fi | ||
30 | # Sanitize the name. Not removing [ or ], couldn't get that to work, only important for Windows. | ||
31 | sim=$(sanitize $NAME) | ||
32 | |||
33 | if [ "x$LOCATION" = "x" ] | ||
34 | then | ||
35 | LOCATION="$RANDOM,$RANDOM" # again UNIQUE (i.e. ONLY ONE) per grid in THIS case! | ||
36 | echo "WARNING setting the Location to $LOCATION, this may not be what you want." | ||
37 | fi | ||
38 | |||
39 | if [ "x$IP" = "x" ] | ||
40 | then | ||
41 | # 0.0.0.0 will work for a single sim per physical machine, otherwise we need the real internal IP. | ||
42 | IP="0.0.0.0" | ||
43 | echo "WARNING setting the InternalAddress to $IP, this may not be what you want." | ||
44 | # echo " 0.0.0.0 will work for a single sim per physical machine, otherwise we need the real internal IP." | ||
45 | # According to the OpenSim docs, 0.0.0.0 means to listen on all NICs the machine has, which should work fine. | ||
46 | fi | ||
47 | |||
48 | if [ "x$URL" = "x" ] | ||
49 | then | ||
50 | # Here we make use of an external IP finding service. Careful, it may move. | ||
51 | # URL=$(wget -q http://automation.whatismyip.com/n09230945.asp -O -) # URL is best (without the HTTP://), but IP (e.g. 88.109.81.55) works too. | ||
52 | URL="SYSTEMIP" | ||
53 | echo "WARNING setting the ExternalHostName to $URL, this may not be what you want." | ||
54 | fi | ||
55 | |||
56 | if [ "x$SIZE" = "x" ] | ||
57 | then | ||
58 | SIZE="256" | ||
59 | fi | ||
60 | |||
61 | # Wow, the hoops we have to jump through to avoid octal. | ||
62 | if [ 9 -gt $k ]; then | ||
63 | NUM=$(printf '0%1s' $(( 10#$k + 1 )) ) | ||
64 | else | ||
65 | NUM=$(printf '%2s' $(( 10#$k + 1 )) ) | ||
66 | fi | ||
67 | |||
68 | PORT=$(( 9005 + (10#$k * 5) )) # 9002 is used for HTTP/UDP so START with port 9003! CAUTION Diva/D2 starts at port 9000. | ||
69 | UUID=$(uuidgen) | ||
70 | |||
71 | echo "Creating sim$NUM on port $PORT @ $LOCATION - $NAME." | ||
72 | |||
73 | cp -r sim_skeleton sim$NUM | ||
74 | |||
75 | cd sim$NUM | ||
76 | mv My_sim.xml ${sim}.xml | ||
77 | sed -i "s@SIM_NAME@$NAME@g" ${sim}.xml | ||
78 | sed -i "s@SIM_UUID@$UUID@g" ${sim}.xml | ||
79 | sed -i "s@SIM_POS@$LOCATION@g" ${sim}.xml | ||
80 | sed -i "s@SIM_IP@$IP@g" ${sim}.xml | ||
81 | sed -i "s@SIM_INT_PORT@$(( $PORT + 1 ))@g" ${sim}.xml | ||
82 | sed -i "s@SIM_URL@$URL@g" ${sim}.xml | ||
83 | sed -i "s@SIM_SIZE@$SIZE@g" ${sim}.xml | ||
84 | |||
85 | ln -s ../../current/scripts/common.sh common.sh | ||
86 | ln -s ../../current/scripts/start-sim start-sim | ||
87 | cp -P start-sim backup-sim | ||
88 | cp -P start-sim stop-sim | ||
89 | |||
90 | sed -i "s@SIM_NUMBER@$NUM@g" ThisSim.ini | ||
91 | sed -i "s@SIM_PORT@$PORT@g" ThisSim.ini | ||
92 | |||
93 | sed -i "s@SIM_NUMBER@$NUM@g" opensim-monit.conf | ||
94 | |||
95 | sudo chown -R opensim:opensim .. | ||
96 | sudo chmod -R g+w .. | ||
diff --git a/scripts/fix_var_run.sh b/scripts/fix_var_run.sh deleted file mode 100755 index 97567cb..0000000 --- a/scripts/fix_var_run.sh +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | # Create the opensim run dir. | ||
2 | mkdir -p /var/run/opensim | ||
3 | chown opensim:opensim /var/run/opensim | ||
4 | chmod ug+rwx /var/run/opensim | ||
5 | chmod o-rwx /var/run/opensim | ||
6 | chmod g+s /var/run/opensim | ||
diff --git a/scripts/install/create_sim.sh b/scripts/install/create_sim.sh new file mode 100755 index 0000000..b940315 --- /dev/null +++ b/scripts/install/create_sim.sh | |||
@@ -0,0 +1,75 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | source ../common.sh | ||
4 | getPrgDir | ||
5 | |||
6 | NAME=$1 | ||
7 | LOCATION=$2 | ||
8 | SIZE=$3 | ||
9 | |||
10 | cd ${OS_PATH}/config | ||
11 | |||
12 | k=0 | ||
13 | for i in $(seq -w 1 99) | ||
14 | do | ||
15 | if [ -e "sim$i" ] | ||
16 | then | ||
17 | k=$i | ||
18 | fi | ||
19 | done | ||
20 | |||
21 | if [ "x${NAME}" = "x" ] | ||
22 | then | ||
23 | NAME="No name sim $RANDOM" # Should be unique per grid. | ||
24 | echo "WARNING setting the sim name to [${NAME}], this may not be what you want." | ||
25 | fi | ||
26 | # Sanitize the name. Not removing [ or ], couldn't get that to work, only important for Windows. | ||
27 | sim=$(sanitize ${NAME}) | ||
28 | |||
29 | if [ "x${LOCATION}" = "x" ] | ||
30 | then | ||
31 | LOCATION="$RANDOM,$RANDOM" # again UNIQUE (i.e. ONLY ONE) per grid in THIS case! | ||
32 | echo "WARNING setting the Location to ${LOCATION}, this may not be what you want." | ||
33 | fi | ||
34 | |||
35 | if [ "x${SIZE}" = "x" ] | ||
36 | then | ||
37 | SIZE="256" | ||
38 | fi | ||
39 | |||
40 | # Wow, the hoops we have to jump through to avoid octal. | ||
41 | if [ 9 -gt $k ]; then | ||
42 | NUM=$(printf '0%1s' $(( 10#$k + 1 )) ) | ||
43 | else | ||
44 | NUM=$(printf '%2s' $(( 10#$k + 1 )) ) | ||
45 | fi | ||
46 | |||
47 | PORT=$(( 9005 + (10#$k * 2) )) # 9002 is used for HTTP/UDP so START with port 9003! CAUTION Diva/D2 starts at port 9000. | ||
48 | UUID=$(uuidgen) | ||
49 | |||
50 | echo "Creating sim${NUM} on port ${PORT} @ ${LOCATION} - ${NAME}." | ||
51 | |||
52 | cp -r sim_skeleton sim${NUM} | ||
53 | |||
54 | cd sim${NUM} | ||
55 | sed -i "s@SIM_NAME@${NAME}@g" ThisSim.ini | ||
56 | sed -i "s@SIM_UUID@${UUID}@g" ThisSim.ini | ||
57 | sed -i "s@SIM_POS@${LOCATION}@g" ThisSim.ini | ||
58 | sed -i "s@SIM_INT_PORT@$(( ${PORT} + 1 ))@g" ThisSim.ini | ||
59 | sed -i "s@SIM_SIZE@${SIZE}@g" ThisSim.ini | ||
60 | |||
61 | ln -s ../../current/scripts/common.sh common.sh | ||
62 | ln -s ../../current/scripts/start-sim start-sim | ||
63 | cp -P start-sim backup-sim | ||
64 | cp -P start-sim stop-sim | ||
65 | |||
66 | sed -i "s@SIM_NUMBER@${NUM}@g" ThisSim.ini | ||
67 | sed -i "s@SIM_PORT@${PORT}@g" ThisSim.ini | ||
68 | |||
69 | sed -i "s@OS_PATH@${OS_PATH}@g" opensim-monit.conf | ||
70 | sed -i "s@SIM_NUMBER@${NUM}@g" opensim-monit.conf | ||
71 | |||
72 | mv ThisSim.ini $(sanitize "${NAME}").ini | ||
73 | |||
74 | sudo chown -R ${OS_USER}:${OS_USER} .. | ||
75 | sudo chmod -R g+w .. | ||
diff --git a/scripts/go_live.sh b/scripts/install/go_live.sh index 21d7072..c5ce90e 100755 --- a/scripts/go_live.sh +++ b/scripts/install/go_live.sh | |||
@@ -1,6 +1,6 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | OSPATH="/opt/opensim" | 3 | source common.sh |
4 | 4 | ||
5 | for i in $(seq 99) | 5 | for i in $(seq 99) |
6 | do | 6 | do |
diff --git a/scripts/group_migrate.sql b/scripts/install/group_migrate.sql index 6c15011..6c15011 100644 --- a/scripts/group_migrate.sql +++ b/scripts/install/group_migrate.sql | |||
diff --git a/config/ROBUST/opensim-monit.conf b/scripts/install/opensim-monit.conf index 70190b9..409b69e 100644 --- a/config/ROBUST/opensim-monit.conf +++ b/scripts/install/opensim-monit.conf | |||
@@ -9,23 +9,16 @@ | |||
9 | # on ubuntu/debian, this is overridden by the CHECK_INTERVALS var in | 9 | # on ubuntu/debian, this is overridden by the CHECK_INTERVALS var in |
10 | # /etc/default/monit . the below assumes you've set it to 30 seconds. | 10 | # /etc/default/monit . the below assumes you've set it to 30 seconds. |
11 | # | 11 | # |
12 | # if process dies, will restart sim within 30 seconds. if process | ||
13 | # dies 5 times in as many tries, will stop trying and send email | ||
14 | # alert. | ||
15 | # | ||
16 | # if SimFPS drops to 0 for 2 minutes, restart. | ||
17 | # | ||
18 | # if process CPU usage stays above 300% for 2 minutes, restart. | ||
19 | # | ||
20 | # see ../README for configuration instructions. | 12 | # see ../README for configuration instructions. |
21 | # | 13 | # |
22 | # Hmmmm, seems that monit changing to a user and running bash -l is different from sudo changing to a user and running bash -l. | 14 | # Hmmmm, seems that monit changing to a user and running bash -l is different from sudo changing to a user and running bash -l. |
23 | # | 15 | # |
24 | check process ROBUST with pidfile /var/run/opensim/ROBUST.pid | 16 | check process simSIM_NUMBER with pidfile /OS_PATH/caches/simSIM_NUMBER.pid |
25 | start program = "/usr/bin/sudo -Hu opensim /bin/bash -lc 'cd /opt/opensim/config/ROBUST && /opt/opensim/config/ROBUST/start-sim -q'" | 17 | start program = "/usr/bin/sudo -Hu opensim /bin/bash -lc 'cd /OS_PATH/config/simSIM_NUMBER && /OS_PATH/config/simSIM_NUMBER/start-sim -q'" |
26 | as uid root and gid root | 18 | as uid root and gid root |
27 | stop program = "/usr/bin/sudo -Hu opensim /bin/bash -lc 'cd /opt/opensim/config/ROBUST && /opt/opensim/config/ROBUST/stop-sim'" with timeout 600 seconds | 19 | stop program = "/usr/bin/sudo -Hu opensim /bin/bash -lc 'cd /OS_PATH/config/simSIM_NUMBER && /OS_PATH/config/simSIM_NUMBER/stop-sim'" with timeout 600 seconds |
28 | if cpu usage > 50% for 4 cycles then restart | 20 | if cpu usage > 50% for 4 cycles then restart |
21 | if MEMORY usage > 10% for 4 cycles then restart | ||
29 | # if 5 restarts within 5 cycles then timeout | 22 | # if 5 restarts within 5 cycles then timeout |
30 | # if failed url http://127.0.0.1:9005/jsonSimStats/ | 23 | # if failed url http://127.0.0.1:9005/jsonSimStats/ |
31 | # and content != '"SimFPS":0.0,' for 4 cycles | 24 | # and content != '"SimFPS":0.0,' for 4 cycles |
@@ -33,4 +26,4 @@ check process ROBUST with pidfile /var/run/opensim/ROBUST.pid | |||
33 | # if failed url http://127.0.0.1:9008/jsonSimStats/ | 26 | # if failed url http://127.0.0.1:9008/jsonSimStats/ |
34 | # and content == '"SimFPS":' for 4 cycles | 27 | # and content == '"SimFPS":' for 4 cycles |
35 | # then restart | 28 | # then restart |
36 | 29 | depends on ROBUST | |
diff --git a/scripts/install/opensim.tmux.conf b/scripts/install/opensim.tmux.conf new file mode 100644 index 0000000..84e0c21 --- /dev/null +++ b/scripts/install/opensim.tmux.conf | |||
@@ -0,0 +1,97 @@ | |||
1 | # Tmux has a habit of changing what these options are for each version, so this is a bit of a mess. | ||
2 | |||
3 | # Screen compatibility, change the command key. And rebind the prefix sending command. | ||
4 | set-option -g prefix C-a | ||
5 | unbind-key C-b | ||
6 | bind-key C-a send-prefix | ||
7 | |||
8 | # r reloads the configuration, handy | ||
9 | bind r source-file ~/.tmux.conf | ||
10 | |||
11 | bind R clear-history | ||
12 | |||
13 | # More sane pane gain. B-) | ||
14 | unbind % # Remove default binding since we’re replacing them. | ||
15 | unbind '"' | ||
16 | bind | split-window -h | ||
17 | bind - split-window -v | ||
18 | |||
19 | # set-options -g global, -s server, -w window, otherwise a session option. | ||
20 | # -a appends a string to the existing option. | ||
21 | # -u unsets an option. | ||
22 | # -o prevents setting an aption if it is already set. | ||
23 | # -q shut up info messages. | ||
24 | |||
25 | # SESSION OPTIONS | ||
26 | |||
27 | set-option -g bell-action any | ||
28 | set-option -g bell-on-alert on | ||
29 | |||
30 | # Not actually documented what the limit is, but there is one. | ||
31 | set-option -g history-limit 100000 | ||
32 | |||
33 | # All this mouse stuff is unreliable in UTF8 mode. At least on roxterm. | ||
34 | # Also keep in mind the terminal specs mouse report limit of 256 characters, being less than my typical terminal width. | ||
35 | # Hmm, still wont pass mouse through like the docs say they will. | ||
36 | # Ah, mc needs "mc -x". Though once again, watch that right edge on huge terminals. | ||
37 | # These three wont work under Ubuntu 16.04. | ||
38 | ##set-option -g mouse-resize-pane on | ||
39 | ##set-option -g mouse-select-pane on | ||
40 | ##set-option -g mouse-select-window on | ||
41 | # This wont work under Ubuntu 16.04. | ||
42 | ##set-option -g mode-mouse on # on - mouse does copy mode stuff; copy-mode - mouse can't go into copy mode, but does stuff once in there; off - mouse is unmolested. | ||
43 | # Instead do this (also defaults to turning on the above three mouse things) - | ||
44 | set-option -g mouse on | ||
45 | # Or this. sigh | ||
46 | #set-option -g mouse | ||
47 | ##set-option -g mouse-utf8 off # Defaults to on. | ||
48 | |||
49 | set-option -g set-remain-on-exit on | ||
50 | |||
51 | # How to set the title of the terminal window. | ||
52 | set-option -g set-titles on | ||
53 | set-option -g set-titles-string '#W' # Default is "#S:#I:#W - "#T"" | ||
54 | |||
55 | set-option -g status-interval 1 # Redraw status line every second, for the clock. | ||
56 | set-option -g status-justify centre # Window list in the middle. | ||
57 | ##set-option -g status-utf8 on | ||
58 | |||
59 | # Character pair Replaced with | ||
60 | #(shell-command) First line of the command's output | ||
61 | #[attributes] Colour or attribute change | ||
62 | #H Hostname of local host (not FDQN) | ||
63 | #h Hostname of local host without the domain name | ||
64 | #F Current window flag | ||
65 | #I Current window index | ||
66 | #D Current pane unique identifier | ||
67 | #P Current pane index | ||
68 | #S Session name | ||
69 | #T Current pane title | ||
70 | #W Current window name | ||
71 | ## A literal ‘#’ | ||
72 | |||
73 | # Yes, my terminal really is bigger than 160 characters. | ||
74 | set-option -g status-left-length 42 | ||
75 | #set-option -g status-left '[#H #S #F]' | ||
76 | set-option -g status-left '#H [#S:#I.#P]#F' | ||
77 | set-option -g status-right-length 64 | ||
78 | set-option -g status-right "%F #(uptime | cut -d ' ' -f 2-2,10-)" # %F is ISO date, uptime starts with the current time, and ends with the load average. B-) | ||
79 | |||
80 | # Set window notifications | ||
81 | set-option -g visual-activity on # Show status message for activity in monitor-activity windows. | ||
82 | #set-option -g visual-content on # Show status message for content in monitor-content windows. Based on a fnmatch(3) string. | ||
83 | set-option -g visual-silence on # Show status message for silence in monitor-silence windows. Based on a set interval. | ||
84 | |||
85 | set-option -gw alternate-screen off # Don't save the original screen before starting tmux, may also allow use of the terminals original scrollback buffer. | ||
86 | set-option -gw clock-mode-style 24 # We are using the uptime clock anyway, so this is pointless. | ||
87 | |||
88 | # Highlight active window | ||
89 | set-option -gw window-status-current-bg red | ||
90 | set-option -gw window-status-current-format '[#I:#W]' | ||
91 | set-option -gw window-status-format '[#I:#W]#F' | ||
92 | |||
93 | # Set window notifications | ||
94 | set-option -gw monitor-activity on # Bell on activity. | ||
95 | |||
96 | # We want 256 colours in our terminal. | ||
97 | set-option -g default-terminal "screen-256color" | ||
diff --git a/scripts/install/secure.sh b/scripts/install/secure.sh new file mode 100755 index 0000000..95aae84 --- /dev/null +++ b/scripts/install/secure.sh | |||
@@ -0,0 +1,26 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | source ../common.sh | ||
4 | |||
5 | echo "Securing OpenSim." | ||
6 | sudo chmod 600 ${OS_PATH}/config/*.ini | ||
7 | sudo chmod 600 ${OS_PATH}/config/ROBUST/*.ini | ||
8 | sudo chown -R ${OS_USER}:${OS_USER} ${OS_PATH} | ||
9 | sudo chmod -R 775 ${OS_PATH} | ||
10 | sudo chmod -R a-x ${OS_PATH} | ||
11 | sudo chmod -R a+X ${OS_PATH} | ||
12 | sudo chmod -R g+w ${OS_PATH} | ||
13 | sudo chmod -R a+x ${OS_PATH}/current/*.sh | ||
14 | sudo chmod -R a+x ${OS_PATH}/current/scripts/*.sh | ||
15 | sudo chmod -R a+x ${OS_PATH}/current/scripts/install/*.sh | ||
16 | sudo chmod a+x ${OS_PATH}/current/scripts/show-console | ||
17 | sudo chmod a+x ${OS_PATH}/current/scripts/start-sim | ||
18 | |||
19 | sudo chmod ug+rwx ${OS_PATH}/config | ||
20 | sudo chmod g+s ${OS_PATH}/config | ||
21 | sudo chmod 600 ${OS_PATH}/config/*.ini | ||
22 | sudo chmod 600 ${OS_PATH}/config/ROBUST/*.ini | ||
23 | |||
24 | chmod ug+rwx ${OS_PATH}/caches | ||
25 | chmod o-rwx ${OS_PATH}/caches | ||
26 | chmod g+s ${OS_PATH}/caches | ||
diff --git a/scripts/opensim.tmux.conf b/scripts/opensim.tmux.conf deleted file mode 100644 index ea342a2..0000000 --- a/scripts/opensim.tmux.conf +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | # Tmux has a habit of changing what these options are for each version, so this is a bit of a mess. | ||
2 | |||
3 | set-option -g prefix C-a | ||
4 | unbind-key C-b | ||
5 | bind-key C-a send-prefix | ||
6 | |||
7 | # r reloads the configuration, handy | ||
8 | bind r source-file ~/.tmux.conf | ||
9 | |||
10 | unbind % # Remove default binding since we’re replacing them. | ||
11 | bind | split-window -h | ||
12 | bind - split-window -v | ||
13 | |||
14 | set-option -g bell-action any | ||
15 | set-option -g bell-on-alert on | ||
16 | |||
17 | set-option -g history-limit 100000 | ||
18 | |||
19 | # These three wont work under Ubuntu 16.04. | ||
20 | set-option -g mouse-resize-pane on | ||
21 | set-option -g mouse-select-pane on | ||
22 | set-option -g mouse-select-window on | ||
23 | set-option -g mouse-utf8 on | ||
24 | |||
25 | #set-option -g set-remain-on-exit on | ||
26 | set-option -g set-titles on | ||
27 | set-option -g set-titles-string '#W' | ||
28 | |||
29 | set-option -g status-interval 1 | ||
30 | set-option -g status-justify centre | ||
31 | set-option -g status-utf8 on | ||
32 | |||
33 | set-option -g status-left-length 80 | ||
34 | set-option -g status-left '[#H #S #F]' | ||
35 | set-option -g status-right-length 80 | ||
36 | set-option -g status-right '%F #(uptime)'<-----># &F is ISO date, uptime starts with the current time, and ends with the load average. B-) | ||
37 | |||
38 | set-option -g visual-activity on | ||
39 | set-option -g visual-content on | ||
40 | set-option -g visual-silence on | ||
41 | |||
42 | set-option -gw clock-mode-style 24 | ||
43 | # This wont work under Ubuntu 16.04. | ||
44 | set-option -gw mode-mouse on | ||
45 | # Instead do this (also defaults to turning on the above three mouse things) - | ||
46 | #set-option -gw mouse on | ||
47 | |||
48 | # Highlight active window | ||
49 | set-option -gw window-status-current-bg red | ||
50 | |||
51 | # Set window notifications | ||
52 | set-option -gw monitor-activity on | ||
diff --git a/scripts/show-console b/scripts/show-console index ddeba86..e7fb941 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" \; attach-session -t "OpenSimSC" |
diff --git a/scripts/start-sim b/scripts/start-sim index bd0815f..48c530a 100755 --- a/scripts/start-sim +++ b/scripts/start-sim | |||
@@ -4,14 +4,17 @@ source common.sh | |||
4 | getPrgDir | 4 | getPrgDir |
5 | 5 | ||
6 | USER=$(whoami) | 6 | USER=$(whoami) |
7 | console_name="OpenSim_console" | 7 | console_name="OpenSimSC" |
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}" |
12 | bindir="${PRGDIR}/../bin" | 12 | bindir="${PRGDIR}/../bin" |
13 | date=$(date '+%F_%T') | 13 | date=$(date '+%F_%T') |
14 | all="" | ||
15 | delay=45 | ||
14 | quiet="" | 16 | quiet="" |
17 | waiting="" | ||
15 | inventory="" | 18 | inventory="" |
16 | 19 | ||
17 | function wait_for_text() | 20 | function wait_for_text() |
@@ -22,27 +25,77 @@ function wait_for_text() | |||
22 | done | 25 | done |
23 | } | 26 | } |
24 | 27 | ||
25 | if [ $USER = "opensim" ] | 28 | |
29 | if [ $USER = "${OS_USER}" ] | ||
26 | then | 30 | then |
27 | SUDO="" | 31 | SUDO="" |
28 | else | 32 | else |
29 | SUDO="sudo -Hu opensim" | 33 | SUDO="sudo -Hu ${OS_USER}" |
34 | fi | ||
35 | |||
36 | if [ "$1" = "-a" ] | ||
37 | then | ||
38 | all="-a" | ||
39 | shift 1 | ||
40 | fi | ||
41 | |||
42 | if [ "$1" = "-d" ] | ||
43 | then | ||
44 | delay=$2 | ||
45 | shift 2 | ||
30 | fi | 46 | fi |
31 | 47 | ||
32 | if [ "$1" = "-q" ] | 48 | if [ "$1" = "-q" ] |
33 | then | 49 | then |
34 | quiet="true" | 50 | quiet="-q" |
51 | shift 1 | ||
52 | fi | ||
53 | |||
54 | if [ "$1" = "-w" ] | ||
55 | then | ||
56 | waiting="-w" | ||
35 | shift 1 | 57 | shift 1 |
36 | fi | 58 | fi |
37 | 59 | ||
38 | if [ "x$1" = "x" ]; then | 60 | if [ "x$1" = "x" ]; then |
39 | tgt=$(basename $(pwd)) | 61 | tgt=$(basename $(pwd)) |
62 | # These checks are kludgy. | ||
63 | if [ "$tgt" = "scripts" ]; then | ||
64 | all="-a" | ||
65 | cd ${PRGDIR}/../../config/ROBUST | ||
66 | tgt="ROBUST" | ||
67 | fi | ||
68 | if [ "$tgt" = "bin" ]; then | ||
69 | uptime | ||
70 | wait_for_text "ROBUST" "INITIALIZATION COMPLETE FOR ROBUST" | ||
71 | if [ ! "x$all" = "x" ] | ||
72 | then | ||
73 | echo "Sleeping for $((${delay} / 2)) seconds." | ||
74 | sleep $((${delay} / 2)) | ||
75 | for i in $(seq -w 1 99) | ||
76 | do | ||
77 | if [ -e "${PRGDIR}/../../config/sim${i}" ] | ||
78 | then | ||
79 | uptime | ||
80 | echo "Starting sim${i}." | ||
81 | cd ${PRGDIR}/../../config/sim${i}; ./start-sim -w | ||
82 | uptime | ||
83 | # Sleep for a while, so that there is plenty of time to finish starting scripts and such, | ||
84 | # and we are not keeping the computer very busy if there are lots of sims. | ||
85 | echo "Sleeping for ${delay} seconds." | ||
86 | sleep ${delay} | ||
87 | fi | ||
88 | done | ||
89 | uptime | ||
90 | fi | ||
91 | exit 0 | ||
92 | fi | ||
40 | num="$(echo ${tgt} | cut -c 4-)" | 93 | num="$(echo ${tgt} | cut -c 4-)" |
41 | elif [ -d "./$1" ]; then | 94 | elif [ -d "$1" ]; then |
42 | tgt=$1 | 95 | tgt=$1 |
43 | elif [ -d "./sim$1" ]; then | 96 | elif [ -d "sim$1" ]; then |
44 | num=$1 | 97 | num=$1 |
45 | tgt="./sim${num}" | 98 | tgt="sim${num}" |
46 | else | 99 | else |
47 | tgt=$1 | 100 | tgt=$1 |
48 | inventory=$1 | 101 | inventory=$1 |
@@ -61,8 +114,8 @@ if ( ${tmux_command} -q list-sessions 2>/dev/null | grep -q ${console_name}: ); | |||
61 | true | 114 | true |
62 | else | 115 | else |
63 | # The sudo is only so that the session is owned by opensim, otherwise it's owned by whoever ran this script, which is a likely security hole. | 116 | # The sudo is only so that the session is owned by opensim, otherwise it's owned by whoever ran this script, which is a likely security hole. |
64 | # 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. | 117 | # After the session is created, we rely on the ${PRGDIR}/../../caches/ directory to be group sticky, so that anyone in the opensim group can attach to the tmux socket. |
65 | $SUDO ${tmux_command} new-session -d -s ${console_name} -n "Server" | 118 | $SUDO ${tmux_command} new-session -d -s ${console_name} -n "ROBUST" |
66 | fi | 119 | fi |
67 | 120 | ||
68 | 121 | ||
@@ -71,36 +124,37 @@ if [ "x$tgt" = "xROBUST" ]; then | |||
71 | title="ROBUST" | 124 | title="ROBUST" |
72 | elif [ "x$inventory" = "x" ]; then | 125 | elif [ "x$inventory" = "x" ]; then |
73 | exe="OpenSim" | 126 | exe="OpenSim" |
74 | # Grab the first Section line of the sims .xml file, cut it down to the name. | 127 | # Grab the first RegionName line of the sims .ini file, cut it down to the name. |
75 | title=$(getSimName ${num}) | 128 | title=$(getSimName ${num}) |
76 | fi | 129 | fi |
77 | 130 | ||
78 | case $(basename $0) in | 131 | case $(basename $0) in |
79 | "start-sim") | 132 | "start-sim") |
80 | cmd="mono ${exe}.exe -inidirectory=${tgt} " | 133 | cmd="mono ${exe}.exe -inidirectory=../../config/${tgt} " |
81 | 134 | ||
82 | # Check if it's already running. | 135 | # Check if it's already running. |
83 | if [ -e /var/run/opensim/${tgt}.pid ] | 136 | if [ -e ${PRGDIR}/../../caches/${tgt}.pid ] |
84 | then | 137 | then |
85 | # Double check if it's REALLY running. | 138 | # Double check if it's REALLY running. |
86 | if [ "x$(ps -p $(cat /var/run/opensim/${tgt}.pid) --no-headers -o comm)" = "x" ]; then | 139 | if [ "x$(ps -p $(cat ${PRGDIR}/../../caches/${tgt}.pid) --no-headers -o comm)" = "x" ]; then |
87 | $SUDO rm -f /var/run/opensim/${tgt}.pid | 140 | $SUDO rm -f ${PRGDIR}/../../caches/${tgt}.pid |
88 | fi | 141 | fi |
89 | fi | 142 | fi |
90 | # Now see if it's really really running. lol | 143 | # Now see if it's really really running. lol |
91 | if [ ! -e /var/run/opensim/${tgt}.pid ] | 144 | if [ ! -e ${PRGDIR}/../../caches/${tgt}.pid ] |
92 | then | 145 | then |
93 | if [ "x$tgt" = "xROBUST" ]; then | 146 | if [ "x$tgt" = "xROBUST" ]; then |
94 | # TODO - the problem here is that the > bit is executed as onefang, not as opensim. | ||
95 | $SUDO cat ../config/config.ini ../config/Robust.ini.template >../config/Robust.ini | ||
96 | # $SUDO chown -R opensim:opensim ../config/Robust.ini | ||
97 | chmod 640 ../config/Robust.ini | ||
98 | ${tmux_command} split-window -hp 50 -t "${tmux_session}:" "${cmd}" | 147 | ${tmux_command} split-window -hp 50 -t "${tmux_session}:" "${cmd}" |
99 | else | 148 | else |
100 | ${tmux_command} new-window -dn "${title}" -t "${tmux_session}:${num}" "${cmd}" | 149 | ${tmux_command} new-window -dn "${title}" -t "${tmux_session}:${num}" "${cmd}" |
101 | fi | 150 | fi |
102 | fi | 151 | fi |
103 | 152 | ||
153 | if [ ! "x$all" = "x" ] | ||
154 | then | ||
155 | ${tmux_send}:ROBUST.{left} "../scripts/start-sim -a -d ${delay}" Enter | ||
156 | fi | ||
157 | |||
104 | if [ "x$quiet" = "x" ] | 158 | if [ "x$quiet" = "x" ] |
105 | then | 159 | then |
106 | if [ "x$tgt" = "xROBUST" ]; then | 160 | if [ "x$tgt" = "xROBUST" ]; then |
@@ -108,7 +162,10 @@ case $(basename $0) in | |||
108 | fi | 162 | fi |
109 | fi | 163 | fi |
110 | 164 | ||
111 | ${tmux_send}:"${title}" Enter Enter Enter | 165 | if [ ! "x$waiting" = "x" ] |
166 | then | ||
167 | wait_for_text "${title}" "INITIALIZATION COMPLETE FOR ${title}" | ||
168 | fi | ||
112 | ;; | 169 | ;; |
113 | 170 | ||
114 | "backup-inventory") | 171 | "backup-inventory") |
@@ -124,7 +181,7 @@ case $(basename $0) in | |||
124 | ;; | 181 | ;; |
125 | 182 | ||
126 | "backup-sim") | 183 | "backup-sim") |
127 | if [ -e /var/run/opensim/${tgt}.pid ]; then | 184 | if [ -e ${PRGDIR}/../../caches/${tgt}.pid ]; then |
128 | cd ${PRGDIR} | 185 | cd ${PRGDIR} |
129 | $SUDO ${PRGDIR}/gitAR.sh o "${title}" | 186 | $SUDO ${PRGDIR}/gitAR.sh o "${title}" |
130 | sim=$(sanitize "${title}") | 187 | sim=$(sanitize "${title}") |
@@ -141,7 +198,7 @@ case $(basename $0) in | |||
141 | ;; | 198 | ;; |
142 | 199 | ||
143 | "stop-sim") | 200 | "stop-sim") |
144 | if [ -e /var/run/opensim/${tgt}.pid ]; then | 201 | if [ -e ${PRGDIR}/../../caches/${tgt}.pid ]; then |
145 | ${tmux_send}:"${title}" "alert WARNING - Emergency shutdown in one minute!" Enter | 202 | ${tmux_send}:"${title}" "alert WARNING - Emergency shutdown in one minute!" Enter |
146 | ${tmux_send}:"${title}" "alert WARNING - Emergency shutdown in one minute!" Enter | 203 | ${tmux_send}:"${title}" "alert WARNING - Emergency shutdown in one minute!" Enter |
147 | sleep 30 | 204 | sleep 30 |
@@ -150,9 +207,9 @@ case $(basename $0) in | |||
150 | sleep 30 | 207 | sleep 30 |
151 | ${tmux_send}:"${title}" "shutdown" Enter | 208 | ${tmux_send}:"${title}" "shutdown" Enter |
152 | sleep 30 | 209 | sleep 30 |
153 | if [ -e /var/run/opensim/${tgt}.pid ]; then | 210 | if [ -e ${PRGDIR}/../../caches/${tgt}.pid ]; then |
154 | echo "Killing it with extreme prejudice!" | 211 | echo "Killing it with extreme prejudice!" |
155 | kill -TERM `cat /var/run/opensim/${tgt}.pid` | 212 | kill -TERM `cat ${PRGDIR}/../../caches/${tgt}.pid` |
156 | fi | 213 | fi |
157 | else | 214 | else |
158 | echo "Sim ${title} is not running, so not stopping." | 215 | echo "Sim ${title} is not running, so not stopping." |