Source code for the modding-openmw.com website https://modding-openmw.com/
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.
 
 
 
 
 

178 lines
6.3 KiB

  1. proj_dir := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
  2. .DEFAULT_GOAL := server
  3. host_check:
  4. ifndef HOSTS
  5. @echo "\n\033[31mPLEASE PROVIDE THE '\033[91mHOSTS\033[31m' VARIABLE!\nUSAGE: \033[91mmake TARGET HOSTS=some_hosts_or_host_group\033[0m\n"
  6. @exit 1
  7. endif
  8. get-versions:
  9. @echo PRODUCTION:
  10. @http --print b https://modding-openmw.com/_stat/
  11. @echo STAGING:
  12. @http --print b https://staging.modding-openmw.com/_stat/
  13. @echo BETA:
  14. @http --print b https://beta.modding-openmw.com/_stat/
  15. clean:
  16. /bin/rm -fr *.sqlite3 src && for d in $$(find . -name __pycache__); do rm -rf $${d}; done
  17. migrate:
  18. $(proj_dir)/momw/manage.py migrate
  19. makemigrations:
  20. $(proj_dir)/momw/manage.py makemigrations
  21. shell:
  22. $(proj_dir)/momw/manage.py shell
  23. smtpd:
  24. python3 -m smtpd -n -c DebuggingServer localhost:1025
  25. refreshdb:
  26. sudo -u momwdb dropdb momwdb && sudo -u momwdb createdb momwdb
  27. seeddb:
  28. $(proj_dir)/bin/seed_db.py
  29. reset: clean refreshdb migrate seeddb
  30. server:
  31. $(proj_dir)/momw/manage.py runserver 0.0.0.0:8666
  32. pip-requirements:
  33. pip3 install --user -r requirements.txt
  34. start-xvfb-ci:
  35. $(proj_dir)/bin/start_xvfb.sh
  36. test-black:
  37. ifneq (, $(shell which black 2>/dev/null))
  38. black --check $(proj_dir)
  39. else
  40. @echo black executable not found!
  41. endif
  42. test-flake8:
  43. find $(proj_dir) -type f -name "*.py" | xargs flake8 --verbose
  44. test-dropdb:
  45. sudo -u momwdb dropdb test_momwdb || echo test db is gone
  46. test-chroniko:
  47. $(proj_dir)/momw/manage.py test chroniko.tests
  48. test-media:
  49. $(proj_dir)/momw/manage.py test media.tests
  50. test-momw:
  51. $(proj_dir)/momw/manage.py test momw.tests
  52. test-utilz:
  53. $(proj_dir)/momw/manage.py test utilz.tests
  54. test-djangotests: test-chroniko test-momw test-utilz
  55. ifndef SKIPTESTS
  56. test: test-black test-flake8 test-dropdb test-djangotests
  57. else
  58. test:
  59. @echo Skipped tests due to the presence of the SKIPTESTS env var!
  60. endif
  61. django: host_check test
  62. cd ../playbooks && \
  63. ansible-playbook site.yml --extra-vars "control_hosts=$(HOSTS) \
  64. control_msg='Momw Django App Setup' \
  65. control_user=root \
  66. django_db_migrate=true \
  67. django_db_seed=true \
  68. django_start=true \
  69. django_sync_code=true \
  70. django_drop_db=true" \
  71. --tags user,nginx,postgresql,memcached,django \
  72. --vault-password-file ${CURDIR}/auth
  73. django-migrate: host_check test
  74. cd ../playbooks && \
  75. ansible-playbook site.yml --extra-vars "control_hosts=$(HOSTS) \
  76. control_msg='Run Momw Django db migrations' \
  77. control_user=$(CONTROL_USER) \
  78. db_migrate=true" \
  79. --tags ircspam,migration
  80. django-seeddb: host_check test
  81. cd ../playbooks && \
  82. ansible-playbook site.yml --extra-vars "control_hosts=$(HOSTS) \
  83. control_msg='Momw Django database seed' \
  84. control_user=root \
  85. django_db_migrate=true \
  86. django_db_seed=true" \
  87. --tags ircspam,django_seeddb
  88. django-resetdb: host_check test ## Reset the remote database with new data
  89. cd ../playbooks && \
  90. ansible-playbook site.yml --extra-vars "control_hosts=$(HOSTS) \
  91. control_msg='Momw Django database reset' \
  92. control_user=root \
  93. django_db_migrate=true \
  94. django_db_seed=true \
  95. django_drop_db=true" \
  96. --tags ircspam,django_seeddb,django_resetdb \
  97. --vault-password-file ${CURDIR}/auth
  98. django-warmcache: host_check
  99. cd ../playbooks && \
  100. ansible-playbook site.yml --extra-vars "control_hosts=$(HOSTS) \
  101. control_msg='Momw Django cache warm' \
  102. control_user=root \
  103. django_warmcache=true" \
  104. --tags ircspam,warmcache
  105. sync: host_check test
  106. cd ../playbooks && \
  107. ansible-playbook site.yml --extra-vars "control_hosts=$(HOSTS) \
  108. control_msg='Momw Code Sync & Restart' \
  109. control_user=root \
  110. django_git=true \
  111. django_sync_code=true" \
  112. --tags ircspam,django_sync
  113. memcached-restart: host_check
  114. cd ../playbooks && \
  115. ansible-playbook site.yml --extra-vars "control_hosts=$(HOSTS) \
  116. control_msg='memcached service restart' \
  117. control_user=root \
  118. memcached_restart=true" \
  119. --tags ircspam,memcached
  120. # ffmpeg -i input.flv -codec copy output.mp4
  121. # ffmpeg -i input.mp4 -ss 00:00:02 -to 00:15:40 -c copy output.mp4
  122. add-watermark-to-video:
  123. ifndef INFILE
  124. @echo YOU NEED TO PROVIDE AN 'INFILE' e.g. INFILE=foo make add-watermark-to-video!
  125. @exit 1
  126. endif
  127. ifndef OUTFILE
  128. @echo YOU NEED TO PROVIDE AN 'OUTFILE' e.g. OUTFILE=foo make add-watermark-to-video!
  129. @exit 1
  130. endif
  131. ffmpeg -i $(INFILE) -i $(proj_dir)/momw/static/onesixth-watermark.png -filter_complex "overlay=20:20" -max_muxing_queue_size 1024 $(OUTFILE)
  132. add-watermark-to-image:
  133. ifndef INFILE
  134. @echo YOU NEED TO PROVIDE AN 'INFILE' e.g. INFILE=foo make add-watermark-to-image!
  135. @exit 1
  136. endif
  137. ifndef OUTFILE
  138. @echo YOU NEED TO PROVIDE AN 'OUTFILE' e.g. OUTFILE=foo make add-watermark-to-image!
  139. @exit 1
  140. endif
  141. ifndef COLOR
  142. convert $(INFILE) -gravity NorthWest -pointsize 40 -fill '#fffdc3' -annotate +20+20 "Modding-OpenMW.com" $(OUTFILE)
  143. else
  144. convert $(INFILE) -gravity NorthWest -pointsize 40 -fill "$(COLOR)" -annotate +20+20 "Modding-OpenMW.com" $(OUTFILE)
  145. endif