From d8b6646a004060edf073b96065fdbb979baa2f68 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 27 Nov 2011 19:31:33 +1000 Subject: Trying to make things safer for upgrades and some general tweaks. --- README | 11 ++++++++ common.ini | 21 ++++++++++++++ create_region.sh | 45 ++++++++++++++++++++++-------- go_live.sh | 12 ++++---- install_opensim.sh | 81 ++++++++++++++++++++++++++++++++---------------------- opensim-monit.conf | 2 +- start-sim | 6 +++- 7 files changed, 127 insertions(+), 51 deletions(-) create mode 100644 common.ini diff --git a/README b/README index d5edc4b..8636f21 100644 --- a/README +++ b/README @@ -60,3 +60,14 @@ this directory) - ./go_live.sh + +NOTES - + +This attempts to use only one copy of the OS install for all sims. We +are running one instance of OS for each sim though, as this prevents one +sim crashing from bringing down the others. OS however really wants to +write data to directories within it's own bin directory. I'm not at all +certian if that data can be shared. For the same reason, so far I've +not been able to get to thepoint where we can make the OS directory read +only. This complicates things during upgrades. + diff --git a/common.ini b/common.ini new file mode 100644 index 0000000..b76bcae --- /dev/null +++ b/common.ini @@ -0,0 +1,21 @@ +[DatabaseService] + StorageProvider = "OpenSim.Data.MySQL.dll" + ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=MYSQL_PASSWORD;" +[AssetService] + ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=MYSQL_PASSWORD;" +[InventoryService] + ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=MYSQL_PASSWORD;" +[AvatarService] + ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=MYSQL_PASSWORD;" +[AuthenticationService] + ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=MYSQL_PASSWORD;" +[UserAccountService] + ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=MYSQL_PASSWORD;" +[GridUserService] + ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=MYSQL_PASSWORD;" +[FriendsService] + ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=MYSQL_PASSWORD;" +[Network] + ConsoleUser = "REST_USER" + ConsolePass = "REST_PASSWORD" + diff --git a/create_region.sh b/create_region.sh index ba9de5a..5c27052 100755 --- a/create_region.sh +++ b/create_region.sh @@ -4,7 +4,9 @@ NAME=$1 LOCATION=$2 URL=$3 IP=$4 -cd /opt/opensim/config + +OSPATH="/opt/opensim" +cd $OSPATH/config k=0 for i in $(seq 99) @@ -28,12 +30,8 @@ then echo "WARNING setting the Location to $LOCATION, this may not be what you want." fi -if [ "x$URL" = "x" ] -then - URL=$(hostname) # URL is best (without the HTTP://), but IP (e.g. 88.109.81.55) works too. - echo "WARNING setting the ExternalHostName to $URL, this may not be what you want." -fi - +# Here we make use of an external IP finding service. Careful, it may move. +# We later reuse the same IP for the default URL, coz that should work at least. 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. @@ -42,6 +40,12 @@ then echo " 0.0.0.0 will work for a single sim per physical machine, otherwise we need the real internal IP." fi +if [ "x$URL" = "x" ] +then + URL=$IP # URL is best (without the HTTP://), but IP (e.g. 88.109.81.55) works too. + echo "WARNING setting the ExternalHostName to $URL, this may not be what you want." +fi + NUM=$(printf "%02d" $(($k + 1)) ) PORT=$(( 9005 + ($k * 5) )) # 9002 is used for HTTP/UDP so START with port 9003! CAUTION Diva/D2 starts at port 9000. UUID=$(uuidgen) @@ -60,21 +64,40 @@ AllowAlternatePorts = False ExternalHostName = $URL zzzzEOFzzzz -ln -s ../../setup/start-sim-in-rest start-sim-in-rest +ln -s ../../setup/start-sim start-sim cp ../../current/bin/OpenSim.exe.config OpenSim.exe.config +sed -i 's@@@' OpenSim.exe.config sed -i "s@@@" OpenSim.exe.config cat > ThisSim.ini << zzzzEOFzzzz [Startup] PIDFile = "/var/run/opensim/sim$NUM.pid" - regionload_regionsdir="/opt/opensim/config/sim$NUM/Regions" + regionload_regionsdir="$OSPATH/config/sim$NUM/Regions" + DecodedSculptMapPath = "caches/sim$NUM/j2kDecodeCache" [Network] console_port = $(( $PORT + 2 )) http_listener_port = $(( $PORT + 0)) -zzzzEOFzzzz -cp ../../current/bin/OpenSim.ConsoleClient.ini OpenSim.ConsoleClient.ini +[AssetCache] + ;; Damn, this gets overidden later by the FlotsamCache.ini file. + ;; At least it says it can be shared by multiple instances. + ; CacheDirectory = "caches/sim$NUM/assetcache" + +[XEngine] + ScriptEnginesPath = "caches/sim$NUM/ScriptEngines" + +[GridService] + MapTileDirectory = "caches/sim$NUM/maptiles" + +[DataSnapshot] + snapshot_cache_directory = "caches/sim$NUM/DataSnapshot" + +[Includes] + Include-Common = config/common.ini + +zzzzEOFzzzz +cp ../OpenSim.ConsoleClient.ini OpenSim.ConsoleClient.ini sed -i "s@; port = 9002@port = $(( $PORT + 2 ))@" OpenSim.ConsoleClient.ini cp ../../setup/opensim-monit.conf opensim-monit.conf diff --git a/go_live.sh b/go_live.sh index 65e4a08..856b4ce 100755 --- a/go_live.sh +++ b/go_live.sh @@ -1,17 +1,19 @@ #!/bin/bash +OSPATH="/opt/opensim" + for i in $(seq 99) do j=$(printf "sim%02d" $i) - if [ -e "/opt/opensim/config/$j" ] + if [ -e "$OSPATH/config/$j" ] then - sudo chown -R opensim:opensim /opt/opensim/config/$j - sudo ln -s /opt/opensim/config/$j/opensim-monit.conf /etc/monit/conf.d/$j.conf + sudo chown -R opensim:opensim $OSPATH/config/$j + sudo ln -s $OSPATH/config/$j/opensim-monit.conf /etc/monit/conf.d/$j.conf fi done sudo chmod 755 /var/log/opensim sudo chmod 755 /var/run/opensim -sudo chown -R opensim:opensim /opt/opensim/opensim-0.7.1.1-infinitegrid-03 -sudo chown -R opensim:opensim /opt/opensim/modules +sudo chown -R opensim:opensim $OSPATH/opensim-0.7.1.1-infinitegrid-03 +sudo chown -R opensim:opensim $OSPATH/modules diff --git a/install_opensim.sh b/install_opensim.sh index 0800523..4163132 100755 --- a/install_opensim.sh +++ b/install_opensim.sh @@ -6,6 +6,10 @@ then else MYSQL_PASSWORD=$1 fi +REST_USER="RestingUser" +REST_PASSWORD="SecretRestingPlace" + +OSPATH="/opt/opensim" USER=$(whoami) VERSION_CONTROL="off" @@ -36,41 +40,33 @@ sudo chmod 757 /var/log/opensim sudo mkdir -p /var/run/opensim sudo chown opensim:opensim /var/run/opensim sudo chmod 757 /var/run/opensim -sudo mkdir -p /opt/opensim/config /opt/opensim/modules /opt/opensim/setup -sudo chown opensim:opensim /opt/opensim -sudo chown -R opensim:opensim /opt/opensim -sudo chmod -R 757 /opt/opensim -cp start-sim-in-rest /opt/opensim/setup -cp opensim-monit.conf /opt/opensim/setup +sudo mkdir -p $OSPATH/config $OSPATH/setup $OSPATH/caches/assetcache +sudo chown opensim:opensim $OSPATH +sudo chown -R opensim:opensim $OSPATH +sudo chmod -R 757 $OSPATH +cp * $OSPATH/setup +cp common.ini $OSPATH/config +sed -i "s@MYSQL_PASSWORD@$MYSQL_PASSWORD@g" $OSPATH/config/common.ini +sed -i "s@REST_PASSWORD@$REST_PASSWORD@g" $OSPATH/config/common.ini +sed -i "s@REST_USER@$REST_USER@g" $OSPATH/config/common.ini cat opensim-crontab.txt | sudo crontab -u opensim - -cd /opt/opensim +cd $OSPATH if [ ! -e opensim-0.7.1.1-infinitegrid-03.tar.bz2 ] then wget https://github.com/downloads/infinitegrid/InfiniteGrid-Opensim/opensim-0.7.1.1-infinitegrid-03.tar.bz2 fi - if [ ! -e opensim-0.7.1.1-infinitegrid-03 ] then tar xjf opensim-0.7.1.1-infinitegrid-03.tar.bz2 fi ln -fs opensim-0.7.1.1-infinitegrid-03 current -cd current/bin -mv -f OpenSim.Forge.Currency.dll ../../modules/ -ln -fs ../../modules/OpenSim.Forge.Currency.dll OpenSim.Forge.Currency.dll -mv -f OpenSimSearch.Modules.dll ../../modules/ -ln -fs ../../modules/OpenSimSearch.Modules.dll OpenSimSearch.Modules.dll -mv -f NSLModules.Messaging.MuteList.dll ../../modules/ -ln -fs ../../modules/NSLModules.Messaging.MuteList.dll NSLModules.Messaging.MuteList.dll -mv -f OpenSimProfile.Modules.dll ../../modules/ -ln -fs ../../modules/OpenSimProfile.Modules.dll OpenSimProfile.Modules.dll -ln -fs ../../config config - -cat > OpenSim.ConsoleClient.ini << zzzzEOFzzzz +# Create the REST client config file. +cat > config/OpenSim.ConsoleClient.ini << zzzzEOFzzzz [Startup] ; Set here or use the -user command-line switch - user = RestingUser + user = $REST_USER ; Set here or use the -host command-line switch host = localhost @@ -81,18 +77,37 @@ cat > OpenSim.ConsoleClient.ini << zzzzEOFzzzz ; Set here or use the -pass command-line switch ; Please be aware that this is not secure since the password is in the clear ; we recommend the use of -pass wherever possible - pass = SecretRestingPLace + pass = $REST_PASSWORD zzzzEOFzzzz -sed -i 's@@@' OpenSim.exe.config -sed -i 's@; ConsoleUser = "Test"@ConsoleUser = "RestingUser"@' OpenSim.ini -sed -i 's@; ConsolePass = "secret"@ConsolePass = "SecretRestingPlace"@' OpenSim.ini +cd current/bin +# Not sure why we are moving these. Hopefully we can get rid of having to move them. +# Comenting them out, until Alice or Rizzy remember why they seed to be moved. See if things still work. +#mv -f OpenSim.Forge.Currency.dll ../../modules/ +#ln -fs ../../modules/OpenSim.Forge.Currency.dll OpenSim.Forge.Currency.dll +#mv -f OpenSimSearch.Modules.dll ../../modules/ +#ln -fs ../../modules/OpenSimSearch.Modules.dll OpenSimSearch.Modules.dll +#mv -f NSLModules.Messaging.MuteList.dll ../../modules/ +#ln -fs ../../modules/NSLModules.Messaging.MuteList.dll NSLModules.Messaging.MuteList.dll +#mv -f OpenSimProfile.Modules.dll ../../modules/ +#ln -fs ../../modules/OpenSimProfile.Modules.dll OpenSimProfile.Modules.dll + +ln -fs ../../config config +mv -f addon-modules ../../config +ln -fs ../../config/addon-modules addon-modules + +# Try to make the OS distro directory suited to being read only. +ln -fs ../../caches caches +mv -f ScriptEngines ../../caches +ln -fs ../../caches/ScriptEngines ScriptEngines +# Grumble, OS has it's own silly ideas, and recreates this. +# "Cannot create /opt/opensim/opensim-0.7.1.1-infinitegrid-03/bin/addin-db-001 because a file with the same name already exists." +#ln -fs ../../caches/addin-db-001 addin-db-001 cd config-include/ +# Damn, can't overide these, we could change them for the next IG OS release. sed -i 's@Include-Storage = "config-include/storage/SQLiteStandalone.ini";@; Include-Storage = "config-include/storage/SQLiteStandalone.ini";@' GridCommon.ini -sed -i 's@; StorageProvider = "OpenSim.Data.MySQL.dll"@StorageProvider = "OpenSim.Data.MySQL.dll"@' GridCommon.ini -sed -i "s@; ConnectionString = \"Data Source=localhost;Database=opensim;User ID=opensim;Password=\*\*\*\*;\"@ConnectionString = \"Data Source=localhost;Database=opensim;User ID=opensim;Password=$MYSQL_PASSWORD;\"@" GridCommon.ini - +sed -i 's@CacheDirectory = ./assetcache@CacheDirectory = caches/assetcache@' FlotsamCache.ini cd ../../.. # Setting screen to be suid. EWWWWWW!!! Security hole!! @@ -105,9 +120,9 @@ then sudo chown root:utmp /var/run/screen fi -sudo chown -R opensim:opensim /opt/opensim -sudo chmod -R a-x /opt/opensim -sudo chmod -R a+X /opt/opensim -sudo chmod -R g+w /opt/opensim -sudo chmod a+x /opt/opensim/setup/start-sim-in-rest +sudo chown -R opensim:opensim $OSPATH +sudo chmod -R a-x $OSPATH +sudo chmod -R a+X $OSPATH +sudo chmod -R g+w $OSPATH +sudo chmod a+x $OSPATH/setup/start-sim diff --git a/opensim-monit.conf b/opensim-monit.conf index f28c76c..c98ad91 100644 --- a/opensim-monit.conf +++ b/opensim-monit.conf @@ -20,7 +20,7 @@ # see ../README for configuration instructions. # check process sim01 with pidfile /var/run/opensim/sim01.pid - start program = "/bin/bash -c 'cd /opt/opensim/config/sim01 && /opt/opensim/sim01/start-sim-in-rest -q'" + start program = "/bin/bash -c 'cd /opt/opensim/config/sim01 && /opt/opensim/sim01/start-sim -q'" as uid opensim and gid opensim stop program = "/bin/kill -9 `cat /var/run/opensim/sim01.pid`" # if cpu usage > 300% for 4 cycles then restart diff --git a/start-sim b/start-sim index 3313f57..dbb1beb 100755 --- a/start-sim +++ b/start-sim @@ -44,7 +44,11 @@ else SUDO="sudo -Hu opensim" fi +# Would be nice if this worked. +export MONO_PATH=${bindir} +# Then we would not have to do this, and subsequently write all over the damn bin directory. cd ${bindir} + if [ "x$Screaming" = "xtrue" ] then if ($screen_check | grep -q ${console_name}); then @@ -63,7 +67,7 @@ else fi inidir=/opt/opensim/config/${tgt} -cmd="/usr/bin/mono ${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config $NeedARest" +cmd="/usr/bin/mono ${bindir}/${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config $NeedARest" title=$(head -n 1 ${inidir}/Regions/sim.ini ) # Check if it's already running. -- cgit v1.1