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

186 lines
6.4 KiB

proj_dir := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
.DEFAULT_GOAL := server
PORT ?= 8666
host_check:
ifndef HOSTS
@echo "\n\033[31mPLEASE PROVIDE THE '\033[91mHOSTS\033[31m' VARIABLE!\nUSAGE: \033[91mmake TARGET HOSTS=some_hosts_or_host_group\033[0m\n"
@exit 1
endif
get-versions:
@echo PRODUCTION:
@http --print b https://modding-openmw.com/_stat/
@echo STAGING:
@http --print b https://staging.modding-openmw.com/_stat/
@echo BETA:
@http --print b https://beta.modding-openmw.com/_stat/
clean:
/bin/rm -fr *.sqlite3 src && for d in $$(find . -name __pycache__); do rm -rf $${d}; done
compose-up:
docker-compose up --build
docker-reset:
docker rm momw_psql_1
docker volume rm momw_psql-data
migrate:
$(proj_dir)/momw/manage.py migrate
makemigrations:
$(proj_dir)/momw/manage.py makemigrations
shell:
$(proj_dir)/momw/manage.py shell
smtpd:
python3 -m smtpd -n -c DebuggingServer localhost:1025
refreshdb:
sudo -u momwdb dropdb momwdb && sudo -u momwdb createdb momwdb
seeddb:
$(proj_dir)/bin/seed_db.py
reset: clean refreshdb migrate seeddb
server:
$(proj_dir)/momw/manage.py runserver 0.0.0.0:$(PORT)
pip-requirements:
python3 -m pip install --user -r requirements.txt
start-xvfb-ci:
$(proj_dir)/bin/start_xvfb.sh
test-black:
ifneq (, $(shell which black 2>/dev/null))
black --check $(proj_dir)
else
@echo black executable not found!
endif
test-flake8:
find $(proj_dir) -type f -name "*.py" | xargs flake8 --verbose
test-dropdb:
sudo -u momwdb dropdb test_momwdb || echo test db is gone
test-chroniko:
$(proj_dir)/momw/manage.py test chroniko.tests
test-media:
$(proj_dir)/momw/manage.py test media.tests
test-momw:
$(proj_dir)/momw/manage.py test momw.tests
test-utilz:
$(proj_dir)/momw/manage.py test utilz.tests
test-djangotests: test-chroniko test-momw test-utilz
ifndef SKIPTESTS
test: test-black test-flake8 test-dropdb test-djangotests
else
test:
@echo Skipped tests due to the presence of the SKIPTESTS env var!
endif
django: host_check test
cd ../playbooks && \
ansible-playbook site.yml --extra-vars "control_hosts=$(HOSTS) \
control_msg='Momw Django App Setup' \
control_user=root \
django_db_migrate=true \
django_db_seed=true \
django_start=true \
django_sync_code=true \
django_drop_db=true" \
--tags user,nginx,postgresql,memcached,django \
--vault-password-file ${CURDIR}/auth
django-migrate: host_check test
cd ../playbooks && \
ansible-playbook site.yml --extra-vars "control_hosts=$(HOSTS) \
control_msg='Run Momw Django db migrations' \
control_user=$(CONTROL_USER) \
db_migrate=true" \
--tags ircspam,migration
django-seeddb: host_check test
cd ../playbooks && \
ansible-playbook site.yml --extra-vars "control_hosts=$(HOSTS) \
control_msg='Momw Django database seed' \
control_user=root \
django_db_migrate=true \
django_db_seed=true" \
--tags ircspam,django_seeddb
django-resetdb: host_check test ## Reset the remote database with new data
cd ../playbooks && \
ansible-playbook site.yml --extra-vars "control_hosts=$(HOSTS) \
control_msg='Momw Django database reset' \
control_user=root \
django_db_migrate=true \
django_db_seed=true \
django_drop_db=true" \
--tags ircspam,django_seeddb,django_resetdb \
--vault-password-file ${CURDIR}/auth
django-warmcache: host_check
cd ../playbooks && \
ansible-playbook site.yml --extra-vars "control_hosts=$(HOSTS) \
control_msg='Momw Django cache warm' \
control_user=root \
django_warmcache=true" \
--tags ircspam,warmcache
sync: host_check test
cd ../playbooks && \
ansible-playbook site.yml --extra-vars "control_hosts=$(HOSTS) \
control_msg='Momw Code Sync & Restart' \
control_user=root \
django_git=true \
django_sync_code=true" \
--tags ircspam,django_sync
memcached-restart: host_check
cd ../playbooks && \
ansible-playbook site.yml --extra-vars "control_hosts=$(HOSTS) \
control_msg='memcached service restart' \
control_user=root \
memcached_restart=true" \
--tags ircspam,memcached
# ffmpeg -i input.flv -codec copy output.mp4
# ffmpeg -i input.mp4 -ss 00:00:02 -to 00:15:40 -c copy output.mp4
add-watermark-to-video:
ifndef INFILE
@echo YOU NEED TO PROVIDE AN 'INFILE' e.g. INFILE=foo make add-watermark-to-video!
@exit 1
endif
ifndef OUTFILE
@echo YOU NEED TO PROVIDE AN 'OUTFILE' e.g. OUTFILE=foo make add-watermark-to-video!
@exit 1
endif
ffmpeg -i $(INFILE) -i $(proj_dir)/momw/static/onesixth-watermark.png -filter_complex "overlay=20:20" -max_muxing_queue_size 1024 $(OUTFILE)
add-watermark-to-image:
ifndef INFILE
@echo YOU NEED TO PROVIDE AN 'INFILE' e.g. INFILE=foo make add-watermark-to-image!
@exit 1
endif
ifndef OUTFILE
@echo YOU NEED TO PROVIDE AN 'OUTFILE' e.g. OUTFILE=foo make add-watermark-to-image!
@exit 1
endif
ifndef COLOR
convert $(INFILE) -gravity NorthWest -pointsize 40 -fill '#fffdc3' -annotate +20+20 "Modding-OpenMW.com" $(OUTFILE)
else
convert $(INFILE) -gravity NorthWest -pointsize 40 -fill "$(COLOR)" -annotate +20+20 "Modding-OpenMW.com" $(OUTFILE)
endif