aboutsummaryrefslogblamecommitdiffstats
path: root/Makefile
blob: a4b2b970c6096a006c0ca8ab1984cbc9698da73e (plain) (tree)





























                                                                                                                                                                                   
.PHONY: deploy

include deployment-config.mk

SSH_OPTS := -q -o ControlMaster=auto -o ControlPath=.ssh-deployment.sock

deploy:
	@echo "    SSH     $(WEB_SERVER)"
	@ssh $(SSH_OPTS) -Nf $(WEB_SERVER)
	
	@echo "    RSYNC   . $(WEB_SERVER):$(FLASK_PATH)"
	@ssh -t $(SSH_OPTS) $(WEB_SERVER) "sudo -u $(FLASK_USER) -v"
	@rsync -aizm --delete-excluded --exclude=.ssh-deployment.sock --exclude=.git --exclude=Makefile --exclude="*.pyc" --exclude="*.mk" --exclude=.gitignore --exclude="*.swp" \
		--filter="P pastes/" --rsh="ssh $(SSH_OPTS)" --rsync-path="sudo -n -u $(FLASK_USER) rsync" \
		. "$(WEB_SERVER):$(FLASK_PATH)" 
	
	@echo "    CHMOD   750/640 $(WEB_SERVER):$(FLASK_PATH)/*"
	@ssh -t $(SSH_OPTS) $(WEB_SERVER) "sudo find -P '$(FLASK_PATH)' \! -path '$(FLASK_PATH)/pastes/*' -type f -exec chmod 640 {} \;; \
					   sudo find -P '$(FLASK_PATH)' \! -path '$(FLASK_PATH)/pastes/*' -type d -exec chmod 750 {} \;;"
	
	@echo "    CHOWN   $(FLASK_USER):$(NGINX_USER) $(WEB_SERVER):$(FLASK_PATH)/pastes"
	@ssh -t $(SSH_OPTS) $(WEB_SERVER) "sudo mkdir -p '$(FLASK_PATH)/pastes'; sudo chown $(FLASK_USER):$(NGINX_USER) '$(FLASK_PATH)' '$(FLASK_PATH)/pastes'"
	@echo "    CHMOD   710 $(WEB_SERVER):$(FLASK_PATH)"
	@ssh -t $(SSH_OPTS) $(WEB_SERVER) "sudo chmod 710 '$(FLASK_PATH)'"
	
	@echo "    UWSGI   restart $(WEB_SERVER)"
	@ssh -t $(SSH_OPTS) $(WEB_SERVER) "sudo /etc/init.d/uwsgi restart"
	
	@echo "    SSH     $(WEB_SERVER)"
	@ssh -O exit $(SSH_OPTS) $(WEB_SERVER)