make_and_put_all.sh 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. #!/usr/bin/env bash
  2. #Paul Klumpp 2012-11-19
  3. cwd=$(pwd)
  4. q2srv=$cwd/../q2srv/
  5. cd $cwd
  6. function checkuser {
  7. if [ "${USER}" == "root" ]; then
  8. echo "Nono! Don't run this as root! Don't!"
  9. echo "Switch to a normal user!"
  10. echo
  11. exit
  12. fi
  13. }
  14. function checkinstalled {
  15. if [ "$1" != "" ]; then
  16. woot=$(which "$1" 2> /dev/null)
  17. if [ -f "$woot" ]; then
  18. echo 1
  19. else
  20. echo 0
  21. fi
  22. fi
  23. }
  24. function systemcheck {
  25. echo "Before continuing, make sure you have the following installed:"
  26. echo "* git"
  27. echo "* make"
  28. echo "* cc"
  29. echo "* screen"
  30. echo "* realpath"
  31. echo "* Lua 5.1, only 5.1!, dev headers"
  32. echo "* libz, also known as zlib1g-dev on Debian/Ubuntu"
  33. echo
  34. echo " PRESS ENTER"
  35. echo
  36. read
  37. software="git make cc realpath lua screen"
  38. for soft in $software; do
  39. see=$(checkinstalled "$soft")
  40. if [ $see -eq 0 ]; then
  41. echo "'$soft' not found on your system. Please have a system administrator install it!"
  42. exit
  43. fi
  44. done
  45. }
  46. level=0
  47. function checkargs {
  48. case "$1" in
  49. clean)
  50. level=3
  51. ;;
  52. update)
  53. level=2
  54. ;;
  55. install)
  56. level=1
  57. ;;
  58. *)
  59. echo "Usage: $0 <clean/update/install>"
  60. echo
  61. echo " clean: cleans the compilation directories, compiles and installs"
  62. echo " update: compiles and installs"
  63. echo " install: just installs the binaries, which are hopefully ready"
  64. echo
  65. exit
  66. ;;
  67. esac
  68. }
  69. function main {
  70. checkuser
  71. checkargs $*
  72. systemcheck
  73. repo[1]="q2admin"
  74. url[1]="https://github.com/hifi/q2admin.git"
  75. cleanit[1]="make clean"
  76. makeit[1]="make"
  77. repo[2]="aq2-tng"
  78. url[2]="https://github.com/hifi/aq2-tng.git"
  79. cleanit[2]="cd source && pwd && make clean"
  80. makeit[2]="cd source && pwd && make"
  81. repo[3]="q2a_mvd"
  82. url[3]="https://gitlab.netdome.biz/pklumpp/q2a_mvd.git"
  83. cleanit[3]=""
  84. makeit[3]=""
  85. repo[4]="gs_starter"
  86. url[4]="https://gitlab.netdome.biz/pklumpp/linux-gameserver-starter.git"
  87. cleanit[4]=""
  88. makeit[4]=""
  89. repo[5]="q2pro"
  90. url[5]="git://github.com/AndreyNazarov/q2pro.git"
  91. cleanit[5]="make clean"
  92. makeit[5]="cp -v ../q2proconfig ./.config && INCLUDES='-DUSE_PACKETDUP=1' make q2proded"
  93. ARCH=$(uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc/ -e s/sparc64/sparc/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/alpha/axp/)
  94. for idx in ${!repo[*]}; do
  95. echo
  96. # always get sources
  97. echo "$idx: ${repo[$idx]} from ${url[$idx]}"
  98. if [ ! -d "${repo[$idx]}" ]; then
  99. echo "Source dir missing, we get it"
  100. GIT_SSL_NO_VERIFY=true git clone ${url[$idx]} ${repo[$idx]}
  101. else
  102. echo "Source dir exists, we update it"
  103. cd $cwd/${repo[$idx]}
  104. GIT_SSL_NO_VERIFY=true git pull
  105. cd ..
  106. fi
  107. if [ $level -gt 2 ]; then
  108. # clean it
  109. cd $cwd/${repo[$idx]}
  110. eval ${cleanit[$idx]}
  111. fi
  112. if [ $level -gt 1 ]; then
  113. # compile it
  114. cd $cwd/${repo[$idx]}
  115. eval ${makeit[$idx]}
  116. fi
  117. if [ $level -gt 0 ]; then
  118. # install it
  119. case "${repo[$idx]}" in
  120. aq2-tng)
  121. if [ -f "game$ARCH.so" ]; then
  122. cp -v game$ARCH.so $q2srv/action/game$ARCH.real.so
  123. cd ..
  124. cd action
  125. cp -v prules.ini $q2srv/action/
  126. cp -vr doc/ $q2srv/action/
  127. cp -vr models/ $q2srv/action/
  128. cp -vr pics/ $q2srv/action/
  129. cp -vr players/ $q2srv/action/
  130. cp -vr sound/ $q2srv/action/
  131. cp -vr tng/ $q2srv/action/
  132. else
  133. echo "Whaaat? 'aq2-tng' did not compile. Something was wrong."
  134. echo
  135. echo "Please find the error messages of the compilation happening above and"
  136. echo "file them as an issue at https://github.com/hifi/aq2-tng"
  137. exit
  138. fi
  139. ;;
  140. q2admin)
  141. if [ -f "game$ARCH.so" ]; then
  142. cp -v game$ARCH.so $q2srv/action/game$ARCH.so
  143. cp -vr plugins/ $q2srv/
  144. else
  145. echo "W0000000t .. q2admin did not compile. Something was wrong."
  146. echo
  147. echo "It's possible that Lua5.1 is missing. "
  148. echo "Or you're just using 'install' as parameter and forgot to compile q2admin first."
  149. echo
  150. echo "If you are on Debian or Ubuntu, please try to install the following"
  151. echo "package server wide: liblua5.1-0-dev"
  152. echo
  153. echo "To do that, try: 'sudo apt-get install liblua5.1-0-dev'"
  154. echo
  155. echo "Then start this script again."
  156. echo
  157. exit
  158. fi
  159. ;;
  160. q2a_mvd)
  161. cp -v mvd.lua $q2srv/plugins/
  162. if [ ! -f "$q2srv/plugins/mvd_transfer.sh" ]; then
  163. cp -uv mvd_transfer.sh $q2srv/plugins/
  164. fi
  165. ;;
  166. gs_starter)
  167. cp -v gs_starter.sh $q2srv/
  168. if [ ! -f "$q2srv/gs_starter.cfg" ]; then
  169. cp -v gs_starter.cfg $q2srv
  170. fi
  171. ;;
  172. q2pro)
  173. if [ -f "q2proded" ]; then
  174. cp -v q2proded $q2srv/
  175. else
  176. echo "Errm... q2pro dedicated did not compile. Something was wrong."
  177. echo
  178. echo "It's possible that ZLIB is missing."
  179. echo "Or you're just using 'install' as parameter and forgot to compile q2proded first."
  180. echo
  181. echo "If you are on Debian or Ubuntu, please try to install the following"
  182. echo "package server wide: zlib1g-dev"
  183. echo
  184. echo "To do that, try: 'sudo apt-get install zlib1g-dev'"
  185. echo
  186. echo "Then start this script again."
  187. echo
  188. exit
  189. fi
  190. ;;
  191. esac
  192. fi
  193. cd $cwd
  194. echo
  195. done
  196. echo
  197. echo "Everything should be in place now."
  198. echo
  199. echo "Please review the files h_passwords.cfg, aq2_*.cfg in 'q2srv/action'."
  200. echo "Other than that ;) read the README file"
  201. echo
  202. }
  203. main $*
  204. # vim: expandtab tabstop=4 autoindent:
  205. # kate: space-indent on; indent-width 4; mixedindent off;