install_cmp_qwbot.sh 2.8 KB

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