cron.mk: use sudo -u for crontab -e

This commit is contained in:
Andreas Neue 2023-06-05 11:40:16 +02:00
parent 4a05d9f562
commit e217695036
2 changed files with 3 additions and 3 deletions

View File

@ -93,7 +93,7 @@ ifdef DEPLOY_HOSTS
@- $(foreach host,$(DEPLOY_HOSTS), \
ssh $(SSH_USER)@$(host) "mkdir -p $(DEPLOY_PATH)/$(DEPLOY_NAME)"; \
rsync -rav --exclude '*~' --exclude '.git*' --exclude '*.swp' . $(SSH_USER)@$(host):$(DEPLOY_PATH)/$(DEPLOY_NAME); \
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME) && chmod o-r .env secrets*" \
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME) && chmod o-r .env secrets*"; \
)
endif

View File

@ -4,7 +4,7 @@ start-cron:
@- echo "\n### starting..."
@- $(foreach host,$(DEPLOY_HOSTS), \
echo "$(host)"; \
ssh $(SSH_USER)@$(host) "crontab -l | sed \"/^#make-deploy-cron:$(DEPLOY_NAME)/,+1 d\" | { cat; echo \"#make-deploy-cron:$(DEPLOY_NAME)\"; cat \"$(DEPLOY_PATH)/$(DEPLOY_NAME)/crontab\"; } | crontab -"; \
ssh $(SSH_USER)@$(host) "sudo -u $(CRON_USER) sh -c 'crontab -l | sed \"/^#make-deploy-cron:$(DEPLOY_NAME)/,+1 d\" | { cat; echo \"#make-deploy-cron:$(DEPLOY_NAME)\"; cat \"$(DEPLOY_PATH)/$(DEPLOY_NAME)/crontab\"; } | crontab -"'; \
sleep $(DEPLOY_START_DELAY); \
)
@ -12,7 +12,7 @@ stop-cron:
@- echo "\n### stopping ..."
@- $(foreach host,$(DEPLOY_HOSTS), \
echo "$(host)"; \
ssh $(SSH_USER)@$(host) "crontab -l | sed \"/^#ck-deploy-cron:$(DEPLOY_NAME)/,+1 d\" | crontab -"; \
ssh $(SSH_USER)@$(host) "sudo -u $(CRON_USER) sh -c 'crontab -l | sed \"/^#make-deploy-cron:$(DEPLOY_NAME)/,+1 d\" | crontab -"'; \
)
pull-cron: