aq2-bsrv-pkg.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. software="git make cc realpath lua screen"
  26. for soft in $software; do
  27. see=$(checkinstalled "$soft")
  28. if [ $see -eq 0 ]; then
  29. echo "'$soft' not found on your system. Please have a system administrator install it!"
  30. exit
  31. fi
  32. done
  33. }
  34. function checkdir {
  35. that=$(pwd | sed -e "s/^.\+\///")
  36. if [ "$that" == "q2compile" ]; then
  37. echo "Not allowed from this directory"
  38. exit
  39. fi
  40. }
  41. level=0
  42. function checkargs {
  43. if [ "$1" == "" ]; then
  44. echo "Usage: $0 <first/update>"
  45. echo
  46. echo " first: gets git baseserver directory, compiles and puts binaries into that directory"
  47. echo " update: updates git baseserver directory"
  48. echo
  49. exit
  50. fi
  51. case "$1" in
  52. first)
  53. level=3
  54. ;;
  55. update)
  56. level=2
  57. ;;
  58. esac
  59. }
  60. function main {
  61. checkuser
  62. checkdir
  63. checkargs $*
  64. systemcheck
  65. repo[1]="aq2-basesrv"
  66. url[1]="https://gitlab.netdome.biz/pklumpp/aq2-base-server.git"
  67. 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/)
  68. for idx in ${!repo[*]}; do
  69. echo
  70. # get sources
  71. if [ $level -gt 0 ]; then
  72. echo "$idx: ${repo[$idx]} from ${url[$idx]}"
  73. if [ ! -d "${repo[$idx]}" ]; then
  74. echo "git dir missing, we get it"
  75. GIT_SSL_NO_VERIFY=true git clone ${url[$idx]} ${repo[$idx]}
  76. else
  77. echo "git dir exists, we update it"
  78. cd $cwd/${repo[$idx]}
  79. GIT_SSL_NO_VERIFY=true git pull
  80. cd ..
  81. fi
  82. fi
  83. case "$level" in
  84. 3)
  85. # first install
  86. # get gits, compile everything cleanly and put it into baseserver directory
  87. cd $cwd/${repo[$idx]}
  88. cd q2compile && ./make_and_put_all.sh clean
  89. ;;
  90. 2)
  91. # update check
  92. # get gits, compile everything and put it into baseserver directory
  93. cd $cwd/${repo[$idx]}
  94. cd q2compile && ./make_and_put_all.sh update
  95. ;;
  96. esac
  97. cd $cwd
  98. echo
  99. done
  100. }
  101. main $*
  102. # vim: expandtab tabstop=4 autoindent:
  103. # kate: space-indent on; indent-width 4; mixedindent off;