install.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #!/usr/bin/env bash
  2. # vim: expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
  3. # kate: space-indent on; indent-width 2; mixedindent off;
  4. NEEDS="git qmake make g++"
  5. DIR_LIBQWCL="libqwclient"
  6. SRCPATH_QWBOT=$(pwd)
  7. # we certainly hope we are in our repository.
  8. cd ${SRCPATH_QWBOT}/${DIR_LIBQWCL}/
  9. SRCPATH_LIBQWCL=$(pwd)
  10. cd ${SRCPATH_QWBOT}
  11. BIN_QWBOT="cimsqwbot"
  12. CFG_QWBOT="cimsqwbot.cfg"
  13. STARTER="startcimsqwbot.sh"
  14. INST_LOCATION=""
  15. function usage() {
  16. echo "Installation Script for the QWBOT of the community messaging project."
  17. echo "Usage: ${0} <target-directory>"
  18. exit
  19. }
  20. for p in $NEEDS; do
  21. TEST=$(which $p 2> /dev/null)
  22. if [ ! -f "$TEST" ]; then
  23. echo "Sorry, you don't seem to have '$p' installed."
  24. echo "You need these programs before this script will run: $NEEDS"
  25. exit
  26. fi
  27. done
  28. # on first run, we need a target location for binaries, lets explain usage and check for the argument OR the location file.....
  29. # if we have not found the location file, get location from argument.. and go on
  30. if [ "${INST_LOCATION}" == "" ]; then
  31. if [ "$1" != "" ]; then
  32. INST_LOCATION="${1}"
  33. echo "Using target-directory ${INST_LOCATION}"
  34. echo
  35. mkdir -p "${INST_LOCATION}"
  36. if [ -d "${INST_LOCATION}" ]; then
  37. # worked, we save the binary target location in a small file
  38. echo "INST_LOCATION=\"${INST_LOCATION}\"" > install.location
  39. fi
  40. else
  41. # if we found the location file, get location, go on..
  42. if [ -f "install.location" ]; then
  43. source ./install.location
  44. echo "Read target-directory from file ./install.location - it is: ${INST_LOCATION}"
  45. echo "Delete the file if you want to specify a new target directory."
  46. echo
  47. else
  48. # if no argument given AND there is no location file, then give usage info.
  49. usage
  50. fi
  51. fi
  52. fi
  53. # now, we have a target location... lets go on and pull
  54. # if we are in our git directory then update all
  55. git pull
  56. cd "${SRCPATH_QWBOT}"
  57. git submodule update --init --recursive
  58. # we always make them both...
  59. cd "$SRCPATH_LIBQWCL"
  60. qmake
  61. make
  62. cd "${SRCPATH_QWBOT}"
  63. qmake
  64. make
  65. if [ -d "${INST_LOCATION}" ]; then
  66. #copy assets over
  67. echo "Copying qwbot binary..."
  68. cp "${BIN_QWBOT}" "${INST_LOCATION}"
  69. echo "Copying qwclient library..."
  70. mkdir -p "${INST_LOCATION}/libqwclient"
  71. cp "${SRCPATH_LIBQWCL}/*.so.*" "${INST_LOCATION}/libqwclient/"
  72. # change into that target directory
  73. cd ${INST_LOCATION}
  74. # first start there:
  75. if [ -f "./${BIN_QWBOT}" ]; then
  76. LD_LIBRARY_PATH=${SRCPATH_LIBQWCL} ./${BIN_QWBOT} &
  77. PID=$!
  78. echo PID $PID
  79. sleep 1
  80. kill $PID
  81. else
  82. echo
  83. echo "It seems there have been problems compiling this thing! The binary ./${BIN_QWBOT} is missing."
  84. echo "This is awkward. Probably some dependency was missing or had a wrong version while compilation."
  85. echo "Better go have a chat to the devs at irc://quakenet.org/qwnet"
  86. echo
  87. exit
  88. fi
  89. # cfg file should have been created by the first start of the qwbot.
  90. # now, lets check the starting script. It should be executable.
  91. if [ -f "${STARTER}" ]; then
  92. chmod u+x "${STARTER}"
  93. fi
  94. cd "${INST_LOCATION}"
  95. echo
  96. echo "The installation is now ready to run. BUT..."
  97. echo
  98. echo "1. Please know, that you need maps. The bot will start downloading them often, which takes time."
  99. echo " It is advised, you get some maps already and put them in the appropriate gamedir under"
  100. echo " ${INST_LOCATION}"
  101. echo " gamedir qw example: ${INST_LOCATION}/qw/maps"
  102. echo " gamedir fortress example: ${INST_LOCATION}/fortress/maps"
  103. echo
  104. echo "2. Please edit the ${CFG_QWBOT}"
  105. echo " For an overview of configuration options, please see the wiki at:"
  106. echo " https://gitlab.netdome.biz/community-messaging-project/qwbot/wikis/home"
  107. echo
  108. echo "3. Now, it's cool to run:"
  109. echo " cd "${INST_LOCATION}" && ./${STARTER}"
  110. echo
  111. echo "4. If you want to update your bot at a later time, go to ${SRCPATH_QWBOT} and run me (${0}) again."
  112. echo
  113. echo "Have fun."
  114. echo
  115. else
  116. #missing
  117. echo "For some reason I can't create or access the target directory ${INST_LOCATION} ..."
  118. exit
  119. fi