From f92e3e7c49fef4d136ddd7d2e7f817cb0b255f4b Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 8 Sep 2020 21:31:56 +1000 Subject: Add the old bash scripts. Most of these will eventually be rewritten as C + Lua. --- scripts/install/create_sim.sh | 75 ++++++++++++++++++++++++++++++ scripts/install/go_live.sh | 12 +++++ scripts/install/group_migrate.sql | 48 +++++++++++++++++++ scripts/install/opensim.tmux.conf | 97 +++++++++++++++++++++++++++++++++++++++ scripts/install/secure.sh | 26 +++++++++++ 5 files changed, 258 insertions(+) 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.tmux.conf create mode 100755 scripts/install/secure.sh (limited to 'scripts/install') 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 @@ +#!/bin/bash + +source ../common.sh +getPrgDir + +NAME=$1 +LOCATION=$2 +SIZE=$3 + +cd ${OS_PATH}/config + +k=0 +for i in $(seq -w 1 99) +do + if [ -e "sim$i" ] + 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${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 * 2) )) # 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} +sed -i "s@SIM_NAME@${NAME}@g" ThisSim.ini +sed -i "s@SIM_UUID@${UUID}@g" ThisSim.ini +sed -i "s@SIM_POS@${LOCATION}@g" ThisSim.ini +sed -i "s@SIM_INT_PORT@$(( ${PORT} + 1 ))@g" ThisSim.ini +sed -i "s@SIM_SIZE@${SIZE}@g" ThisSim.ini + +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@OS_PATH@${OS_PATH}@g" opensim-monit.conf +sed -i "s@SIM_NUMBER@${NUM}@g" opensim-monit.conf + +mv ThisSim.ini $(sanitize "${NAME}").ini + +sudo chown -R ${OS_USER}:${OS_USER} .. +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..c5ce90e --- /dev/null +++ b/scripts/install/go_live.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +source common.sh + +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.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 @@ +# Tmux has a habit of changing what these options are for each version, so this is a bit of a mess. + +# Screen compatibility, change the command key. And rebind the prefix sending command. +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 + +bind R clear-history + +# More sane pane gain. B-) +unbind % # Remove default binding since we’re replacing them. +unbind '"' +bind | split-window -h +bind - split-window -v + +# set-options -g global, -s server, -w window, otherwise a session option. +# -a appends a string to the existing option. +# -u unsets an option. +# -o prevents setting an aption if it is already set. +# -q shut up info messages. + +# SESSION OPTIONS + +set-option -g bell-action any +set-option -g bell-on-alert on + +# Not actually documented what the limit is, but there is one. +set-option -g history-limit 100000 + +# All this mouse stuff is unreliable in UTF8 mode. At least on roxterm. +# Also keep in mind the terminal specs mouse report limit of 256 characters, being less than my typical terminal width. +# Hmm, still wont pass mouse through like the docs say they will. +# Ah, mc needs "mc -x". Though once again, watch that right edge on huge terminals. +# 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 +# This wont work under Ubuntu 16.04. +##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. +# Instead do this (also defaults to turning on the above three mouse things) - +set-option -g mouse on +# Or this. sigh +#set-option -g mouse +##set-option -g mouse-utf8 off # Defaults to on. + +set-option -g set-remain-on-exit on + +# How to set the title of the terminal window. +set-option -g set-titles on +set-option -g set-titles-string '#W' # Default is "#S:#I:#W - "#T"" + +set-option -g status-interval 1 # Redraw status line every second, for the clock. +set-option -g status-justify centre # Window list in the middle. +##set-option -g status-utf8 on + +# Character pair Replaced with + #(shell-command) First line of the command's output + #[attributes] Colour or attribute change + #H Hostname of local host (not FDQN) + #h Hostname of local host without the domain name + #F Current window flag + #I Current window index + #D Current pane unique identifier + #P Current pane index + #S Session name + #T Current pane title + #W Current window name + ## A literal ‘#’ + +# Yes, my terminal really is bigger than 160 characters. +set-option -g status-left-length 42 +#set-option -g status-left '[#H #S #F]' +set-option -g status-left '#H [#S:#I.#P]#F' +set-option -g status-right-length 64 +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-) + +# Set window notifications +set-option -g visual-activity on # Show status message for activity in monitor-activity windows. +#set-option -g visual-content on # Show status message for content in monitor-content windows. Based on a fnmatch(3) string. +set-option -g visual-silence on # Show status message for silence in monitor-silence windows. Based on a set interval. + +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. +set-option -gw clock-mode-style 24 # We are using the uptime clock anyway, so this is pointless. + +# Highlight active window +set-option -gw window-status-current-bg red +set-option -gw window-status-current-format '[#I:#W]' +set-option -gw window-status-format '[#I:#W]#F' + +# Set window notifications +set-option -gw monitor-activity on # Bell on activity. + +# We want 256 colours in our terminal. +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 @@ +#!/bin/bash + +source ../common.sh + +echo "Securing OpenSim." +sudo chmod 600 ${OS_PATH}/config/*.ini +sudo chmod 600 ${OS_PATH}/config/ROBUST/*.ini +sudo chown -R ${OS_USER}:${OS_USER} ${OS_PATH} +sudo chmod -R 775 ${OS_PATH} +sudo chmod -R a-x ${OS_PATH} +sudo chmod -R a+X ${OS_PATH} +sudo chmod -R g+w ${OS_PATH} +sudo chmod -R a+x ${OS_PATH}/current/*.sh +sudo chmod -R a+x ${OS_PATH}/current/scripts/*.sh +sudo chmod -R a+x ${OS_PATH}/current/scripts/install/*.sh +sudo chmod a+x ${OS_PATH}/current/scripts/show-console +sudo chmod a+x ${OS_PATH}/current/scripts/start-sim + +sudo chmod ug+rwx ${OS_PATH}/config +sudo chmod g+s ${OS_PATH}/config +sudo chmod 600 ${OS_PATH}/config/*.ini +sudo chmod 600 ${OS_PATH}/config/ROBUST/*.ini + +chmod ug+rwx ${OS_PATH}/caches +chmod o-rwx ${OS_PATH}/caches +chmod g+s ${OS_PATH}/caches -- cgit v1.1