is_cimsqwbot.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #!/bin/bash
  2. if [ ! -d "libqwclient" ]; then
  3. git clone https://github.com/buhnemann/libqwclient.git
  4. INSTALL=1
  5. fi
  6. if [ ! -d "cimsqwbot" ]; then
  7. git clone git://b4r.org/cimsqwbot
  8. INSTALL=1
  9. fi
  10. cd cimsqwbot
  11. BOTPATH=$(pwd)
  12. cd ../libqwclient/
  13. LIBPATH=$(pwd)
  14. CONFIGNAME="$BOTPATH/cimsqwbot.cfg"
  15. STARTSCRIPTNAME="$BOTPATH/startcimsqwbot.sh"
  16. if [ "$INSTALL" == "1" ]; then
  17. # is the configuration file missing? then...
  18. if [ ! -f "$CONFIGNAME" ]; then
  19. cd "$LIBPATH"
  20. git pull
  21. qmake
  22. make
  23. cd "$BOTPATH"
  24. git pull
  25. qmake
  26. make
  27. LD_LIBRARY_PATH=$LIBPATH ./cimsqwbot &
  28. PID=$!
  29. echo PID $PID
  30. sleep 1
  31. kill $PID
  32. # cfg file should have been created by the start of cimsqwbot.
  33. fi
  34. # now, lets create a starting script in cimsqwbot
  35. if [ ! -f "$STARTSCRIPTNAME" ]; then
  36. (
  37. cat <<- EOFINSTALLSCRIPT
  38. #!/bin/sh
  39. BOTPATH="\$pwd"
  40. LIBPATH="\$BOTPATH/../libqwclient/"
  41. if [ "\$(which realpath)" != "" ]; then
  42. LIBPATH="\$(realpath \$LIBPATH)"
  43. fi
  44. echo BOTPATH: "\$BOTPATH"
  45. echo LIBPATH: "\$LIBPATH"
  46. while [ 1 ]; do
  47. cd "\$LIBPATH"
  48. git pull
  49. qmake
  50. make
  51. cd "\$BOTPATH"
  52. git pull
  53. qmake
  54. make
  55. echo started at \$(date) >> runlog.log
  56. LD_LIBRARY_PATH=\$LIBPATH stdbuf -oL ./cimsqwbot | tee -a runlog.log
  57. echo crashed at \$(date) - lol, we never crash. >> runlog.log
  58. sleep 3
  59. done
  60. EOFINSTALLSCRIPT
  61. ) > "$STARTSCRIPTNAME"
  62. if [ -f "$STARTSCRIPTNAME" ]; then
  63. chmod u+x "$STARTSCRIPTNAME"
  64. fi
  65. fi
  66. cd "$BOTPATH"
  67. echo
  68. echo "The installation is now ready to run. BUT..."
  69. echo
  70. echo "1. Because you need the original maps, place pak0.pak and pak1.pak of original quake there:"
  71. echo " $BOTPATH/id1"
  72. echo
  73. echo "2. Please know, that you need maps. The bot will start downloading them often, which takes time."
  74. echo " It is advised, you get some maps already and put them in the appropriate gamedir under"
  75. echo " $BOTPATH"
  76. echo " gamedir qw example: $BOTPATH/qw/maps"
  77. echo " gamedir fortress example: $BOTPATH/fortress/maps"
  78. echo
  79. echo "3. Please edit the $CONFIGNAME"
  80. echo
  81. echo "4. Now, it's cool to run:"
  82. echo " cd "$BOTPATH" && ./startcimsqwbot.sh"
  83. echo
  84. echo "For an overview of configuration options, please see the wiki at:"
  85. echo "http://redmine.b4r.org/projects/cimsqwbot/wiki"
  86. echo
  87. echo "Have fun."
  88. echo
  89. else
  90. echo
  91. echo "It seems the directories 'cimsqwbot' and 'libqwclient' already exist."
  92. echo "So, we did nothing. If you want a fresh install, delete these directories, but"
  93. echo "be sure to save your cimsqwbot.cfg - if you have a good one."
  94. echo
  95. echo "Did nothing."
  96. echo
  97. fi