RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

My Installation Experience - With Setup Script

Fyzxs

Wanderer
I wanted to share my experience setting up RunUO on Ubuntu Server 12.04.

After a few WTFs and 'What am I doing wrong?' I found 3 very helpful posts
http://www.runuo.com/community/thre...ns-distro-for-opensuse-12-1-with-mono.504669/
http://www.runuo.com/community/threads/how-to-configure-runuo-for-linux.88184/page-7#post-750753
http://www.runuo.com/community/threads/runuo-2-1-neruns-distro.457586/page-17#post-3891869

Basing my installation off of these 3 posts, I had it working in no time.
I had it down so smooth that I wrote myself a little script to do it for when I inevitably screw something up. :)

This isn't a robust 'drop and run' script, it's a hack that is set up applicable to my machine/account and the repositories as it stands when I'm writing this post. Make a few edits and it should be good to go on your system and the latest SVN's.

Code:
#!/bin/sh
# Uncomment the next 3 lines if you haven't installed Mono yet
#echo Installing Mono...
#sudo apt-get -y install mono-2.0-devel
#sudo apt-get -y install libmono-winforms2.0-cil libmono-system-data2.0-cil libmono-system-web2.0-cil
echo Downloading RunUO SVN --quite--
svn export -q http://svn.runuo.com/repos/runuo/devel/
rm -r runuo
mv devel runuo
cd runuo/Server
echo Compiling the server
mono-csc -out:../RunUO.exe -d:MONO -optimize+ -unsafe -r:System,System.Configuration.Install,System.Data,System.Drawing,System.EnterpriseServices,System.Management,System.Security,System.ServiceProcess,System.Web,System.Web.Services,System.Windows.Forms,System.Xml -nowarn:219 -recurse:*.cs
echo Editing DataPath.cs
sed -i '16 s:null:@\"</PATH/TO/UO CLIENT/FILES>\":' </PATH/TO/THIS/SCRIPT/LOCATION>/runuo/Scripts/Misc/DataPath.cs
echo Setting up neruns --quite--
cd ../..
rm -r neruns
mkdir neruns
cd neruns
svn export -q http://runuo-nerun-distro.googlecode.com/svn/trunk/Distro%20for%20RunUO%202.2/Data/
svn export -q http://runuo-nerun-distro.googlecode.com/svn/trunk/Distro%20for%20RunUO%202.2/Scripts/
cp -rf * ../runuo
rm -rf *
svn export -q http://runuo-nerun-distro.googlecode.com/svn/trunk/Distro%20for%20RunUO%20SVN/Scripts/
cp -rf * ../runuo
echo Setting up RunUO.exe.config
cd ../runuo
# To find your version of libz, from the command line "locate libz"
# Update target section as needed
echo "<configuration>" >> RunUO.exe.config
echo " <dllmap dll=\"libz\" target=\"libz.so.1\"/>" >> RunUO.exe.config
echo "</configuration>" >> RunUO.exe.config
echo Done

To be clear - This can be cleaned up, streamlined and made easy to modify... I don't need to, therefore I didn't. :)


So... I'm bad at write ups; This is a sweet system and is fairly simple to set up and get operational. I hope this sample script helps others!
 

Fyzxs

Wanderer
I dislike leaving things half-assed...

Code:
#!/bin/bash
#
# Edit the variables to your needs.
#
 
# Location to install RunUO folder
RUNUO_PATH="/home/uoadmin/"
# Folder for RunUO to be installed to
RUNUO_FOLDER="runuo"
# Path to UO Client Files
UOCLIENT_PATH="/home/uoadmin/"
# Folder for the UO Client data files
# You will need to create and move the data into this location
UOCLIENT_FOLDER="uoclient"
 
# There should be no/minimal need to edit below this point.
 
echo
# Checking if Mono needs to be installed
HAS_MONO=$(mono -V | grep "Mono JIT compiler version")
if [ ${#HAS_MONO} -eq 0 ]
then
    echo "Mono not found... Attempting to install"
    $MONO_INST_CMD="sudo apt-get -y install mono-2.0-devel libmono-winforms2.0-cil libmono-system-data2.0-cil libmono-system-web2.0-cil"
    if [ $UID -eq 0 ]
    then
        echo Installing Mono...
        ${MONO_INST_CMD}
    else
        echo "Mono is not installed - You are not root, cannot install Mono."
        echo "Please run this script as sudo"
        echo "or execture the following command manually"
        echo ${MONO_INST_CMD}
    fi
else
    echo "Mono detected. Continuing"
fi
 
echo
# Creating the path for the RunUO folder
echo "Checking the location for the RunUO folder"
if [ ! -d "$RUNUO_PATH" ]; then
    echo "${RUNUO_PATH} doesn't exist, attempting to create..."
    mkdir -p ${RUNUO_PATH}
fi
 
echo
# Clearing the RunUO folder if it exists
if [ -d "$RUNUO_PATH/$RUNUO_FOLDER" ]; then
    echo "${RUNUO_PATH}/${RUNUO_FOLDER} exists... attempting to remove"
    rm -r ${RUNUO_PATH}/${RUNUO_FOLDER}
fi
 
echo
# Retrieving RunUO from SVN
echo "Retrieving RunUO files from SVN"
echo "    There will be no output during this process"
svn export -q http://svn.runuo.com/repos/runuo/devel/ ${RUNUO_PATH}/${RUNUO_FOLDER}
echo "Retrieval of RunUO files from SVN complete"
 
# Pulling down Nerun's Files
echo "Retrieving Nerun's Distro for RunUO 2.2"
echo "    There will be no output during this process"
svn export -q --force  http://runuo-nerun-distro.googlecode.com/svn/trunk/Distro%20for%20RunUO%202.2/ ${RUNUO_PATH}/${RUNUO_FOLDER}
echo "Retrieving Nerun's Distror for RunUO 2.2 is complete"
echo
echo "Retrieving Nerun's Distro for RunUO SVN"
echo "    There will be no output during this process"
svn export -q --force http://runuo-nerun-distro.googlecode.com/svn/trunk/Distro%20for%20RunUO%20SVN/ ${RUNUO_PATH}/${RUNUO_FOLDER}
echo "Retrieving NeRun's Distro for RunUO SVN complete"
 
echo
# Compiling RunUO
echo "Compiling RunUO"
COMPILE_CMD="mono-csc -out:${RUNUO_PATH}/${RUNUO_FOLDER}/RunUO.exe -d:MONO -optimize+ -unsafe -r:System,System.Configuration.Install,System.Data,System.Drawing,System.EnterpriseServices,System.Management,System.Security,System.ServiceProcess,System.Web,System.Web.Services,System.Windows.Forms,System.Xml -nowarn:219 -recurse:${RUNUO_PATH}/${RUNUO_FOLDER}/Server/*.cs"
echo "${COMPILE_CMD}"
${COMPILE_CMD}
echo "Compilation of RunUO is complete"
 
echo
# Updating DataPath.cs to provide UO Client location
echo "Editing DataPath.cs to specify the location of the UO Client Data folder to be ${UOCLIENT_PATH}/${UOCLIENT_FOLDER}"
sed -i "16 s:null:@\"${UOCLIENT_PATH}/${UOCLIENT_FOLDER}\":" ${RUNUO_PATH}/${RUNUO_FOLDER}/Scripts/Misc/DataPath.cs
 
echo
# Creating the RunUO.exe.config
echo "Creating RunUO.exe.config"
LIBZ_TARGET=$(locate libz | grep -o --max-count=1 libz.*)
echo "<configuration>" > ${RUNUO_PATH}/${RUNUO_FOLDER}/RunUO.exe.config
echo " <dllmap dll=\"libz\" target=\"${LIBZ_TARGET}\"/>" >> ${RUNUO_PATH}/${RUNUO_FOLDER}/RunUO.exe.config
echo "</configuration>" >> ${RUNUO_PATH}/${RUNUO_FOLDER}/RunUO.exe.config
 
echo "RunUO set up is complete"
echo "Execute 'mono ${RUNUO_PATH}/${RUNUO_FOLDER}/RunUO.exe' to start your server"

While not necessarily the prettiest bunch of code - This should be much easier to edit/use on other systems.

Figure we're not all a crazy computer geek who does bash scripts for fun. :-P

I did run this on my system, many times - Aside from ... possibly the mono section; it works on my Ubuntu 12.04 Server. I run it, C&P the command it provides to start the server, and it starts right up and asks for the admin acct creation. I even logged in to make sure it didn't glitch out at that point; which is does if you fail to create the RunUO.exe.config file correctly. Infinite restarts!!!

So yea - Have an updated version which should be more user friendly and easier to change for other systems.
 

Fyzxs

Wanderer
So... I was still a little bored...
I saw this thread earlier http://www.runuo.com/community/threads/linux-shell-script-to-start-runuo-server.502516/
and decided to do one. \^_^/

Code:
#!/bin/bash
# /etc/init.d/runuo
 
### BEGIN INIT INFO
# Provides:   runuo
# Required-Start: $local_fs $remote_fs
# Required-Stop:  $local_fs $remote_fs
# Should-Start:   $network
# Should-Stop:    $network
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
# Short-Description:    RunUO Server
# Description:    Init script for RunUO server
### END INIT INFO
 
# Edit these variables to match your system
# Name to use for the screen instance
SCREEN="runuo"
 
# User that should run the server
USERNAME="uoadmin"
 
# Path to runuo server directory
UOPATH="/home/${USERNAME}/runuo"
 
# Executable that starts RunUo
SERVICE="RunUO.exe"
 
# STOP -- Do Not Edit Below Here
# =============================
 
INVOCATION="nohup mono ${UOPATH}/${SERVICE} &"
 
ME=`whoami`
as_user() {
        if [ $ME == $USERNAME ] ; then
                bash -c "$1"
        else
                su $USERNAME -s /bin/bash -c "$1"
        fi
}
 
is_running(){
        # Checks for the RunUO.exe
        # returns true if it exists.
        if ps ax | grep -v grep | grep "$SERVICE" > /dev/null
        then
                return 0
        fi
        return 1
}
 
uo_start() {
        cd $UOPATH
        as_user "$INVOCATION"
        #
        # Waiting for the server to start
        #
        seconds=0
        until ps ax | grep -v grep | grep -v -i SCREEN | grep "$SERVICE" > /dev/null
        do
                sleep 1
                seconds=$seconds+1
                if [[ $seconds -eq 5 ]]
                then
                        echo "Still not running, waiting a while longer..."
                fi
                if [[ $seconds -ge 120 ]]
                then
                        echo "Failed to start, aborting."
                        exit 1
                fi
        done
        sleep 3
        echo "$SERVICE is running."
}
 
uo_stop(){
        seconds=0
        PID=$(ps ax | grep -v grep | grep $SERVICE | awk '{print $1}')
        while  ps ax | grep -v grep | grep "$SERVICE" > /dev/null
        do
                as_user "kill $PID"
                sleep 1
                seconds=$seconds+1
                if [[ $seconds -eq 5 ]]
                then
                        echo "Still not shut down, waiting a while longer..."
                fi
                if [[ $seconds -ge 120 ]]
                then
                        echo "Failed to shut down, forcing kill."
                        as_user "kill -9 $PID"
                        seconds=0
                fi
        done
        sleep 3
        echo  "$SERVICE is now shut down"
}
 
case "$1" in
        start)
                # Starts the server
                if is_running; then
                        echo "Server already running."
                else
                        uo_start
                fi
                ;;
        stop)
                # Stops the server
                if is_running; then
                        uo_stop
                else
                        echo "No running server."
                fi
                ;;
        restart)
                # Restarts the server
                if is_running; then
                        uo_stop
                else
                        echo "No running server, starting it..."
                fi
                sleep 3
                uo_start
                ;;
        status)
                # Shows server status
                if is_running
                then
                        echo "$SERVICE is running."
                else
                        echo "$SERVICE is not running."
                fi
                ;;
        help|--help|-h)
                echo "Usage: $0 COMMAND"
                echo
                echo "Available commands:"
                echo -e "   start \t\t Starts the server"
                echo -e "   stop \t\t Stops the server"
                echo -e "   restart \t\t Restarts the server"
                ;;
        *)
                echo "No such command, see $0 help"
                exit 1
                ;;
 
esac
 
exit 0
It works on my machine! I haven't set it up to start when my computer starts... but it's based off a script I do have doing that, so... hopefully.

Figure it's at least an almost functional starting point for others.
 

Simon Omega

Traveler
None of the environments I have worked in have allowed the screen utility. So I have never used it professionally, nor personally.
I thought it would be nice to try it for RunUO. I saw your script sets up a screen name, but I don't see where screen executes or ties to the session...

I'll read the screen manpages, but anyone care to elaborate in the mean time?

I have also been trying to write a start-stop-daemon service script to add to init.d. But it seems to not like running any thing mono.

Is there a reason you did not go the start-stop-daemon route?
 

Fyzxs

Wanderer
No technical reason or anything like that; just lack of experience (doing daemon stuff) and starting from a non-daemon source.

(apologies for the delayed reply)
 
Top