Heb12 API Setup Script
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.7 KiB

  1. # Run this as the user you want to run the API on.
  2. # Tested on Debian
  3. # Web server home directory
  4. WWW=/var/www/api
  5. # Heb12 config dir
  6. DIR=/home/$(USER)/.local/share/heb12/
  7. # Default translation
  8. TRANSLATION=web
  9. # location ~ /\. {
  10. # deny all;
  11. # }
  12. all: confirm packages pull setup_biblesearch setup_cbiblesearch git_translations add_biblec
  13. confirm:
  14. echo "Will perform the following:"
  15. echo "Install NodeJS, Go, GCC, Python3 and Pip3"
  16. echo "Pull bibleget, cbibleget, bsearchpyjs, and biblec into $(shell printf ~)"
  17. echo "Install systemd services 'biblesearch' and 'cbibleget'"
  18. echo "Pull 2.3GB of Bible data into $(WWW)/translations"
  19. echo ""
  20. echo "Ctrl+C to cancel, or press any key to begin."
  21. read
  22. packages:
  23. sudo apt install nodejs go gcc python3 python3-pip
  24. pip3 install flask waitress
  25. pull:
  26. git clone https://code.theres.life/heb12/bibleget --recurse-submodules
  27. git clone https://code.theres.life/heb12/cbibleget --recurse-submodules
  28. git clone https://code.theres.life/heb12/bsearchpyjs --recurse-submodules
  29. git clone https://code.theres.life/heb12/biblec --recurse-submodules
  30. setup_biblesearch:
  31. -cd bsearchpyjs; mkdir data; mkdir data/$(TRANSLATION)
  32. cd bsearchpyjs; node compile.js $(WWW)/translations/json/en/$(TRANSLATION).json data/$(TRANSLATION)
  33. sudo sh -c 'echo "[Unit]\n\
  34. Description=biblesearch service\n\
  35. After=network.target\n\
  36. StartLimitIntervalSec=0\n\
  37. \n\
  38. [Service]\n\
  39. Type=simple\n\
  40. Restart=always\n\
  41. RestartSec=1\n\
  42. User=$(USER)\n\
  43. ExecStart=/usr/bin/python3 /home/$(USER)/bsearchpyjs/server.py /home/$(USER)/bsearchpyjs/data/web\n\
  44. \n\
  45. [Install]\n\
  46. WantedBy=multi-user.target\n" > /etc/systemd/system/biblesearch.service'
  47. setup_cbibleget:
  48. sudo sh -c 'echo "[Unit]\n\
  49. Description=cbibleget service\n\
  50. After=network.target\n\
  51. StartLimitIntervalSec=0\n\
  52. \n\
  53. [Service]\n\
  54. Type=simple\n\
  55. Restart=always\n\
  56. RestartSec=1\n\
  57. User=$(USER)\n\
  58. ExecStart=sh -c \"cd /home/$(USER)/cbibleget; go run .\"\n\
  59. \n\
  60. [Install]\n\
  61. WantedBy=multi-user.target\n" > /etc/systemd/system/cbibleget.service'
  62. git_translations:
  63. mkdir $(WWW)/translations
  64. cd $(WWW)/translations; git clone https://github.com/heb12/gratis.json json; rm -rf .git
  65. cd $(WWW)/translations; git clone https://github.com/gratis-bible/bible xml; rm -rf .git
  66. cd $(WWW)/translations; git clone --branch split https://github.com/gratis-bible/bible split; rm -rf .git
  67. add_biblec:
  68. echo Creating Biblec $(TRANSLATION)
  69. -mkdir $(DIR)
  70. -mkdir $(WWW)/translations/biblec
  71. cd biblec; node compiler.js $(WWW)/translations/json/en/$(TRANSLATION).json i $(DIR)
  72. -cp $(DIR)/$(TRANSLATION).* $(WWW)/translations/biblec
  73. remove:
  74. cd; rm -rf $(WWW)/translations
  75. cd; rm -rf bibleget cbibleget biblesearch
  76. rm -rf /etc/systemd/system/cbibleget*
  77. rm -rf /etc/systemd/system/biblesearch*