is_cimsqwbot.sh 2.6 KB

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