From 8723177732fe0843116a81b5c935cb440799e243 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 21 May 2019 04:41:57 +1000 Subject: Move install related scripts and stuff into their own directory. --- scripts/create_sim.sh | 96 -------------------------------------- scripts/go_live.sh | 12 ----- scripts/group_migrate.sql | 48 ------------------- scripts/install/create_sim.sh | 96 ++++++++++++++++++++++++++++++++++++++ scripts/install/go_live.sh | 12 +++++ scripts/install/group_migrate.sql | 48 +++++++++++++++++++ scripts/install/opensim-monit.conf | 36 ++++++++++++++ scripts/install/opensim.tmux.conf | 52 +++++++++++++++++++++ scripts/opensim-monit.conf | 36 -------------- scripts/opensim.tmux.conf | 52 --------------------- 10 files changed, 244 insertions(+), 244 deletions(-) delete mode 100755 scripts/create_sim.sh delete mode 100755 scripts/go_live.sh delete mode 100644 scripts/group_migrate.sql create mode 100755 scripts/install/create_sim.sh create mode 100755 scripts/install/go_live.sh create mode 100644 scripts/install/group_migrate.sql create mode 100644 scripts/install/opensim-monit.conf create mode 100644 scripts/install/opensim.tmux.conf delete mode 100644 scripts/opensim-monit.conf delete mode 100644 scripts/opensim.tmux.conf (limited to 'scripts') 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 @@ -#!/bin/bash - -source common.sh -getPrgDir - -NAME=$1 -LOCATION=$2 -URL=$3 -IP=$4 -SIZE=$5 - -OSPATH="/opt/opensim" -cd $OSPATH/config - -k=0 -for i in $(seq -w 1 99) -do - j=$(num2name "$i") - if [ -e "$j" ] - then - k=$i - fi -done - -if [ "x$NAME" = "x" ] -then - NAME="No name sim $RANDOM" # Should be unique per grid. - echo "WARNING setting the sim name to [$NAME], this may not be what you want." -fi -# Sanitize the name. Not removing [ or ], couldn't get that to work, only important for Windows. -sim=$(sanitize $NAME) - -if [ "x$LOCATION" = "x" ] -then - LOCATION="$RANDOM,$RANDOM" # again UNIQUE (i.e. ONLY ONE) per grid in THIS case! - echo "WARNING setting the Location to $LOCATION, this may not be what you want." -fi - -if [ "x$IP" = "x" ] -then - # 0.0.0.0 will work for a single sim per physical machine, otherwise we need the real internal IP. - IP="0.0.0.0" - echo "WARNING setting the InternalAddress to $IP, this may not be what you want." -# echo " 0.0.0.0 will work for a single sim per physical machine, otherwise we need the real internal IP." -# According to the OpenSim docs, 0.0.0.0 means to listen on all NICs the machine has, which should work fine. -fi - -if [ "x$URL" = "x" ] -then -# Here we make use of an external IP finding service. Careful, it may move. -# 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. - URL="SYSTEMIP" - echo "WARNING setting the ExternalHostName to $URL, this may not be what you want." -fi - -if [ "x$SIZE" = "x" ] -then - SIZE="256" -fi - -# Wow, the hoops we have to jump through to avoid octal. -if [ 9 -gt $k ]; then - NUM=$(printf '0%1s' $(( 10#$k + 1 )) ) -else - NUM=$(printf '%2s' $(( 10#$k + 1 )) ) -fi - -PORT=$(( 9005 + (10#$k * 5) )) # 9002 is used for HTTP/UDP so START with port 9003! CAUTION Diva/D2 starts at port 9000. -UUID=$(uuidgen) - -echo "Creating sim$NUM on port $PORT @ $LOCATION - $NAME." - -cp -r sim_skeleton sim$NUM - -cd sim$NUM -mv My_sim.xml ${sim}.xml -sed -i "s@SIM_NAME@$NAME@g" ${sim}.xml -sed -i "s@SIM_UUID@$UUID@g" ${sim}.xml -sed -i "s@SIM_POS@$LOCATION@g" ${sim}.xml -sed -i "s@SIM_IP@$IP@g" ${sim}.xml -sed -i "s@SIM_INT_PORT@$(( $PORT + 1 ))@g" ${sim}.xml -sed -i "s@SIM_URL@$URL@g" ${sim}.xml -sed -i "s@SIM_SIZE@$SIZE@g" ${sim}.xml - -ln -s ../../current/scripts/common.sh common.sh -ln -s ../../current/scripts/start-sim start-sim -cp -P start-sim backup-sim -cp -P start-sim stop-sim - -sed -i "s@SIM_NUMBER@$NUM@g" ThisSim.ini -sed -i "s@SIM_PORT@$PORT@g" ThisSim.ini - -sed -i "s@SIM_NUMBER@$NUM@g" opensim-monit.conf - -sudo chown -R opensim:opensim .. -sudo chmod -R g+w .. diff --git a/scripts/go_live.sh b/scripts/go_live.sh deleted file mode 100755 index 21d7072..0000000 --- a/scripts/go_live.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -OSPATH="/opt/opensim" - -for i in $(seq 99) -do - j=$(printf "sim%02d" $i) - if [ -e "$OSPATH/config/$j" ] - then - sudo ln -s $OSPATH/config/$j/opensim-monit.conf /etc/monit/conf.d/$j.conf - fi -done diff --git a/scripts/group_migrate.sql b/scripts/group_migrate.sql deleted file mode 100644 index 6c15011..0000000 --- a/scripts/group_migrate.sql +++ /dev/null @@ -1,48 +0,0 @@ -INSERT INTO `griddy`.`os_groups_groups` -(GroupID, Name, Charter, InsigniaID, FounderID, MembershipFee, OpenEnrollment, ShowInList, -AllowPublish, MaturePublish, OwnerRoleID) -SELECT GroupID, Name, Charter, InsigniaID, FounderID, MemberShipFee, OpenEnrollment, ShowInList, AllowPublish, -MaturePublish, OwnerRoleID -FROM `griddy`.osgroup; - -/*fill os_groups_invites in ROBUST database with values from osgroupinvite -or FlotSam osgroupinvite*/ -INSERT INTO `griddy`.`os_groups_invites` -(InviteID, GroupID, RoleID, PrincipalID, TMStamp) -SELECT InviteID, GroupID, RoleID, AgentID, TMStamp -FROM `griddy`.osgroupinvite; - -/*fill os_groups_membership in ROBUST database with values from osgroupmembership -or FlotSam osgroupmembership*/ -INSERT INTO `griddy`.`os_groups_membership` -(GroupID, PrincipalID, SelectedRoleID, Contribution, ListInProfile, AcceptNotices) -SELECT GroupID, AgentID, SelectedRoleID, Contribution, ListInProfile, AcceptNotices -FROM `griddy`.osgroupmembership; - -/*fill os_groups_notices in ROBUST database with values from osgroupnotice -or FlotSam osgroupnotice*/ -INSERT INTO `griddy`.`os_groups_notices` -(GroupID, NoticeID, TMStamp, FromName, Subject, Message) -SELECT GroupID, NoticeID, Timestamp, FromName, Subject, Message -FROM `griddy`.osgroupnotice; - -/*fill os_groups_principals in ROBUST database with values from osagent -or FlotSam osagent*/ -INSERT INTO `griddy`.`os_groups_principals` -(PrincipalID, ActiveGroupID) -SELECT AgentID, ActiveGroupID -FROM `griddy`.osagent; - -/*fill os_groups_rolemembership in ROBUST database with values from osrolemembership -or FlotSam osgrouprolemembership*/ -INSERT INTO `griddy`.os_groups_rolemembership -(GroupID, RoleID, PrincipalID) -SELECT GroupID, RoleID, AgentID -FROM `griddy`.osgrouprolemembership; - -/*fill os_groups_roles in ROBUST database with values from osroles -or FlotSam osrole*/ -INSERT INTO `griddy`.os_groups_roles -(GroupID, RoleID, Name, Description, Title, Powers) -SELECT GroupID, RoleID, Name, Description, Title, Powers -FROM `griddy`.osrole; 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 @@ +#!/bin/bash + +source common.sh +getPrgDir + +NAME=$1 +LOCATION=$2 +URL=$3 +IP=$4 +SIZE=$5 + +OSPATH="/opt/opensim" +cd $OSPATH/config + +k=0 +for i in $(seq -w 1 99) +do + j=$(num2name "$i") + if [ -e "$j" ] + then + k=$i + fi +done + +if [ "x$NAME" = "x" ] +then + NAME="No name sim $RANDOM" # Should be unique per grid. + echo "WARNING setting the sim name to [$NAME], this may not be what you want." +fi +# Sanitize the name. Not removing [ or ], couldn't get that to work, only important for Windows. +sim=$(sanitize $NAME) + +if [ "x$LOCATION" = "x" ] +then + LOCATION="$RANDOM,$RANDOM" # again UNIQUE (i.e. ONLY ONE) per grid in THIS case! + echo "WARNING setting the Location to $LOCATION, this may not be what you want." +fi + +if [ "x$IP" = "x" ] +then + # 0.0.0.0 will work for a single sim per physical machine, otherwise we need the real internal IP. + IP="0.0.0.0" + echo "WARNING setting the InternalAddress to $IP, this may not be what you want." +# echo " 0.0.0.0 will work for a single sim per physical machine, otherwise we need the real internal IP." +# According to the OpenSim docs, 0.0.0.0 means to listen on all NICs the machine has, which should work fine. +fi + +if [ "x$URL" = "x" ] +then +# Here we make use of an external IP finding service. Careful, it may move. +# 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. + URL="SYSTEMIP" + echo "WARNING setting the ExternalHostName to $URL, this may not be what you want." +fi + +if [ "x$SIZE" = "x" ] +then + SIZE="256" +fi + +# Wow, the hoops we have to jump through to avoid octal. +if [ 9 -gt $k ]; then + NUM=$(printf '0%1s' $(( 10#$k + 1 )) ) +else + NUM=$(printf '%2s' $(( 10#$k + 1 )) ) +fi + +PORT=$(( 9005 + (10#$k * 5) )) # 9002 is used for HTTP/UDP so START with port 9003! CAUTION Diva/D2 starts at port 9000. +UUID=$(uuidgen) + +echo "Creating sim$NUM on port $PORT @ $LOCATION - $NAME." + +cp -r sim_skeleton sim$NUM + +cd sim$NUM +mv My_sim.xml ${sim}.xml +sed -i "s@SIM_NAME@$NAME@g" ${sim}.xml +sed -i "s@SIM_UUID@$UUID@g" ${sim}.xml +sed -i "s@SIM_POS@$LOCATION@g" ${sim}.xml +sed -i "s@SIM_IP@$IP@g" ${sim}.xml +sed -i "s@SIM_INT_PORT@$(( $PORT + 1 ))@g" ${sim}.xml +sed -i "s@SIM_URL@$URL@g" ${sim}.xml +sed -i "s@SIM_SIZE@$SIZE@g" ${sim}.xml + +ln -s ../../current/scripts/common.sh common.sh +ln -s ../../current/scripts/start-sim start-sim +cp -P start-sim backup-sim +cp -P start-sim stop-sim + +sed -i "s@SIM_NUMBER@$NUM@g" ThisSim.ini +sed -i "s@SIM_PORT@$PORT@g" ThisSim.ini + +sed -i "s@SIM_NUMBER@$NUM@g" opensim-monit.conf + +sudo chown -R opensim:opensim .. +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 @@ +#!/bin/bash + +OSPATH="/opt/opensim" + +for i in $(seq 99) +do + j=$(printf "sim%02d" $i) + if [ -e "$OSPATH/config/$j" ] + then + sudo ln -s $OSPATH/config/$j/opensim-monit.conf /etc/monit/conf.d/$j.conf + fi +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 @@ +INSERT INTO `griddy`.`os_groups_groups` +(GroupID, Name, Charter, InsigniaID, FounderID, MembershipFee, OpenEnrollment, ShowInList, +AllowPublish, MaturePublish, OwnerRoleID) +SELECT GroupID, Name, Charter, InsigniaID, FounderID, MemberShipFee, OpenEnrollment, ShowInList, AllowPublish, +MaturePublish, OwnerRoleID +FROM `griddy`.osgroup; + +/*fill os_groups_invites in ROBUST database with values from osgroupinvite +or FlotSam osgroupinvite*/ +INSERT INTO `griddy`.`os_groups_invites` +(InviteID, GroupID, RoleID, PrincipalID, TMStamp) +SELECT InviteID, GroupID, RoleID, AgentID, TMStamp +FROM `griddy`.osgroupinvite; + +/*fill os_groups_membership in ROBUST database with values from osgroupmembership +or FlotSam osgroupmembership*/ +INSERT INTO `griddy`.`os_groups_membership` +(GroupID, PrincipalID, SelectedRoleID, Contribution, ListInProfile, AcceptNotices) +SELECT GroupID, AgentID, SelectedRoleID, Contribution, ListInProfile, AcceptNotices +FROM `griddy`.osgroupmembership; + +/*fill os_groups_notices in ROBUST database with values from osgroupnotice +or FlotSam osgroupnotice*/ +INSERT INTO `griddy`.`os_groups_notices` +(GroupID, NoticeID, TMStamp, FromName, Subject, Message) +SELECT GroupID, NoticeID, Timestamp, FromName, Subject, Message +FROM `griddy`.osgroupnotice; + +/*fill os_groups_principals in ROBUST database with values from osagent +or FlotSam osagent*/ +INSERT INTO `griddy`.`os_groups_principals` +(PrincipalID, ActiveGroupID) +SELECT AgentID, ActiveGroupID +FROM `griddy`.osagent; + +/*fill os_groups_rolemembership in ROBUST database with values from osrolemembership +or FlotSam osgrouprolemembership*/ +INSERT INTO `griddy`.os_groups_rolemembership +(GroupID, RoleID, PrincipalID) +SELECT GroupID, RoleID, AgentID +FROM `griddy`.osgrouprolemembership; + +/*fill os_groups_roles in ROBUST database with values from osroles +or FlotSam osrole*/ +INSERT INTO `griddy`.os_groups_roles +(GroupID, RoleID, Name, Description, Title, Powers) +SELECT GroupID, RoleID, Name, Description, Title, Powers +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 @@ +# manage the OpenSim process for Your Sim +# +# usage: +# monit start your_sim +# monit stop your_sim +# monit restart your_sim +# +# see 'daemon' setting in /etc/monit/monitrc for the cycle length. +# on ubuntu/debian, this is overridden by the CHECK_INTERVALS var in +# /etc/default/monit . the below assumes you've set it to 30 seconds. +# +# if process dies, will restart sim within 30 seconds. if process +# dies 5 times in as many tries, will stop trying and send email +# alert. +# +# if SimFPS drops to 0 for 2 minutes, restart. +# +# if process CPU usage stays above 300% for 2 minutes, restart. +# +# see ../README for configuration instructions. +# +# Hmmmm, seems that monit changing to a user and running bash -l is different from sudo changing to a user and running bash -l. +# +check process sim01 with pidfile /var/run/opensim/sim01.pid + start program = "/usr/bin/sudo -Hu opensim /bin/bash -lc 'cd /opt/opensim/config/sim01 && /opt/opensim/config/sim01/start-sim -q'" + as uid root and gid root + 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 + if cpu usage > 50% for 4 cycles then restart +# if 5 restarts within 5 cycles then timeout +# if failed url http://127.0.0.1:9005/jsonSimStats/ +# and content != '"SimFPS":0.0,' for 4 cycles +# then restart +# if failed url http://127.0.0.1:9008/jsonSimStats/ +# and content == '"SimFPS":' for 4 cycles +# then restart + 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 @@ +# Tmux has a habit of changing what these options are for each version, so this is a bit of a mess. + +set-option -g prefix C-a +unbind-key C-b +bind-key C-a send-prefix + +# r reloads the configuration, handy +bind r source-file ~/.tmux.conf + +unbind % # Remove default binding since we’re replacing them. +bind | split-window -h +bind - split-window -v + +set-option -g bell-action any +set-option -g bell-on-alert on + +set-option -g history-limit 100000 + +# These three wont work under Ubuntu 16.04. +set-option -g mouse-resize-pane on +set-option -g mouse-select-pane on +set-option -g mouse-select-window on +set-option -g mouse-utf8 on + +#set-option -g set-remain-on-exit on +set-option -g set-titles on +set-option -g set-titles-string '#W' + +set-option -g status-interval 1 +set-option -g status-justify centre +set-option -g status-utf8 on + +set-option -g status-left-length 80 +set-option -g status-left '[#H #S #F]' +set-option -g status-right-length 80 +set-option -g status-right '%F #(uptime)'<-----># &F is ISO date, uptime starts with the current time, and ends with the load average. B-) + +set-option -g visual-activity on +set-option -g visual-content on +set-option -g visual-silence on + +set-option -gw clock-mode-style 24 +# This wont work under Ubuntu 16.04. +set-option -gw mode-mouse on +# Instead do this (also defaults to turning on the above three mouse things) - +#set-option -gw mouse on + +# Highlight active window +set-option -gw window-status-current-bg red + +# Set window notifications +set-option -gw monitor-activity on diff --git a/scripts/opensim-monit.conf b/scripts/opensim-monit.conf deleted file mode 100644 index 7785056..0000000 --- a/scripts/opensim-monit.conf +++ /dev/null @@ -1,36 +0,0 @@ -# manage the OpenSim process for Your Sim -# -# usage: -# monit start your_sim -# monit stop your_sim -# monit restart your_sim -# -# see 'daemon' setting in /etc/monit/monitrc for the cycle length. -# on ubuntu/debian, this is overridden by the CHECK_INTERVALS var in -# /etc/default/monit . the below assumes you've set it to 30 seconds. -# -# if process dies, will restart sim within 30 seconds. if process -# dies 5 times in as many tries, will stop trying and send email -# alert. -# -# if SimFPS drops to 0 for 2 minutes, restart. -# -# if process CPU usage stays above 300% for 2 minutes, restart. -# -# see ../README for configuration instructions. -# -# Hmmmm, seems that monit changing to a user and running bash -l is different from sudo changing to a user and running bash -l. -# -check process sim01 with pidfile /var/run/opensim/sim01.pid - start program = "/usr/bin/sudo -Hu opensim /bin/bash -lc 'cd /opt/opensim/config/sim01 && /opt/opensim/config/sim01/start-sim -q'" - as uid root and gid root - 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 - if cpu usage > 50% for 4 cycles then restart -# if 5 restarts within 5 cycles then timeout -# if failed url http://127.0.0.1:9005/jsonSimStats/ -# and content != '"SimFPS":0.0,' for 4 cycles -# then restart -# if failed url http://127.0.0.1:9008/jsonSimStats/ -# and content == '"SimFPS":' for 4 cycles -# then restart - 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 @@ -# Tmux has a habit of changing what these options are for each version, so this is a bit of a mess. - -set-option -g prefix C-a -unbind-key C-b -bind-key C-a send-prefix - -# r reloads the configuration, handy -bind r source-file ~/.tmux.conf - -unbind % # Remove default binding since we’re replacing them. -bind | split-window -h -bind - split-window -v - -set-option -g bell-action any -set-option -g bell-on-alert on - -set-option -g history-limit 100000 - -# These three wont work under Ubuntu 16.04. -set-option -g mouse-resize-pane on -set-option -g mouse-select-pane on -set-option -g mouse-select-window on -set-option -g mouse-utf8 on - -#set-option -g set-remain-on-exit on -set-option -g set-titles on -set-option -g set-titles-string '#W' - -set-option -g status-interval 1 -set-option -g status-justify centre -set-option -g status-utf8 on - -set-option -g status-left-length 80 -set-option -g status-left '[#H #S #F]' -set-option -g status-right-length 80 -set-option -g status-right '%F #(uptime)'<-----># &F is ISO date, uptime starts with the current time, and ends with the load average. B-) - -set-option -g visual-activity on -set-option -g visual-content on -set-option -g visual-silence on - -set-option -gw clock-mode-style 24 -# This wont work under Ubuntu 16.04. -set-option -gw mode-mouse on -# Instead do this (also defaults to turning on the above three mouse things) - -#set-option -gw mouse on - -# Highlight active window -set-option -gw window-status-current-bg red - -# Set window notifications -set-option -gw monitor-activity on -- cgit v1.1