diff options
author | onefang | 2019-05-21 04:41:57 +1000 |
---|---|---|
committer | onefang | 2019-05-21 04:41:57 +1000 |
commit | 8723177732fe0843116a81b5c935cb440799e243 (patch) | |
tree | 94b2018d492c321c6ae69c79e812353a1d831fbf /scripts/install | |
parent | Typo-- (diff) | |
download | opensim-SC-8723177732fe0843116a81b5c935cb440799e243.zip opensim-SC-8723177732fe0843116a81b5c935cb440799e243.tar.gz opensim-SC-8723177732fe0843116a81b5c935cb440799e243.tar.bz2 opensim-SC-8723177732fe0843116a81b5c935cb440799e243.tar.xz |
Move install related scripts and stuff into their own directory.
Diffstat (limited to 'scripts/install')
-rwxr-xr-x | scripts/install/create_sim.sh | 96 | ||||
-rwxr-xr-x | scripts/install/go_live.sh | 12 | ||||
-rw-r--r-- | scripts/install/group_migrate.sql | 48 | ||||
-rw-r--r-- | scripts/install/opensim-monit.conf | 36 | ||||
-rw-r--r-- | scripts/install/opensim.tmux.conf | 52 |
5 files changed, 244 insertions, 0 deletions
diff --git a/scripts/install/create_sim.sh b/scripts/install/create_sim.sh new file mode 100755 index 0000000..0681067 --- /dev/null +++ b/scripts/install/create_sim.sh | |||
@@ -0,0 +1,96 @@ | |||
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/install/go_live.sh b/scripts/install/go_live.sh new file mode 100755 index 0000000..21d7072 --- /dev/null +++ b/scripts/install/go_live.sh | |||
@@ -0,0 +1,12 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | OSPATH="/opt/opensim" | ||
4 | |||
5 | for i in $(seq 99) | ||
6 | do | ||
7 | j=$(printf "sim%02d" $i) | ||
8 | if [ -e "$OSPATH/config/$j" ] | ||
9 | then | ||
10 | sudo ln -s $OSPATH/config/$j/opensim-monit.conf /etc/monit/conf.d/$j.conf | ||
11 | fi | ||
12 | done | ||
diff --git a/scripts/install/group_migrate.sql b/scripts/install/group_migrate.sql new file mode 100644 index 0000000..6c15011 --- /dev/null +++ b/scripts/install/group_migrate.sql | |||
@@ -0,0 +1,48 @@ | |||
1 | INSERT INTO `griddy`.`os_groups_groups` | ||
2 | (GroupID, Name, Charter, InsigniaID, FounderID, MembershipFee, OpenEnrollment, ShowInList, | ||
3 | AllowPublish, MaturePublish, OwnerRoleID) | ||
4 | SELECT GroupID, Name, Charter, InsigniaID, FounderID, MemberShipFee, OpenEnrollment, ShowInList, AllowPublish, | ||
5 | MaturePublish, OwnerRoleID | ||
6 | FROM `griddy`.osgroup; | ||
7 | |||
8 | /*fill os_groups_invites in ROBUST database with values from osgroupinvite | ||
9 | or FlotSam osgroupinvite*/ | ||
10 | INSERT INTO `griddy`.`os_groups_invites` | ||
11 | (InviteID, GroupID, RoleID, PrincipalID, TMStamp) | ||
12 | SELECT InviteID, GroupID, RoleID, AgentID, TMStamp | ||
13 | FROM `griddy`.osgroupinvite; | ||
14 | |||
15 | /*fill os_groups_membership in ROBUST database with values from osgroupmembership | ||
16 | or FlotSam osgroupmembership*/ | ||
17 | INSERT INTO `griddy`.`os_groups_membership` | ||
18 | (GroupID, PrincipalID, SelectedRoleID, Contribution, ListInProfile, AcceptNotices) | ||
19 | SELECT GroupID, AgentID, SelectedRoleID, Contribution, ListInProfile, AcceptNotices | ||
20 | FROM `griddy`.osgroupmembership; | ||
21 | |||
22 | /*fill os_groups_notices in ROBUST database with values from osgroupnotice | ||
23 | or FlotSam osgroupnotice*/ | ||
24 | INSERT INTO `griddy`.`os_groups_notices` | ||
25 | (GroupID, NoticeID, TMStamp, FromName, Subject, Message) | ||
26 | SELECT GroupID, NoticeID, Timestamp, FromName, Subject, Message | ||
27 | FROM `griddy`.osgroupnotice; | ||
28 | |||
29 | /*fill os_groups_principals in ROBUST database with values from osagent | ||
30 | or FlotSam osagent*/ | ||
31 | INSERT INTO `griddy`.`os_groups_principals` | ||
32 | (PrincipalID, ActiveGroupID) | ||
33 | SELECT AgentID, ActiveGroupID | ||
34 | FROM `griddy`.osagent; | ||
35 | |||
36 | /*fill os_groups_rolemembership in ROBUST database with values from osrolemembership | ||
37 | or FlotSam osgrouprolemembership*/ | ||
38 | INSERT INTO `griddy`.os_groups_rolemembership | ||
39 | (GroupID, RoleID, PrincipalID) | ||
40 | SELECT GroupID, RoleID, AgentID | ||
41 | FROM `griddy`.osgrouprolemembership; | ||
42 | |||
43 | /*fill os_groups_roles in ROBUST database with values from osroles | ||
44 | or FlotSam osrole*/ | ||
45 | INSERT INTO `griddy`.os_groups_roles | ||
46 | (GroupID, RoleID, Name, Description, Title, Powers) | ||
47 | SELECT GroupID, RoleID, Name, Description, Title, Powers | ||
48 | FROM `griddy`.osrole; | ||
diff --git a/scripts/install/opensim-monit.conf b/scripts/install/opensim-monit.conf new file mode 100644 index 0000000..7785056 --- /dev/null +++ b/scripts/install/opensim-monit.conf | |||
@@ -0,0 +1,36 @@ | |||
1 | # manage the OpenSim process for Your Sim | ||
2 | # | ||
3 | # usage: | ||
4 | # monit start your_sim | ||
5 | # monit stop your_sim | ||
6 | # monit restart your_sim | ||
7 | # | ||
8 | # see 'daemon' setting in /etc/monit/monitrc for the cycle length. | ||
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. | ||
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. | ||
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. | ||
23 | # | ||
24 | check process sim01 with pidfile /var/run/opensim/sim01.pid | ||
25 | start program = "/usr/bin/sudo -Hu opensim /bin/bash -lc 'cd /opt/opensim/config/sim01 && /opt/opensim/config/sim01/start-sim -q'" | ||
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 | ||
28 | if cpu usage > 50% for 4 cycles then restart | ||
29 | # if 5 restarts within 5 cycles then timeout | ||
30 | # if failed url http://127.0.0.1:9005/jsonSimStats/ | ||
31 | # and content != '"SimFPS":0.0,' for 4 cycles | ||
32 | # then restart | ||
33 | # if failed url http://127.0.0.1:9008/jsonSimStats/ | ||
34 | # and content == '"SimFPS":' for 4 cycles | ||
35 | # then restart | ||
36 | |||
diff --git a/scripts/install/opensim.tmux.conf b/scripts/install/opensim.tmux.conf new file mode 100644 index 0000000..ea342a2 --- /dev/null +++ b/scripts/install/opensim.tmux.conf | |||
@@ -0,0 +1,52 @@ | |||
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 | ||