Guest User

Untitled

a guest
Jul 17th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. RELEASE="57"
  4.  
  5. mangosDir="/home/[user]/source/mangos"
  6. ytdbDir="/home/[user]/source/ytdbase"
  7. ytdbCur="$ytdbDir/R$RELEASE"
  8. mangosSql="$mangosDir/sql/updates"
  9. sd2Sql="/home/[user]/source/scriptdev2/sql/Updates"
  10.  
  11. hostname=127.0.0.1
  12. username=mangos
  13. userpass=mangos
  14. userport=3306
  15. databasename=mangos
  16. databasenamesd2=scriptdev2
  17.  
  18. custom="/home/[user]/source/custom"
  19.  
  20. # fetch from YTDB release MaNGOS revision
  21. cd $ytdbCur
  22. rm *.sql
  23. ls -R > /tmp/files.txt
  24. grep MaNGOS /tmp/files.txt > /tmp/f1a.txt
  25. awk -F "_" '{print $5}' /tmp/f1a.txt > /tmp/f1b.txt
  26. 7z x YTDB_*.7z
  27. sed 's/R//' /tmp/f1b.txt > /tmp/f1c.txt
  28. ls *MaNGOS*sql* > /tmp/f1d.txt
  29. sed -e "s/^/mysql --host=$hostname --user=$username --password=$userpass --port=$userport $databasename < /" /tmp/f1d.txt > /tmp/f1e.txt
  30.  
  31. # create head for ytdb.sh
  32. sed '/MaNGOS/ {
  33. i\'#!/bin/bash'
  34. i\ cd '$ytdbCur'
  35. a\ cd '$mangosSql'
  36. }' /tmp/f1e.txt > /tmp/f1.txt
  37.  
  38. ytdbRev="$(head /tmp/f1c.txt)"
  39. echo "$ytdbRev YTDB starting revision
  40. -- collecting ytdb Updates"
  41. cat /tmp/files.txt | grep mangos_FIX > /tmp/f2a.txt
  42. # bash does not read ( and ) so change it to \( and \)
  43. sed 's|(|\\\(|g;s|)|\\\)|g' /tmp/f2a.txt > /tmp/f2a1.txt
  44. # fetch revision number this updatepack was created for
  45. # add it: $revisionnumber $filename
  46. # afterwards delete the revision number from the updatepacks
  47. grep mangos_FIX /tmp/files.txt | sed 's/\(.*\)\..*/\1/;s|(||g; s|)||g' > /tmp/f2.txt
  48. awk -F"_" '{ print $4}' /tmp/f2.txt > /tmp/f2b.txt
  49. paste -d " " /tmp/f2b.txt /tmp/f2a1.txt > /tmp/f2.txt
  50.  
  51. echo "-- collecting MaNGOS Updates"
  52. cd $mangosSql
  53. ls *mangos* | awk ' $1 > '$ytdbRev'' > /tmp/mangosUpdates.txt
  54. # combine MaNGOS updates and YTDB updates and sort their order of appearance
  55. cat /tmp/mangosUpdates.txt /tmp/f2.txt > /tmp/f3a.txt
  56. sort -n /tmp/f3a.txt > /tmp/f3b.txt
  57. cut -d " " -f2 /tmp/f3b.txt > /tmp/f3.txt
  58.  
  59. # add mysql command and add a line where to cd for and after importing this file
  60. sed -e "s/^/mysql --host=$hostname --user=$username --password=$userpass --port=$userport $databasename < /" /tmp/f3.txt > /tmp/f4a.txt
  61. sed '/mangos_FIX/ {
  62. i\ cd '$ytdbCur'/Updates
  63. a\ cd '$mangosSql'
  64. }' /tmp/f4a.txt > /tmp/f4.txt
  65.  
  66. echo "-- collecting ScriptDev2 Updates"
  67. awk -F "_" '{print $7}' /tmp/f1a.txt > /tmp/f5a.txt
  68. sed 's/R//' /tmp/f5a.txt > /tmp/f5b.txt
  69. sd2Rev="$(head /tmp/f5b.txt)"
  70. # fetch revision number this updatepack was created for
  71. # add it: $revisionnumber $filename
  72. # afterwards delete the revision number from the updatepacks
  73. cd $sd2Sql
  74. echo "$sd2Rev ScriptDev2 starting revision"
  75. ls *mangos* > /tmp/files2.txt
  76. awk -F"_" '{ print $1}' /tmp/files2.txt > /tmp/f5b2.txt
  77. sed 's/r//' /tmp/f5b2.txt > /tmp/f5b3.txt
  78. paste -d " " /tmp/f5b3.txt /tmp/files2.txt > /tmp/f5b4.txt
  79. awk ' $1 > '$sd2Rev'' /tmp/f5b4.txt > /tmp/f5c.txt
  80. cut -d " " -f2 /tmp/f5c.txt > /tmp/f5c1.txt
  81.  
  82. # add mysql command and add a head line where to cd for importing this file
  83. # since SD2 is independet from YTDB updates, this only needs to be done once
  84. echo " cd $sd2Sql" > /tmp/f5d.txt
  85. sed -e "s/^/mysql --host=$hostname --user=$username --password=$userpass --port=$userport $databasename < /" /tmp/f5c1.txt > /tmp/f5e.txt
  86. cat /tmp/f5d.txt /tmp/f5e.txt > /tmp/f5.txt
  87. # add SD2 full scripts file
  88. echo " cd $sd2Sql/../
  89. mysql --host=$hostname --user=$username --password=$userpass --port=$userport $databasenamesd2 < scriptdev2_script_full.sql" > /tmp/f6.txt
  90.  
  91. # add custom files with path where to find them and mysql command
  92. echo " cd $custom" > /tmp/f7a.txt
  93. cd $custom
  94. ls > /tmp/f7b.txt
  95. sed -e "s/^/mysql --host=$hostname --user=$username --password=$userpass --port=$userport $databasename < /" /tmp/f7b.txt > /tmp/f7c.txt
  96. cat /tmp/f7a.txt /tmp/f7c.txt > /tmp/f7.txt
  97.  
  98. echo "-- generate Output File. chmod 755 that file and run it"
  99. cat /tmp/f1.txt /tmp/f4.txt /tmp/f5.txt /tmp/f6.txt /tmp/f7.txt> /home/[user]/Desktop/ytdb.sh
  100.  
  101. cd /tmp/
  102. rm f1a.txt f1b.txt f1c.txt f1d.txt f1e.txt f1.txt f2a1.txt f2a.txt f2b.txt f2.txt f3a.txt f3b.txt f3.txt f4a.txt f4.txt f5a.txt f5b2.txt f5b3.txt f5b4.txt f5b.txt f5c1.txt f5c.txt f5d.txt f5e.txt f5.txt f6.txt f7a.txt f7b.txt f7c.txt f7.txt files2.txt files.txt mangosUpdates.txt
  103.  
  104. echo "-- done"
Add Comment
Please, Sign In to add comment