install_cmp_qwbot.sh 2.7 KB

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