fix: guard core make targets and defer service restarts to postrun#7
Draft
troglodyne wants to merge 1 commit into
Draft
fix: guard core make targets and defer service restarts to postrun#7troglodyne wants to merge 1 commit into
troglodyne wants to merge 1 commit into
Conversation
makefile.tt: - service_user: guard useradd with existence check (id user || useradd) so re-running against an existing system does not fail on duplicate user - ssl: guard both ln -s with [ -L target ] || to survive re-deploy when symlinks already exist nginxproxy.tt: - remove duplicate redundant systemctl restart (was firing twice in one target) - defer the single restart to queue_postrun_task so nginx reloads after all config is in place, not mid-make fail2ban.tt: - defer systemctl reload to queue_postrun_task (same ordering rationale) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Apr 25, 2026
troglodyne
commented
Apr 26, 2026
| # Setup the link to LE certs | ||
| ln -s /etc/letsencrypt/live/[% domain %]/fullchain.pem /etc/ssl/certs/[% domain %].pem | ||
| ln -s /etc/letsencrypt/live/[% domain %]/privkey.pem /etc/ssl/private/[% domain %].pem | ||
| [ -L /etc/ssl/certs/[% domain %].pem ] || ln -s /etc/letsencrypt/live/[% domain %]/fullchain.pem /etc/ssl/certs/[% domain %].pem |
Contributor
Author
There was a problem hiding this comment.
probably better to just blow away the file preemptively
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Guard unprotected
useraddandln -soperations inmakefile.ttcore targets; eliminate nginx double-restart and defer both nginx and fail2ban service reloads toqueue_postrun_task.Why
Issue #1 calls for safe shared-environment deploys. PRs #5 and #6 cover individual recipes; this covers the core makefile template which runs for every domain:
service_user:useraddfails with exit 9 if the service user already exists on an existing system — now guarded withid user &>/dev/null ||ssl: bothln -ssymlinks for the self-signed cert fail if already present — guarded with[ -L target ] ||Additionally,
nginxproxy.ttwas restarting nginx twice in sequence (once per config file installed) and both restarts fired inline mid-make. Collapsed to one deferred restart viaqueue_postrun_task, so nginx reloads only after all config is in place.fail2ban.tthad the same inline-reload problem.How
makefile.ttservice_usertarget:id [% user %] &>/dev/null || useradd ...makefile.ttssltarget:[ -L /etc/ssl/certs/... ] || ln -s ...(both symlinks)nginxproxy.tt: removed first inlinesystemctl restart nginx, replaced second with[% script_dir %]/queue_postrun_task systemctl restart nginxfail2ban.tt:systemctl reload fail2ban→queue_postrun_task systemctl reload fail2banAll guards follow the same pattern established in PRs #5 and #6.
Testing
No automated test suite. Changes verified by diff — patterns match the established guards in mail.tt, letsencrypt.tt, mariadb.tt, and tpsgi.tt from the merged and pending PRs.