install.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. #ln -s ${SRCPATH_LIBQWCL}/QWClient.h ${SRCPATH_QWBOT}/QWClient.h
  63. #ln -s ${SRCPATH_LIBQWCL}/qwclient_global.h ${SRCPATH_QWBOT}/qwclient_global.h
  64. cd "${SRCPATH_QWBOT}"
  65. qmake
  66. make
  67. if [ -d "${INST_LOCATION}" ]; then
  68. #copy assets over
  69. echo binary
  70. # change into that target directory
  71. cd ${INST_LOCATION}
  72. # first start there:
  73. if [ -f "./${BIN_QWBOT}" ]; then
  74. LD_LIBRARY_PATH=${SRCPATH_LIBQWCL} ./${BIN_QWBOT} &
  75. PID=$!
  76. echo PID $PID
  77. sleep 1
  78. kill $PID
  79. else
  80. echo
  81. echo "It seems there have been problems compiling this thing! The binary ./${BIN_QWBOT} is missing."
  82. echo "This is awkward. Probably some dependency was missing or had a wrong version while compilation."
  83. echo "Better go have a chat to the devs at irc://quakenet.org/qwnet"
  84. echo
  85. exit
  86. fi
  87. # cfg file should have been created by the first start of the qwbot.
  88. # now, lets check the starting script. It should be executable.
  89. if [ -f "${STARTER}" ]; then
  90. chmod u+x "${STARTER}"
  91. fi
  92. cd "${INST_LOCATION}"
  93. echo
  94. echo "The installation is now ready to run. BUT..."
  95. echo
  96. echo "1. Please know, that you need maps. The bot will start downloading them often, which takes time."
  97. echo " It is advised, you get some maps already and put them in the appropriate gamedir under"
  98. echo " ${INST_LOCATION}"
  99. echo " gamedir qw example: ${INST_LOCATION}/qw/maps"
  100. echo " gamedir fortress example: ${INST_LOCATION}/fortress/maps"
  101. echo
  102. echo "2. Please edit the ${CFG_QWBOT}"
  103. echo " For an overview of configuration options, please see the wiki at:"
  104. echo " https://gitlab.netdome.biz/community-messaging-project/qwbot/wikis/home"
  105. echo
  106. echo "3. Now, it's cool to run:"
  107. echo " cd "${INST_LOCATION}" && ./${STARTER}"
  108. echo
  109. echo "4. If you want to update your bot at a later time, go to ${SRCPATH_QWBOT} and run me (${0}) again."
  110. echo
  111. echo "Have fun."
  112. echo
  113. else
  114. #missing
  115. echo "For some reason I can't create or access the target directory ${INST_LOCATION} ..."
  116. exit
  117. fi