Jump to content

MaNGOS Installer a MaNGOS-tool for Linux


Guest Helias

Recommended Posts

I'm working to an application, written in Python, that installs MaNGOS on Linux.

It's a beta version, try it!

Source code:

file: create MaNGOS.py

import os

#Configuration

#Insert in this variables your user  ex. youruser="helias"
youruser="" 

#End Configuration

#Install Softwares
os.system("gksudo apt-get update")
os.system("gksudo apt-get install unzip build-essential gcc g++ cpp automake git-core autoconf make patch libmysql++-dev libtool libssl-dev grep binutils subversion zlibc libc6 nano wine unrar")
os.system("gksudo apt-get install mysql-server mysql-client")

#For the Sources
os.system("mkdir sources")
os.system("cd sources; git clone git://github.com/mangos/mangos.git;")
os.system("cd sources/mangos/; svn co [url]https://scriptdev2.svn.sourceforge.net/svnroot/scriptdev2/[/url] src/bindings/ScriptDev2/")

#Patches of SD2 9519
os.system("cd sources/mangos/; git am $(ls src/bindings/ScriptDev2/patches/MaNGOS-9519-ScriptDev2.patch | grep -v gz)")

#Compilation
os.system("cd sources/mangos/; autoreconf --install --force")
os.system("cd sources/mangos/; mkdir objdir; cd objdir;")
os.system("cd sources/mangos/objdir; ../configure --prefix=/home/%s/MaNGOS --sysconfdir=/home/%s/MaNGOS/etc --enable-cli --enable-ra --datadir=/home/%s/MaNGOS;"%(youruser,youruser,youruser))
os.system("cd sources/mangos/objdir; make; make install;")

#Dbc & Maps
os.system("cp /home/%s/sources/mangos/contrib/extractor/ad.exe \\"/home/%s/World of Warcraft/ad.exe\\""% (youruser,youruser))
os.system("cd \\"World of Warcraft\\"; wine ad.exe;")
os.system("mv \\"/home/%s/World of Warcraft/dbc\\" /home/%s/MaNGOS/bin; mv \\"/home/%s/World of Warcraft/maps\\" /home/%s/MaNGOS/bin "% (youruser, youruser, youruser, youruser))

file: download.py

import os
import urllib

#Downloading files
download = urllib.URLopener()

zip = os.path.exists("UDB_Pack/388full.zip")
ton = os.path.exists("UDB_Pack/389_corepatch_mangos_9583_to_9630.sql")
tons = os.path.exists("UDB_Pack/389_updatepack_mangos.sql")
tnz = os.path.exists("UDB_Pack/390_corepatch_mangos_9631_to_9763.sql")
tnzs = os.path.exists("UDB_Pack/390_updatepack_mangos.sql")
tnu = os.path.exists("UDB_Pack/391_corepatch_mangos_9764_to_9999.sql")
tnus = os.path.exists("UDB_Pack/391_updatepack_mangos.sql")
tnd = os.path.exists("UDB_Pack/392_corepatch_mangos_10000_to_10258.sql")
tnds = os.path.exists("UDB_Pack/392_updatepack_mangos.sql")

os.system("mkdir ./UDB_Pack")

while zip != True:
   zip = os.path.exists("UDB_Pack/388full.zip")
   download.retrieve("https://unifieddb.svn.sourceforge.net/svnroot/unifieddb/trunk/Full_DB/UDB_0.12.0_mangos_9582_SD2_1639.zip", "388full.zip")
   os.system("mv ./388full.zip ./UDB_Pack/388full.zip")
print "Finish download of 388full.zip"

while ton != True:
   ton = os.path.exists("UDB_Pack/389_corepatch_mangos_9583_to_9630.sql")
   download.retrieve("https://unifieddb.svn.sourceforge.net/svnroot/unifieddb/trunk/Updates/0.12.0_additions/389_corepatch_mangos_9583_to_9630.sql", "389_corepatch_mangos_9583_to_9630.sql")
   os.system("mv ./389_corepatch_mangos_9583_to_9630.sql ./UDB_Pack/389_corepatch_mangos_9583_to_9630.sql")    
print "Finish download of 389_corepatch_mangos_9583_to_9630.sql"

while tons != True:
   tons = os.path.exists("UDB_Pack/389_updatepack_mangos.sql")
   download.retrieve("https://unifieddb.svn.sourceforge.net/svnroot/unifieddb/trunk/Updates/0.12.0_additions/389_updatepack_mangos.sql", "389_updatepack_mangos.sql")
   os.system("mv ./389_updatepack_mangos.sql ./UDB_Pack/389_updatepack_mangos.sql")    
print "Finish download of 389_updatepack_mangos.sql"

while tnz != True:
   tnz = os.path.exists("UDB_Pack/390_corepatch_mangos_9631_to_9763.sql")
   download.retrieve("https://unifieddb.svn.sourceforge.net/svnroot/unifieddb/trunk/Updates/0.12.0_additions/390_corepatch_mangos_9631_to_9763.sql", "390_corepatch_mangos_9631_to_9763.sql")
   os.system("mv ./390_corepatch_mangos_9631_to_9763.sql ./UDB_Pack/390_corepatch_mangos_9631_to_9763.sql")
print "Finish download of 390_corepatch_mangos_9631_to_9763.sql"

while tnzs != True:
   tnzs = os.path.exists("UDB_Pack/390_updatepack_mangos.sql")
   download.retrieve("https://unifieddb.svn.sourceforge.net/svnroot/unifieddb/trunk/Updates/0.12.0_additions/390_updatepack_mangos.sql", "390_updatepack_mangos.sql")
   os.system("mv ./390_updatepack_mangos.sql ./UDB_Pack/390_updatepack_mangos.sql")
print "Finish download of 390_updatepack_mangos.sql"

while tnu != True:
   tnu = os.path.exists("UDB_Pack/391_corepatch_mangos_9764_to_9999.sql")
   download.retrieve("https://unifieddb.svn.sourceforge.net/svnroot/unifieddb/trunk/Updates/0.12.0_additions/391_corepatch_mangos_9764_to_9999.sql", "391_corepatch_mangos_9764_to_9999.sql")
   os.system("mv ./391_corepatch_mangos_9764_to_9999.sql ./UDB_Pack/391_corepatch_mangos_9764_to_9999.sql")
print "Finish download of 391_corepatch_mangos_9764_to_9999.sql"

while tnus != True:
   tnus = os.path.exists("UDB_Pack/391_updatepack_mangos.sql")
   download.retrieve("https://unifieddb.svn.sourceforge.net/svnroot/unifieddb/trunk/Updates/0.12.0_additions/391_updatepack_mangos.sql", "391_updatepack_mangos.sql")
   os.system("mv ./391_updatepack_mangos.sql ./UDB_Pack/391_updatepack_mangos.sql")
print "Finish download of 391_updatepack_mangos.sql"

while tnd != True:
   tnd = os.path.exists("UDB_Pack/392_corepatch_mangos_10000_to_10258.sql")
   download.retrieve("https://unifieddb.svn.sourceforge.net/svnroot/unifieddb/trunk/Updates/0.12.0_additions/392_corepatch_mangos_10000_to_10258.sql", "392_corepatch_mangos_10000_to_10258.sql")
   os.system("mv ./392_corepatch_mangos_10000_to_10258.sql ./UDB_Pack/392_corepatch_mangos_10000_to_10258.sql")
print "Finish download of 392_corepatch_mangos_10000_to_10258.sql"

while tnds != True:
   tnds = os.path.exists("UDB_Pack/392_updatepack_mangos.sql")
   download.retrieve("https://unifieddb.svn.sourceforge.net/svnroot/unifieddb/trunk/Updates/0.12.0_additions/392_updatepack_mangos.sql", "392_updatepack_mangos.sql")
   os.system("mv ./392_updatepack_mangos.sql ./UDB_Pack/392_updatepack_mangos.sql")
print "Finish download of 392_updatepack_mangos.sql"

print "Finish all download!"
os.system("unzip ./UDB_Pack/388full.zip")
os.system("mv ./UDB_0.12.0_mangos_9582_SD2_1639.sql ./UDB_Pack/UDB_0.12.0_mangos_9582_SD2_1639.sql")
print "Finish unzipping of 388full.zip"

#Merging files
print "Making UDB 392 full.."
fileu=open("./UDB_Pack/UDB_0.12.0_mangos_9582_SD2_1639.sql", "r").read()
filed=open("./UDB_Pack/389_corepatch_mangos_9583_to_9630.sql", "r").read()
filet=open("./UDB_Pack/389_updatepack_mangos.sql", "r").read()
fileq=open("./UDB_Pack/390_corepatch_mangos_9631_to_9763.sql", "r").read()
filec=open("./UDB_Pack/390_updatepack_mangos.sql", "r").read()
files=open("./UDB_Pack/391_corepatch_mangos_9764_to_9999.sql", "r").read()
filese=open("./UDB_Pack/391_updatepack_mangos.sql", "r").read()
fileo=open("./UDB_Pack/392_corepatch_mangos_10000_to_10258.sql", "r").read()
filen=open("./UDB_Pack/392_updatepack_mangos.sql", "r").read()
udbfull=("%s\\n%s\\n%s\\n%s\\n%s\\n%s\\n%s\\n%s\\n%s"% (fileu, filed, filet, fileq, filec, files, filese, fileo, filen))
udb389=open("392full.sql", "w+")
udb389.write(udbfull)
udb389.close()
os.system("mv ./392full.sql ./UDB_Pack/392full.sql")
print "Finish 392full.sql"

file: MaNGOS-Database.py

import os

#Configuration

#Insert in this variables your user(/home/youruser/) ex. youruser="helias"
youruser=""

#Mysql data

#Insert in this variables your name host
host=""
#Username for connect to database
username=""
#Password of database
password=""

#End Configuration

os.system("mkdir /home/%s/MaNGOS/bin/Logs"% youruser)

#mangosd.conf 
os.system("cp /home/%s/MaNGOS/etc/mangosd.conf.dist /home/%s/MaNGOS/etc/mangosd.conf"% (youruser, youruser))
filemgs=open("/home/%s/MaNGOS/etc/mangosd.conf" % youruser, "r").read()
filemgs=filemgs.replace("LoginDatabaseInfo     = \\"127.0.0.1;3306;mangos;mangos;realmd\\"", "LoginDatabaseInfo     = \\"127.0.0.1;3306;%s;%s;realmd\\""% (username, password))
filemgs=filemgs.replace("WorldDatabaseInfo     = \\"127.0.0.1;3306;mangos;mangos;mangos\\"", "WorldDatabaseInfo     = \\"127.0.0.1;3306;%s;%s;mangos\\""% (username, password))
filemgs=filemgs.replace("CharacterDatabaseInfo = \\"127.0.0.1;3306;mangos;mangos;characters\\"", "CharacterDatabaseInfo     = \\"127.0.0.1;3306;%s;%s;characters\\""% (username, password))
filemgs=filemgs.replace("LogsDir = \\"\\"", "LogsDir = \\"Logs\\"")
filemgs=filemgs.replace("GmLogPerAccount = 0", "GmLogPerAccount = 1")
filemgs=filemgs.replace("LogLevel = 3", "LogLevel = 0")
filemgs=filemgs.replace("LogColors = \\"\\"", "LogColors = \\"10 8 11 9\\"")
filed=open("/home/%s/MaNGOS/etc/mangosd.conf"% youruser, "w")
filed.write(filemgs)
filed.close()
print "mangosd.conf configured."

#realmd.conf
os.system("cp /home/%s/MaNGOS/etc/realmd.conf.dist /home/%s/MaNGOS/etc/realmd.conf"% (youruser, youruser))
filere=open("/home/%s/MaNGOS/etc/realmd.conf"% youruser, "r").read()
filere=filere.replace("LoginDatabaseInfo = \\"127.0.0.1;3306;mangos;mangos;realmd\\"", "LoginDatabaseInfo = \\"127.0.0.1;3306;%s;%s;realmd\\""% (username, password))
filere=filere.replace("LogsDir = \\"\\"", "LogsDir = \\"Logs\\"")
filere=filere.replace("LogFileLevel = 0", "LogFileLevel = 3")
filere=filere.replace("LogColors = \\"\\"", "LogColors = \\"10 8 11 9\\"")
filere=filere.replace("LogLevel = 0", "LogLevel = 3")
fileres=open("/home/%s/MaNGOS/etc/realmd.conf"% youruser, "w")
fileres.write(filere)
fileres.close()
print "realmd.conf configured."

#scriptdev2.conf
filesds=open("/home/%s/MaNGOS/etc/scriptdev2.conf"% youruser, "r").read()
filesds=filesds.replace("ScriptDev2DatabaseInfo     = \\"127.0.0.1;3306;mangos;mangos;scriptdev2\\"","ScriptDev2DatabaseInfo     = \\"127.0.0.1;3306;%s;%s;scriptdev2\\""% (username, password))
filesdsd=open("/home/%s/MaNGOS/etc/scriptdev2.conf"% youruser, "w")
filesdsd.write(filesds)
filesdsd.close()
print "scriptdev2 configured."

#Server Restarter

#for mangos-worldd
os.system("touch /home/%s/MaNGOS/bin/mangos-worldd.h"% youruser)
os.system("chmod +x /home/%s/MaNGOS/bin/mangos-worldd.h"% youruser)
filewdd=open("/home/%s/MaNGOS/bin/mangos-worldd.h"% youruser, "w")
filewdd.write("while date;\\ndo MANGOS=`ps -el | grep mangos-worldd`;\\nif [ -z \\"$MANGOS\\" ];\\nthen echo restarting server at time at `date +\\"%"+"m-%"+"d-%"+"H:%"+"M-%"+"S\\"`>> worldd_restart_log.txt;\\nnice -n 20 /home/%s/MaNGOS/bin/mangos-worldd;\\nfi;\\nsleep 5;\\ndone"% youruser)
filewdd.close()

#for mangos-realmd
os.system("touch /home/%s/MaNGOS/bin/mangos-realmd.h"% youruser)
os.system("chmod +x /home/%s/MaNGOS/bin/mangos-realmd.h"% youruser)
filermd=open("/home/%s/MaNGOS/bin/mangos-realmd.h"% youruser, "w")
filermd.write("while date;\\ndo MANGOS=`ps -el | grep realmd-worldd`;\\nif [ -z \\"$MANGOS\\" ];\\nthen echo restarting server at time at `date +\\"%"+"m-%"+"d-%"+"H:%"+"M-%"+"S\\"`>> realmd_restart_log.txt;\\nnice -n 20 /home/%s/MaNGOS/bin/mangos-realmd;\\nfi;\\nsleep 5;\\ndone"% youruser)
filermd.close()
print "Create server MaNGOS restarter."

#Database

#Create databases
os.system("mysqladmin -h %s -u %s -p%s CREATE mangos"% (host, username, password))
os.system("mysqladmin -h %s -u %s -p%s CREATE realmd"% (host, username, password))
os.system("mysqladmin -h %s -u %s -p%s CREATE characters"% (host, username, password))
os.system("mysqladmin -h %s -u %s -p%s CREATE scriptdev2"% (host, username, password))

#Import DB files

#Realmd
os.system("mysql -u %s -p%s realmd < /home/%s/sources/mangos/sql/realmd.sql"% (username, password, youruser))
print "realmd imported"
#Characters
os.system("mysql -u %s -p%s characters < /home/%s/sources/mangos/sql/characters.sql"% (username, password, youruser))
print "characters imported"
#Mangos 
os.system("mysql -u %s -p%s mangos < /home/%s/UDB_Pack/392full.sql"% (username, password, youruser))
print "Database 392full.sql imported."
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10263_01_mangos_pool_creature.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10263_02_mangos_pool_gameobject.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10263_03_mangos_pool_pool.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10270_01_mangos_reputation_spillover_template.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10286_01_mangos_creature_addon.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10289_01_mangos_creature_template.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10289_02_mangos_creature_model_info.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10299_01_mangos_event_id_scripts.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10307_01_mangos_instance_template.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10307_02_mangos_scripted_areatrigger.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10307_03_mangos_scripted_event_id.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10314_01_mangos_mangos_string.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10314_02_mangos_command.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10323_01_mangos_mangos_string.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10323_02_mangos_command.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10331_01_mangos_mangos_string.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10331_02_mangos_command.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10342_01_mangos_mangos_string.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10342_02_mangos_command.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10349_01_mangos_spell_proc_event.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10350_02_mangos_command.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10353_01_mangos_mangos_string.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10353_02_mangos_command.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10362_01_mangos_creature_movement_template.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10365_01_mangos_creature_ai_scripts.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s mangos < /home/%s/sources/mangos/sql/updates/10381_01_mangos_creature_model_race.sql"% (username, password, youruser))
print "mangos_updates imported."
#Scriptdev2
os.system("mysql -u %s -p%s scriptdev2 < /home/%s/sources/mangos/src/bindings/ScriptDev2/sql/scriptdev2_create_structure_mysql.sql"% (username, password, youruser))
os.system("mysql -u %s -p%s scriptdev2 < /home/%s/sources/mangos/src/bindings/ScriptDev2/sql/scriptdev2_script_full.sql"% (username, password, youruser))
print "scriptdev2 imported."
print "Database imported."

Download MaNGOS-Installer

Link to comment
Share on other sites

sounds like an interesting idea, however your current implementation is too static. Meaning when UDB 393 comes out you'll need to update and redistribute your tool.

instead of downloading the updates individually, you could just checkout the whole repository and the cycle though the files in a loop, instead of using a hardcoded list of what to execute

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use