Table of Contents

Introduction

OSStrap is a bootstrap tool that automatically reconfigures an OpenSim daemon under FreeBSD systems. It relies upon rc.conf to set the hostname as well as other command line tools to extract network settings from the environment.

When the OS boots, the Regions.ini file is automatically generated and sets-up the following regions with the following names:

Arber
Baer
Cuvier
Dart

Based on the set hostname in rc.conf, the network address is mapped to the set hostname which requires that the OS acquires a routable IP address. By default, the script assumes that the hostname is set to snowyowl initially. Users may opt to modify the hostname or relocate the machine but the script adapts accordingly and based on regex patterns it changes the appropriate configuration files dynamically.

Applications

Portable OpenSIM daemon. We have created this for the BIO-SE group using our own OpenSIM distribution bundled in a Virtual Machine running FreeBSD9.

Code

osstrap
#!/usr/local/bin/bash
# Copyright (C) Wizardry and Steamworks.
#
#  Licensed to Wizardry and Steamworks under
# the GPLv3 GNU License which can be found at:
#    http://www.gnu.org/licenses/gpl.html
#
# The osstrap bootstraps the daemon with multiple
# parameters taken from the operating system and 
# ensures that the daemon is configured on boot.
 
# Pause...
 
sleep 60
 
# Go!
if [ `hostname` == "snowyowl" ]; then
  EXTERNAL_ADDRESS=`ifconfig | awk '/inet/{ print $2 ; exit }'`
  GRID_NAME="snowyowl"
else
  EXTERNAL_ADDRESS=`hostname`
  GRID_NAME=`echo $EXTERNAL_ADDRESS | awk 'BEGIN { FS = "." } ; { print $1 }'`
fi
 
DAEMON_DIR='/home/opensim/opensim-daemon/'
REGION_DIR='/home/opensim/opensim-daemon/Regions/'
CONFIG_DIR='/home/opensim/opensim-daemon/config-include'
 
echo "[OpenSim BootStrap] BootStrapping... Please wait..."
 
if [ -z $EXTERNAL_ADDRESS ]; then
  echo "[OpenSim BootStrap ERROR] : Could not find an external address."
  exit
fi
 
if [ ! -d $DAEMON_DIR ] || [ ! -d $REGION_DIR ] || [ ! -d $CONFIG_DIR ]; then
  echo "[OpenSIm BootStrap ERROR] : Daemon directory not found."
  exit
fi
 
if [ ! -f $CONFIG_DIR/StandaloneCommon.ini ]; then
  echo "[OpenSim BootStrap ERROR] : Configuration files could not be found."
  exit
fi
 
# BootStrap Regions
 
echo "[OpenSim BootStrap] Setting up regions..."
 
function uuidgen {
  local UUID=$(printf "%s%s-%s-%s-%s-%s%s%s\n" `jot -r -w "%04x" 8 0 65536`)
  echo "$UUID";
}
 
if [ ! -f $REGION_DIR/Regions.ini ]; then
  declare -a TEMPLATE_REGION_NAMES=('Arber' 'Baer' 'Cuvier' 'Dart');
  declare -a TEMPLATE_COORDINATES=('5000,5000' '5000,5001' '5001,5000' '5001,5001');
  declare -a TEMPLATE_PORTS=('9001' '9002' '9003' '9004');
  declare -a TEMPLATE_REGION_UUIDS=('abeca4d9-9edf-4f5d-8cd6-6b29895436da' 'b2e67ec1-2a27-4d9e-9d02-68cafd2dbc9d' 'c06b7b49-7c23-4a21-a770-0a6bd0f13f77' 'd48cdc16-f718-45b7-88d7-69cb337080b9');
  for (( rix=0 ; rix < ${#TEMPLATE_REGION_NAMES[@]} ; rix++ )); do
    NEW_UUID=$(uuidgen)
    mysql -u opensim --password=opensim4biose -D opensim_estates -e "UPDATE estate_map SET RegionID='$NEW_UUID' WHERE RegionID='${TEMPLATE_REGION_UUIDS[$rix]}'"
    cat >> $REGION_DIR/Regions.ini <<REGION_MARK
[${TEMPLATE_REGION_NAMES[$rix]}] 
RegionUUID = $NEW_UUID
Location = ${TEMPLATE_COORDINATES[$rix]}
InternalPort = ${TEMPLATE_PORTS[$rix]}
AllowAlternatePorts = False
InternalAddress = 0.0.0.0
ExternalHostName = $EXTERNAL_ADDRESS
 
REGION_MARK
  done
fi
 
# BootStrap OpenSim
sed -i '' -e"s/ExternalHostNameForLSL *=.*/ExternalHostNameForLSL = \"$EXTERNAL_ADDRESS\"/g" \
	$DAEMON_DIR/OpenSim.ini;
 
# Bootstrap region addresses.
sed -i '' -e"s/ExternalHostName *=.*/ExternalHostName = $EXTERNAL_ADDRESS/g" \
	$REGION_DIR/Regions.ini;
 
# Bootstrap configuration addresses.
sed -i '' -e"s/HomeURI *=.*/HomeURI = \"http:\/\/$EXTERNAL_ADDRESS:9000\"/g" \
	$CONFIG_DIR/StandaloneCommon.ini;
sed -i '' -e"s/Gatekeeper *=.*/Gatekeeper = \"http:\/\/$EXTERNAL_ADDRESS:9000\"/g" \
	$CONFIG_DIR/StandaloneCommon.ini;
sed -i '' -e"s/GatekeeperURI *=.*/GatekeeperURI = \"http:\/\/$EXTERNAL_ADDRESS:9000\"/g" \
	$CONFIG_DIR/StandaloneCommon.ini;
sed -i '' -e"s/SRV_HomeURI *=.*/SRV_HomeURI = \"http:\/\/$EXTERNAL_ADDRESS:9000\"/g" \
	$CONFIG_DIR/StandaloneCommon.ini;
sed -i '' -e"s/SRV_InventoryServerURI *=.*/SRV_InventoryServerURI = \"http:\/\/$EXTERNAL_ADDRESS:9000\"/g" \
	$CONFIG_DIR/StandaloneCommon.ini;
sed -i '' -e"s/SRV_AssetServerURI *=.*/SRV_AssetServerURI = \"http:\/\/$EXTERNAL_ADDRESS:9000\"/g" \
	$CONFIG_DIR/StandaloneCommon.ini;
sed -i '' -e"s/SRV_ProfileServerURI *=.*/SRV_ProfileServerURI = \"http:\/\/$EXTERNAL_ADDRESS:9000\"/g" \
	$CONFIG_DIR/StandaloneCommon.ini;
sed -i '' -e"s/FriendsServerURI *=.*/FriendsServerURI = \"http:\/\/$EXTERNAL_ADDRESS:9000\"/g" \
	$CONFIG_DIR/StandaloneCommon.ini;
sed -i '' -e"s/IMServerURI *=.*/IMServerURI = \"http:\/\/$EXTERNAL_ADDRESS:9000\"/g" \
	$CONFIG_DIR/StandaloneCommon.ini;
sed -i '' -e"s/MapTileURL *=.*/MapTileURL = \"http:\/\/$EXTERNAL_ADDRESS:9000\"/g" \
	$CONFIG_DIR/StandaloneCommon.ini;
sed -i '' -e"s/ExternalName *=.*/ExternalName = \"http:\/\/$EXTERNAL_ADDRESS:9000\"/g" \
	$CONFIG_DIR/StandaloneCommon.ini;
sed -i '' -e"s/login *=.*/login = \"http:\/\/$EXTERNAL_ADDRESS:9000\"/g" \
	$CONFIG_DIR/StandaloneCommon.ini;
sed -i '' -e"s/gridname *=.*/gridname = \"Snowy Owl - $GRID_NAME\"/g" \
	$CONFIG_DIR/StandaloneCommon.ini;
sed -i '' -e"s/gridnick *=.*/gridnick = \"$GRID_NAME\"/g" \
	$CONFIG_DIR/StandaloneCommon.ini;
 
# Done
echo "[OpenSim BootStrap] Bootstrap successful."
 
sleep 1
 
# Starting...
echo "[OpenSim] Starting daemon... Please wait..."
 
sleep 1
 
cd $DAEMON_DIR && mono OpenSim.exe

opensim/virtual_machines/osstrap.txt ยท Last modified: 2022/04/19 08:28 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.