install_cmp_qwbot.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/usr/bin/env bash
  2. # vim: expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
  3. NEEDS="git qmake make g++"
  4. DIR_LIBQWCL="libqwclient"
  5. DIR_QWBOT="qwbot"
  6. BIN_QWBOT="cmp_qwbot"
  7. CFG_QWBOT="cmp_qwbot.cfg"
  8. STARTER="startcmp_qwbot.sh"
  9. for p in $NEEDS; do
  10. TEST=$(which $p 2> /dev/null)
  11. if [ ! -f "$TEST" ]; then
  12. echo "Sorry, you don't seem to have '$p' installed."
  13. echo "You need these programs before this script will run: $NEEDS"
  14. exit
  15. fi
  16. done
  17. if [ ! -d "${DIR_QWBOT}" ]; then
  18. git clone https://gogs.netdome.biz/community-messaging-project/qwbot.git ${DIR_QWBOT}
  19. INSTALL=1
  20. fi
  21. cd ${DIR_QWBOT}
  22. PATH_QWBOT=$(pwd)
  23. cd ${PATH_QWBOT}/${DIR_LIBQWCL}/
  24. LIBPATH=$(pwd)
  25. CONFIGNAME="${PATH_QWBOT}/${CFG_QWBOT}"
  26. STARTSCRIPTNAME="${PATH_QWBOT}/${STARTER}"
  27. if [ "$INSTALL" == "1" ]; then
  28. # is the configuration file missing? then...
  29. if [ ! -f "$CONFIGNAME" ]; then
  30. cd "${PATH_QWBOT}"
  31. git submodule update --init --recursive
  32. cd "$LIBPATH"
  33. qmake
  34. make
  35. ln -s ${LIBPATH}/QWClient.h ${PATH_QWBOT}/QWClient.h
  36. ln -s ${LIBPATH}/qwclient_global.h ${PATH_QWBOT}/qwclient_global.h
  37. cd "${PATH_QWBOT}"
  38. qmake
  39. make
  40. if [ -f "./${BIN_QWBOT}" ]; then
  41. LD_LIBRARY_PATH=$LIBPATH ./${BIN_QWBOT} &
  42. PID=$!
  43. echo PID $PID
  44. sleep 1
  45. kill $PID
  46. else
  47. echo
  48. echo "It seems there have been problems compiling this thing! The binary ./${BIN_QWBOT} is missing."
  49. echo "This is awkward. Probably some dependency was missing or had a wrong version while compilation."
  50. echo "Better go have a chat to the devs at irc://quakenet.org/qwnet"
  51. echo
  52. exit
  53. fi
  54. # cfg file should have been created by the first start of the qwbot.
  55. fi
  56. # now, lets check the starting script. It should be executable.
  57. if [ -f "$STARTSCRIPTNAME" ]; then
  58. chmod u+x "$STARTSCRIPTNAME"
  59. fi
  60. cd "$PATH_QWBOT"
  61. echo
  62. echo "The installation is now ready to run. BUT..."
  63. echo
  64. echo "1. Please know, that you need maps. The bot will start downloading them often, which takes time."
  65. echo " It is advised, you get some maps already and put them in the appropriate gamedir under"
  66. echo " $PATH_QWBOT"
  67. echo " gamedir qw example: $PATH_QWBOT/qw/maps"
  68. echo " gamedir fortress example: $PATH_QWBOT/fortress/maps"
  69. echo
  70. echo "2. Please edit the $CONFIGNAME"
  71. echo " For an overview of configuration options, please see the wiki at:"
  72. echo " https://gogs.netdome.biz/community-messaging-project/qwbot/wiki/home"
  73. echo
  74. echo "3. Now, it's cool to run:"
  75. echo " cd "$PATH_QWBOT" && ./$STARTER"
  76. echo
  77. echo "Have fun."
  78. echo
  79. else
  80. echo
  81. echo "It seems the directories '$DIR_QWBOT' and '$DIR_LIBQWCL' already exist."
  82. echo "So, we did nothing. If you want a fresh install, delete these directories, but"
  83. echo "be sure to save your $CFG_QWBOT - if you have a good one."
  84. echo
  85. echo "Did nothing."
  86. echo
  87. fi