make_and_put_all.sh 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. if [ "$1" == "" ]; then
  49. echo "Usage: $0 <clean/update/install>"
  50. echo
  51. echo " clean: cleans the compilation directories, compiles and installs"
  52. echo " update: compiles and installs"
  53. echo " install: just installs the binaries, which are hopefully ready"
  54. echo
  55. exit
  56. fi
  57. case "$1" in
  58. clean)
  59. level=3
  60. ;;
  61. update)
  62. level=2
  63. ;;
  64. install)
  65. level=1
  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]="git://b4r.org/q2a_mvd"
  83. cleanit[3]=""
  84. makeit[3]=""
  85. repo[4]="gs_starter"
  86. url[4]="git://b4r.org/gs_starter"
  87. cleanit[4]=""
  88. makeit[4]=""
  89. repo[5]="q2pro"
  90. url[5]="http://git.skuller.net/q2pro"
  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 clone ${url[$idx]}
  101. else
  102. echo "Source dir exists, we update it"
  103. cd $cwd/${repo[$idx]}
  104. 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. cp -v game$ARCH.so $q2srv/action/game$ARCH.real.so
  122. cd ..
  123. cd action
  124. cp -v prules.ini $q2srv/action/
  125. cp -vr doc/ $q2srv/action/
  126. cp -vr models/ $q2srv/action/
  127. cp -vr pics/ $q2srv/action/
  128. cp -vr players/ $q2srv/action/
  129. cp -vr sound/ $q2srv/action/
  130. cp -vr tng/ $q2srv/action/
  131. ;;
  132. q2admin)
  133. if [ -f "game$ARCH.so" ]; then
  134. cp -v game$ARCH.so $q2srv/action/game$ARCH.so
  135. cp -vr plugins/ $q2srv/
  136. else
  137. echo "W0000000t .. q2admin did not compile. Something was wrong."
  138. echo
  139. echo "It's possible that Lua5.1 is missing. "
  140. echo "Or you're just using 'install' as parameter and forgot to compile q2admin first."
  141. echo
  142. echo "If you are on Debian or Ubuntu, please try to install the following"
  143. echo "package server wide: liblua5.1-0-dev"
  144. echo
  145. echo "To do that, try: 'sudo apt-get install liblua5.1-0-dev'"
  146. echo
  147. echo "Then start this script again."
  148. echo
  149. exit
  150. fi
  151. ;;
  152. q2a_mvd)
  153. cp -v mvd.lua $q2srv/plugins/
  154. if [ ! -f "$q2srv/plugins/mvd_transfer.sh" ]; then
  155. cp -uv mvd_transfer.sh $q2srv/plugins/
  156. fi
  157. ;;
  158. gs_starter)
  159. cp -v gs_starter.sh $q2srv/
  160. if [ ! -f "$q2srv/gs_starter.cfg" ]; then
  161. cp -v gs_starter.cfg $q2srv
  162. fi
  163. ;;
  164. q2pro)
  165. cp -v q2proded $q2srv/
  166. ;;
  167. esac
  168. fi
  169. cd $cwd
  170. echo
  171. done
  172. echo
  173. echo "Everything should be in place now."
  174. echo
  175. echo "Please review the files h_passwords.cfg, aq2_*.cfg in 'q2srv/action'."
  176. echo "Other than that ;) read the README file"
  177. echo
  178. }
  179. main $*
  180. # vim: expandtab tabstop=4 autoindent:
  181. # kate: space-indent on; indent-width 4; mixedindent off;