more everything
This commit is contained in:
		
							parent
							
								
									e188f6b7b9
								
							
						
					
					
						commit
						67fd09496f
					
				
					 9 changed files with 94 additions and 55 deletions
				
			
		
							
								
								
									
										43
									
								
								Makefile
									
										
									
									
									
								
							
							
						
						
									
										43
									
								
								Makefile
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -39,17 +39,19 @@ prerequisites:
 | 
			
		|||
ifdef DEPLOY_CLEANUP
 | 
			
		||||
cleanup:
 | 
			
		||||
	@- echo "\n### cleanup ..."
 | 
			
		||||
	@- $(foreach host,$(DEPLOY_HOSTS), \
 | 
			
		||||
	@ $(foreach host,$(DEPLOY_HOSTS), \
 | 
			
		||||
		echo "#host: $(host)"; \
 | 
			
		||||
		scp cleanup.sh $(SSH_USER)@$(host):/$(DEPLOY_PATH)/$(DEPLOY_NAME); \
 | 
			
		||||
		ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh cleanup.sh $(host)"; \
 | 
			
		||||
		if [ -e cleanup.sh ]; then ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh cleanup.sh $(host)"; fi; \
 | 
			
		||||
	)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
prepare:
 | 
			
		||||
	@- echo "\n### preparing ..."
 | 
			
		||||
	@- chmod 600 secrets.mk
 | 
			
		||||
	@- $(foreach host,$(DEPLOY_HOSTS), \
 | 
			
		||||
		ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH); mkdir $(DEPLOY_NAME)"; \
 | 
			
		||||
	@ $(foreach host,$(DEPLOY_HOSTS), \
 | 
			
		||||
		echo "#host: $(host)"; \
 | 
			
		||||
		ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH); if [ ! -d $(DEPLOY_NAME) ] ; then mkdir $(DEPLOY_NAME); fi"; \
 | 
			
		||||
	)
 | 
			
		||||
	
 | 
			
		||||
build:
 | 
			
		||||
| 
						 | 
				
			
			@ -71,23 +73,28 @@ endif
 | 
			
		|||
pre-deploy:
 | 
			
		||||
ifdef DEPLOY_HOSTS
 | 
			
		||||
	@- echo "\n### running pre-deploy script(s)"
 | 
			
		||||
	@- $(foreach host,$(DEPLOY_HOSTS), \
 | 
			
		||||
		ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh pre-deploy.sh $(host); sh pre-deploy_$(host).sh"; \
 | 
			
		||||
	@ $(foreach host,$(DEPLOY_HOSTS), \
 | 
			
		||||
		echo "#host: $(host)"; \
 | 
			
		||||
		if [ -e pre-deploy.sh ]; then ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh pre-deploy.sh $(host)"; fi; \
 | 
			
		||||
		if [ -e pre-deploy_$(host).sh ]; then ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh pre-deploy_$(host).sh"; fi; \
 | 
			
		||||
	)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
post-deploy:
 | 
			
		||||
ifdef DEPLOY_HOSTS
 | 
			
		||||
	@- echo "\n### running post-deploy script(s)"
 | 
			
		||||
	@- $(foreach host,$(DEPLOY_HOSTS), \
 | 
			
		||||
		ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh post-deploy.sh $(host); sh post-deploy_$(host).sh"; \
 | 
			
		||||
	@ $(foreach host,$(DEPLOY_HOSTS), \
 | 
			
		||||
		echo "#host: $(host)"; \
 | 
			
		||||
		if [ -e post-deploy.sh ]; then ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh post-deploy.sh $(host)"; fi; \
 | 
			
		||||
		if [ -e post-deploy_$(host).sh ]; then ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh post-deploy_$(host).sh"; fi; \
 | 
			
		||||
	)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
pre-local:
 | 
			
		||||
ifneq (,$(wildcard pre-local.sh))
 | 
			
		||||
	@- echo "\n### running pre-local script"
 | 
			
		||||
	@- $(foreach host,$(DEPLOY_HOSTS), \
 | 
			
		||||
	@ $(foreach host,$(DEPLOY_HOSTS), \
 | 
			
		||||
		echo "#host: $(host)"; \
 | 
			
		||||
		./pre-local.sh $(host); \
 | 
			
		||||
	)
 | 
			
		||||
else
 | 
			
		||||
| 
						 | 
				
			
			@ -97,7 +104,8 @@ endif
 | 
			
		|||
post-local:
 | 
			
		||||
ifneq (,$(wildcard post-local.sh))
 | 
			
		||||
	@- echo "\n### running post-local script"
 | 
			
		||||
	@- $(foreach host,$(DEPLOY_HOSTS), \
 | 
			
		||||
	@ $(foreach host,$(DEPLOY_HOSTS), \
 | 
			
		||||
		echo "#host: $(host)"; \
 | 
			
		||||
		./post-local.sh $(host); \
 | 
			
		||||
	)
 | 
			
		||||
else
 | 
			
		||||
| 
						 | 
				
			
			@ -107,16 +115,17 @@ endif
 | 
			
		|||
upload:
 | 
			
		||||
ifdef DEPLOY_HOSTS
 | 
			
		||||
	@- echo "\n### uploading files"
 | 
			
		||||
	@- $(foreach host,$(DEPLOY_HOSTS), \
 | 
			
		||||
		ssh $(SSH_USER)@$(host) "mkdir -p $(DEPLOY_PATH)/$(DEPLOY_NAME)"; \
 | 
			
		||||
		rsync_xtra=`cat .rsync`; \
 | 
			
		||||
		rsync_xtra_host=`cat .rsync_$(host)`; \
 | 
			
		||||
	@$(foreach host,$(DEPLOY_HOSTS), \
 | 
			
		||||
		echo "#host: $(host)"; \
 | 
			
		||||
		ssh $(SSH_USER)@$(host) "if [ ! -d $(DEPLOY_PATH)/$(DEPLOY_NAME) ]; then mkdir -p $(DEPLOY_PATH)/$(DEPLOY_NAME); fi"; \
 | 
			
		||||
		if [ -r .rsync ] ; then rsync_xtra=`cat .rsync`; fi; \
 | 
			
		||||
		if [ -r .rsync_$(host) ] ; then rsync_xtra_host=`cat .rsync_$(host)`; fi; \
 | 
			
		||||
		param="-ravv"; \
 | 
			
		||||
		param="$$param $$rsync_xtra"; \
 | 
			
		||||
		param="$$param $$rsync_xtra_host"; \
 | 
			
		||||
		param="$$param --exclude '*~' --exclude '.git*' --exclude '*.swp' . $(SSH_USER)@$(host):$(DEPLOY_PATH)/$(DEPLOY_NAME)"; \
 | 
			
		||||
		eval rsync $$param; \
 | 
			
		||||
		ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME) && chmod o-r .env secrets*"; \
 | 
			
		||||
		ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); if [ -e .env ]; then chmod o-r .env ; fi; if [ -e secrets.mk ]; then chmod o-r secrets.mk; fi; if [ -e secrets.yaml ]; then chmod o-r secrets.yaml; fi"; \
 | 
			
		||||
	)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -143,9 +152,9 @@ restart: restart-$(DEPLOY_TYPE)
 | 
			
		|||
reload:
 | 
			
		||||
ifneq (,$(wildcard reload.sh))
 | 
			
		||||
	@- echo "\n### reloading ..."
 | 
			
		||||
	@- $(foreach host,$(DEPLOY_HOSTS), \
 | 
			
		||||
	@ $(foreach host,$(DEPLOY_HOSTS), \
 | 
			
		||||
		echo "### reloading service on $(host)"; \
 | 
			
		||||
		ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); ./reload.sh"; \
 | 
			
		||||
		if [ -e reload.sh ]; then ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); ./reload.sh"; fi; \
 | 
			
		||||
	)
 | 
			
		||||
else
 | 
			
		||||
	@- echo "\n### no reload script found"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue