Automated Upgrade LINUX

From OpenSimulator

Jump to: navigation, search

Auto-Upgrade for Linux (Multi-Instance)

What it does. Read the Source Code Header of the bash script. Essentially, it grabs the OSG Binary Zip from the website and performs an OpenSimulator Instance Upgrade, transfers the current files and preserves the upgrade INI files as UPG_*.ini so that you can compare them... it will NOT START OPENSIM and OpenSimulator server MUST BE SHUTDOWN prior to running it.  Refer to Smart Prestart LINUX for automated Startup & Shutdown scripts to work in tandem with this.


NOTE:  As of October 2010 and changes to OSG & OpenSimulator this requires testing on Linux Systems.  This is A PROTOTYPE Script.  --WhiteStar 17:08, 24 October 2010 (UTC)

#!/bin/bash
#
# FILENAME: Upgrade_OS.sh
# AUTHOR: WhiteStar Magic @ OSGrid
# DATE: October 24, 2010 
# REVISION: 0.4 (4th prototype)
#
# R.0.3 corrected syntax and added some improvements as suggested by Dene Sparta @ OSG
# NOTE! This is untested 
#
# DESCRIPTION: 
# Based on an initial script by Dene Sparta @ OSG and expanded / modularized.
# Upgrades OpenSimulator Instances from SOURCE Website.
# Creates a bin_NEW with the upgraded version and leave original bin intact to allow for review
# and mods prior to startup. 
# INI`s change so they MUST be reviewed prior to initializing
#
# An Option was added to AUTO-START the Instance AFTER UPGRADE 
# !! WARNING !! This would start the instance with the Original INI Files from the previous version.
# !! The INI files change constantly and should always be reviewed / compared PRIOR to Startup
# !! See bottom of === PROCESS Upgrades === section
#
# INSTALLATION:
# save this script into a convenient folder
# if you have OpenSimulator Instances, for example /opensim/instanceA & /opensim/instanceB
# I suggest installing it in /opensim
#
# RUNNING:
# Note that BEFORE RUNNING THIS, the Instances MUST BE SHUTDOWN !
# Run with the following command bash Upgrade_OS.sh
# can be installed in another directory, Adjust the script accordingly
#
# ======================================================================================
#
# GENERAL VARIABLES THAT MUST BE SET:
#
# where to store your upgrade repository
OS_UPD_REPO="/AUTO_UPDATE"
# website source path
OS_WEB_SRC="http://download.osgrid.org/autowin" 
# filename to get from website
#
# http://download.osgrid.org/ shows LATEST Zip File available
# ======================================================================================
#
# ================
# === ROUTINES ===
# ================
# ======================
# === PROCESS UPDATE ===
# ======================
GET_update()
{
# --- test to see if backup folders exist, if not make them
if [ ! -e "${OS_UPD_REPO}" ]; then mkdir -v ${OS_UPD_REPO}; fi
#
# change to the UPDATE REPOSITORY, get the source ZIP file from the web 
cd ${OS_UPD_REPO}
#
#get the latest current rev ZIP line from OSGrid and write to file cur_rev
wget -Ocur_rev ${OS_WEB_SRC}
#
wget -nc -icur_rev
#
}
# ========================
# === PROCESS Upgrades ===
# ========================
DO_update()
{
# change dir to OpenSimulator Instance & CREATE bin_NEW for Updated version
cd ${OS_Instance}
if [ ! -e "${OS_Instance}/bin_NEW" ] 
then 
mkdir -v ${OS_Instance}/bin_NEW
else
rm -rf ${OS_Instance}/bin_NEW
mkdir -v ${OS_Instance}/bin_NEW
fi
#
# unpack the new rev to /bin_NEW and move to correct position
unzip ${OS_UPD_REPO}/${OS_UPD_NAME} -d ${OS_Instance}/bin_NEW
mv -f ${OS_Instance}/bin_NEW/bin ${OS_Instance}/bin_NEW
#
# rename the NEW FILES (ini`s etc) files to preserve them for review
mv -f ${OS_Instance}/bin_NEW/OpenSim.ini ${OS_Instance}/bin_NEW/UPG_OpenSim.ini
mv -f ${OS_Instance}/bin_NEW/config-include/FlotsamCache.ini ${OS_Instance}/bin_NEW/config-include/UPG_FlotsamCache.ini
mv -f ${OS_Instance}/bin_NEW/config-include/Grid.ini ${OS_Instance}/bin_NEW/config-include/UPG_Grid.ini
mv -f ${OS_Instance}/bin_NEW/config-include/GridCommon.ini ${OS_Instance}/bin_NEW/config-include/UPG_GridCommon.ini
mv -f ${OS_Instance}/bin_NEW/config-include/GridHypergrid.ini ${OS_Instance}/bin_NEW/config-include/UPG_GridHypergrid.ini
mv -f ${OS_Instance}/bin_NEW/config-include/Standalone.ini ${OS_Instance}/bin_NEW/config-include/UPG_Standalone.ini
mv -f ${OS_Instance}/bin_NEW/config-include/StandaloneHypergrid.ini ${OS_Instance}/bin_NEW/config-include/UPG_StandaloneHypergrid.ini
echo "RENAMED the NEW /bin_NEW/config-include/*.INI files to UPG_filename.ini for review"
#
# copy the original ini files from previous version
cp -r -u -p ${OS_Instance}/bin/config-include/*.ini ${OS_Instance}/bin/config-include
echo "Transfered the ORIGINAL /bin/config-include/*.INI files to /bin_NEW/config-include"
#
# Transfer the appropriate files over to ready it for operation
cp -r -u -p ${OS_Instance}/bin/Regions/*.* ${OS_Instance}/bin_NEW/Regions
cp ${OS_Instance}/bin/OpenSim.ini ${OS_Instance}/bin_NEW/OpenSim.ini
cp ${OS_Instance}/bin/*.db ${OS_Instance}/bin_NEW/*.db
echo "Transfered the ORIGINAL Critical files to /bin_NEW"
#
# Now we TAR.GZ the Original bin folder
tar --create --gzip --file=${OS_Instance}/${Instance_Name}_OLD_`date +"%Y-%m-%d"`.tar.gz ${OS_Instance}/bin
#
# == ATTENTION == SPECIAL NOTE HERE FOR OPTIONAL COMPLETION ==
# ============================================================
# !!! UNCOMMENT FOLLOWING LINES IF INSTANCES ARE SHUTDOWN AND YOU WISH TO COMPLETE THE SWITCH OVER !!!
# ============================================================
#rm -rf ${OS_Instance}/bin
#mv -f ${OS_Instance}/bin_NEW ${OS_Instance}/bin
#echo "The New Version prepared to start with UN-REVIEWED INI files"
#
#echo we are are starting up the OPENSIM Instance in ${OS_Instance}/bin 
## Uncomment either line below to start appropriate version of OpenSimulator in screen.
#screen -S ${Instance_Name} -d -m mono OpenSim.exe -gui=true
#screen -S ${Instance_Name} -d -m mono OpenSim.32BitLaunch.exe -gui=true
# ============================================================
}
#
# ##################################
# === PERFORM THE UPGRADE/UPDATE ===
# ==================================
#
GET_update 
# 
# -------------------------
# --- Upgrade Instances ---
# -------------------------
#
Instance_Name=TEST
OS_Instance="/opensim/TEST"
DO_update
#
# !! Repeat and edit as needed !!
#
#Instance_Name=instanceB
#OS_Instance="/opensim/instanceB"
#DO_update
#
#Instance_Name=instanceC
#OS_Instance="/opensim/instanceC"
#DO_update
#
#Instance_Name=instanceD
#OS_Instance="/opensim/instanceD"
#DO_update
#
#################################

Return to Automating Tasks

Personal tools
General
About This Wiki