• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Bash][-Nix] TFS Compile Script

Shinmaru

エロルアー Scripter!
Joined
Aug 20, 2007
Messages
1,988
Reaction score
88
Location
Puerto Rico
[Bash][-Nix][Dialog] TFS Menu

This is a small discussion for a Script I'm making for Linux, it will do from Download Dependencies & Tools, Compile Boost(Thanks to Cykotitan and Fallen), Compile LuaJIT, allow you to add your own flags and compile TFS, this works with 0.2 - Latest, for now It supports Debian - Ubuntu and Fedora - CentOS, there can be more to add if I find it useful to do so.

Goal:
To make Linux OT server easier to manage.

WARNING:
I am new to bash, so go easy on me, I'm writing the script as I read tutorials about it. If you know better ways to write it, please teach me, just don;t come out to murder me for a mistake.

Update: v.3.0 ("Edit" still not worked on, just a few fixes.)

TFS Menu:
[bash]#!/bin/bash
addon=""
LuajitVer=-2.0.0-beta8
boostVer=.1.47.0
boostVer_=_1_47_0
filename=$(basename $0)
extension=${filename##*.}
filename=${filename%.*}
if [[ $EUID -ne 0 ]]; then
if [[ `dpkg -s dialog` || `rpm -qa | grep dialog` ]] ; then
dialog --backtitle "TFS Menu" --title "Warning" --yesno "This script was ran under normal user, in order to install any dependencies and such it is required to run as root.\nDo you want to log in to root?" 0 0
case $? in
0)
clear
if su -c "./$filename.sh" root ; then
exit 0
fi

;;
1)
echo "Continuing..."
;;
esac
else
clear
echo "Run this with root."
exit 0
fi
fi
if [[ $EUID -eq 0 ]]; then
if dpkg -s dialog ; then
echo "Dialog is Installed."
elif apt-get install dialog ; then
echo "Installing dialog..."
elif rpm -qa | grep dialog ; then
echo "Dialog is Installed."
elif yum install dialog ; then
echo "Installing dialog..."
else
echo "This system is not supported by this script."
fi
fi
while :
do
dialog --title "TFS Menu" --nocancel --menu "Choose an option:" 0 0 0 "Compile" "Compile Boost, TFS and more." "Install" "Install dependencies for APT and RPM based OS." "Edit" "Edit compiling files." "Exit" "Exit TFS Menu." 2> /tmp/tfsmenu.tmp.$$
result="TFS Menu"
value=$?
choice=`cat /tmp/tfsmenu.tmp.$$`
rm -f /tmp/tfsmenu.tmp.$$
case $value in
0)
if [ $choice = "Compile" ] ; then
while :
do
dialog --backtitle "TFS Menu" --title "Compile Menu" --nocancel --menu "Choose an option:" 0 0 0 "TFS" "Compile The Forgotten Server." "Boost" "Compile Boost libraries." "LuaJIT" "Compile Lua Just-In-Time." "Back" "Return back to the Main Menu." 2> /tmp/cmpmenu.tmp.$$
value=$?
choice=`cat /tmp/cmpmenu.tmp.$$`
rm -f /tmp/cmpmenu.tmp.$$
case $value in
0)
if [ $choice = "TFS" ] ; then
clear
if [ -f "autogen.sh" ]; then
./autogen.sh
fi
if [ -f "configure.ac" ]; then
./configure --enable-mysql $addon
fi
if [ -f "build.sh" ]; then
./build.sh
else
mkdir obj
make
fi
if [ -d "obj" ] ; then
mv *.o obj/
echo "*.o files where moved to obj/"
else
mkdir obj
mv *.o onj/
echo "*.o files where moved to obj/"
fi
if [ -d "src" ] ; then
mv *.cpp *.h src/
echo "*.cpp and *.h where moved to src/"
else
mkdir src
mv *.cpp *.h src/
echo "*.cpp and *.h where moved to src/"
fi
elif [ $choice = "Boost" ] ; then
clear
if [ -f boost$boostVer_.tar.gz ] || wget "http://dl.dropbox.com/u/36141316/boost$boostVer_.tar.gz" ; then
tar xzf boost$boostVer_.tar.gz
cd boost$boostVer_/
chmod +x bootstrap.sh
if ./bootstrap.sh ; then
if ./bjam variant=release link=static threading=multi ; then
echo "Boost$boostVer_ has been installed."
fi
else
echo "Error: A problem occured with bootstrap.sh ."
fi
cd ..
else
echo "Error: Unable to download Boost$boostVer ."
fi
elif [ $choice = "LuaJIT" ] ; then
clear
if [ -f "/usr/local/bin/luajit$LuajitVer" ]; then
result='LuaJIT has already been installed.'
else
wget http://luajit.org/download/LuaJIT$LuajitVer.tar.gz
tar zxf LuaJIT-2.0.0-beta8.tar.gz
cd LuaJIT-2.0.0-beta8
make && make install
ln -sf luajit-2.0.0-beta8 /usr/local/bin/luajit
cd ..
echo "LUAjit............Compiled & Installed."
fi
elif [ $choice = "Back" ] ; then
break
fi
;;
esac
done
elif [ $choice = "Install" ] ; then
while :
do
dialog --backtitle "TFS Menu" --title "Install Menu" --nocancel --menu "Choose an option:" 0 0 0 "APT" "Install APT based compiling libraries(Debian/Ubuntu)." "RPM" "Install RPM based compiling libraries(Fedora/CentOS)." "Back" "Return to the Main Menu." 2> /tmp/instmenu.tmp.$$
value=$?
choice=`cat /tmp/instmenu.tmp.$$`
rm -f /tmp/instmenu.tmp.$$
case $value in
0)
if [ $choice = "APT" ] ; then
clear
apt-get install build-essential libxml2-dev libxml++2.6-dev liblua5.1-0-dev libboost-all-dev libmysql++-dev libgmp3-dev liblua5.1-sql-mysql-dev liblua5.1-sql-sqlite-dev libsqlite3-dev zlib1g-dev dh-autoreconf
elif [ $choice = "RPM" ] ; then
clear
yum install mysql++-devel lua-devel boost-devel gmp-devel lua-sql-mysql lua-sql-sqlite libsqlite3x-devel zlib-devel libxml2-devel libxml++-devel kernel-devel mysql-connector-c++ mysql-connector-c++-devel && yum groupinstall "Development Tools"
elif [ $choice = "Back" ] ; then
break
fi
;;
esac
done
elif [ $choice = "Edit" ] ; then
while :
do
dialog --backtitle "TFS Menu" --title "Edit Menu" --nocancel --menu "Choose an option:" 0 0 0 "ConAC" "Modify flags inside configure.ac." "Config" "Add additional features." "Back" "Return to the Main Menu." 2> /tmp/edtmenu.tmp.$$
value=$?
choice=`cat /tmp/edtmenu.tmp.$$`
rm -f /tmp/edtmenu.tmp.$$
case $value in
0)
if [ $choice = "Back" ] ; then
break
fi
;;
esac
done
elif [ $choice = "Exit" ] ; then
break
fi
;;
esac
done
clear[/bash]

Screenshot:
TFS Menu, Using dialog.
1G4Jm.png


Compile Menu.
8Gc6Z.png


Install Menu.
6wt8R.png


Edit Menu.
rwTDi.png



Change:
Code:
[B]v.3.0[/B]
* Added a small "cleanup" after compiling TFS.(More to clean)
* Added a "checking" to see if dialog is installed on your system.(Root required)

[B]v.2.9:[/B]
* Improved the whole script to use an actual Terminal GUI
* Added better "checks"(more to be improved).
* Code reduced.

[B]v.2.2:[/B]
* Fixed Boost not compiling.
* Added some "checks" for the commands.

I will be adding more stuff to it.

Instructions:
Copy this to any text file and save it as a .sh file.
Move the file to where the TFS source files are at.
Type`./NAME-OF-FILE.sh`
Read and follow instructions.

This is not the final script. it's not done.

Note:
Any kind of testing would be appreciated, the OS in which this can be ran, are:
Any Debian/Ubuntu based Distro.(Needs to have apt-get)
Any Fedora based Distro.(Needs to have yum)
 
Last edited:
This:
Code:
./bjam toolset=gcc variant=release link=static threading=multi --with-filesystem --with-system --with-regex --with-thread --with-date_time
to this please:
Code:
./bjam variant=release link=static threading=multi
 
This:
Code:
./bjam toolset=gcc variant=release link=static threading=multi --with-filesystem --with-system --with-regex --with-thread --with-date_time
to this please:
Code:
./bjam variant=release link=static threading=multi
What? Any reason in particular why would you want to compile all Boost libraries, if they're not all required?

@OP
your script doesn't perform any cleanup? Delete the downloaded archives or copy move the compiled libs to the correct directory (to prevent the need to add additional include dir), for instance.
You could also remove --enable-sqlite --enable-server-diag, since those features are generally not used.
 
Last edited:
I made script using OtLand - Compiling The Forgotten Server in Debian GNU/Linux this tutorial as reference, now I will ask, does it harm in anyway to leave it? or removing it makes some significant improvements?
They're not used by 95% of Linux users I'd imagine, so why leave them in?

There's neither a significant improvement nor it does any harm, it's just the right/optimal thing to do here.

A minimal build -- those who need SQLite support probably know what they're doing and can compile this themselves (don't get me wrong)
 
BUMP, Small Fix v2.2, I'm still learning, so it has a slow update.

Next to add, Proper Clean Up, and the ability to run the server, via the Menu.
 
I finally found some time to post, and here is what I've been doing on some of my spare time.
Future v3.0 TFS Menu:

More to come. This will simplify TFS compiling on Linux, and hopefully reduce the amount of samethreads asking for the same kind of help.

Have a nice day and see you some other day! :D
 
Last edited:
I believe that for me would be easier to compile and run in putty instead of this program help...
 
I believe that for me would be easier to compile and run in putty instead of this program help...

This does run behind putty, it's just a terminal GUI. The whole purpose is to simplify TFS compilation for newbie and Novice alike, I pland make things editable so anyone that knows how to compile a server proper can do so behind this bash script.

Even I like to do it manually with no a gui, but that's just me.
 
bumping such a useful skrypt for all linux newbiez! <3 This script is really easy to use and should help any linux beginner that needs to get his server up!
 
Nice, great job. I added reputation to your account ;).
 
Back
Top