cinderweb

Untitled

Sep 17th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.21 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # Update all packages
  4. su vagrant
  5. echo "Updating the Virtual Machine (if this is the first time you're running this"
  6. echo "machine, it can take some time)..."
  7. sudo apt-get -y update &> /dev/null
  8. sudo apt-get -y upgrade &> /dev/null
  9.  
  10. # Install dependancies necessary for compiling tmwa
  11. echo "Installing tmwa dependancies:"
  12.  
  13. DEPS="build-essential flex bison git"
  14.  
  15. for pkg in $DEPS; do
  16. PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $pkg|grep "install ok installed")
  17. if [ "" == "$PKG_OK" ]; then
  18. echo Installing $pkg...
  19. sudo apt-get --force-yes --yes install $pkg &> /dev/null
  20. else
  21. echo $pkg is already installed. Skipping installation.
  22. fi
  23. done
  24.  
  25. # Set up sharing the folder with the host OS
  26. if [ ! -d "/home/vagrant/tmwAthena/" ]; then
  27. echo Setting up folder sharing for content...
  28. ln -fs /vagrant/ /home/vagrant/tmwAthena &> /dev/null
  29. else
  30. echo Folder sharing already set up. Skipping.
  31. fi
  32.  
  33. # Set up tmwa and tmwa-server-data repositories and compile tmwa
  34. if [ -d "/home/vagrant/tmwAthena/tmwa" ]; then
  35. echo "Checking for updates for the themanaworld/tmwa clone..."
  36. cd /home/vagrant/tmwAthena/tmwa
  37. echo "Switching to branch master to preserve local changes..."
  38. git checkout master &> /dev/null || echo "[Error] Failed to switch branches."
  39. TMWA_UPDT=$(git pull)
  40. if [ "$TMWA_UPDT" == "Already up-to-date." ]; then
  41. echo "themanaworld/tmwa clone is already up to date."
  42. # Make install just in case the clone is from a previous VM
  43. sudo make install &> /dev/null
  44. else
  45. echo "themanaworld/tmwa clone updated."
  46. echo "Rebuilding tmwa (please be patient, this can take some time)..."
  47. git submodule update --init &> /dev/null
  48. make clean &> /dev/null
  49. ./configure &> /dev/null
  50. make &> /dev/null
  51. sudo make install &> /dev/null
  52. fi
  53. else
  54. echo "Cloning themanaworld/tmwa..."
  55. cd /home/vagrant/tmwAthena
  56. git clone --recursive git://github.com/themanaworld/tmwa.git &> /dev/null || echo "[Error] Cloning tmwa failed."
  57. cd /home/vagrant/tmwAthena/tmwa/deps/attoconf
  58. sudo ./setup.py install &> /dev/null
  59. cd /home/vagrant/tmwAthena/tmwa
  60. echo "Building tmwa (please be patient, this can take some time)..."
  61. ./configure &> /dev/null || echo "[Error] Configure failed for tmwa."
  62. make &> /dev/null || echo "[Error] Building tmwa failed."
  63. sudo make install &> /dev/null || echo "[Error] Make install for tmwa failed."
  64. git config --global [email protected]:.pushInsteadOf git://github.com
  65. fi
  66. if [ -d "/home/vagrant/tmwAthena/tmwa-server-data" ]; then
  67. echo "Checking for updates for the themanaworld/tmwa-server-data clone..."
  68. cd /home/vagrant/tmwAthena/tmwa-server-data
  69. echo "Switching to branch master to preserve local changes..."
  70. git checkout master &> /dev/null || echo "[Error] Failed to switch branches."
  71. TMWASD_UPDT=$(git pull)
  72. if [ "$TMWASD_UPDT" == "Already up-to-date." ]; then
  73. echo "themanaworld/tmwa-server-data clone is already up to date."
  74. else
  75. echo "Updating magic..."
  76. cd /home/vagrant/tmwAthena/tmwa-server-data/world/map/conf
  77. wget -N -O spells-build https://gist.github.com/DinoPaskvan/6283572/raw/56b607a04990f396ad9a1c9af5a72663bc62cedf/spells-build &> /dev/null
  78. chmod 777 spells-build
  79. cp magic.conf.template magic.conf
  80. ./build-magic.sh
  81. echo "themanaworld/tmwa-server-data clone updated."
  82. fi
  83. else
  84. echo "Cloning themanaworld/tmwa-server-data..."
  85. cd /home/vagrant/tmwAthena
  86. git clone --recursive git://github.com/themanaworld/tmwa-server-data.git &> /dev/null || echo "[Error] Cloning tmwa-server-data failed."
  87. cd tmwa-server-data
  88. echo "Setting up update hooks..."
  89. ln -s ../../git/hooks/post-merge .git/hooks/ &> /dev/null
  90. ln -s ../../../../git/hooks/post-merge .git/modules/client-data/hooks/ &> /dev/null
  91. echo Creating the configuration files...
  92. make conf &> /dev/null
  93. # Checkout master branches inside client-data
  94. cd client-data &> /dev/null
  95. git checkout master &> /dev/null
  96. cd music &> /dev/null
  97. git checkout master &> /dev/null
  98. # Set up magic
  99. echo "Setting up magic..."
  100. cd /home/vagrant/tmwAthena/tmwa-server-data/world/map/conf
  101. wget -O spells-build https://gist.github.com/DinoPaskvan/6283572/raw/ae439049895f89925550127e9d22b80761cd2d6b/spells-build &> /dev/null
  102. chmod 777 spells-build
  103. cp magic.conf.template magic.conf
  104. ./build-magic.sh
  105. fi
  106.  
  107. # Run the tmwa server
  108. cd /home/vagrant/tmwAthena/tmwa-server-data/
  109. echo "Starting the server..."
  110. ./char-server& ./login-server& ./map-server&
  111. sleep 15
  112.  
  113. # Check for admin account and create it if it doesn't exist
  114. cd /home/vagrant/tmwAthena/tmwa-server-data/login/save
  115. CHK_ACC=$(cat account.txt | grep admin)
  116. if [ "$CHK_ACC" == "" ]; then
  117. echo "GM account can't be found, creating..."
  118. cd /home/vagrant/tmwAthena/tmwa-server-data/login
  119. ladmin <<END
  120. add admin M vagrant
  121. gm admin 99
  122. exit
  123. exit
  124. END
  125. else
  126. echo "GM account is already set up."
  127. fi
  128.  
  129. # Output info about the server
  130. echo "##############################################################################"
  131. echo "# #"
  132. echo "# Server is now running. You can reach it by adding a new server to your #"
  133. echo "# client: #"
  134. echo "# Name: Local Server #"
  135. echo "# Address: localhost #"
  136. echo "# Port: 6901 #"
  137. echo "# Server type: TmwAthena #"
  138. echo "# A GM level 99 account has been created for you with the following #"
  139. echo "# credentials: #"
  140. echo "# Username: admin #"
  141. echo "# Password: vagrant #"
  142. echo "# Have fun! #"
  143. echo "# #"
  144. echo "##############################################################################"
Advertisement
Add Comment
Please, Sign In to add comment