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.
 
 
 
 
 

187 lines
6.4 KiB

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