Controlling Nginx startup: four changes with a transaction journal
How the CLI disables Nginx package SysV links without overwriting foreign files, retains the systemd mask and verifies the result after a reboot.
An installed Nginx package may already contain a default configuration and startup links. A separate step is therefore needed between installation and the first controlled start. We tested this transition in the Go CLI on a Debian 13 VM while retaining the service startup block.
Nginx on the manually configured E‑01 already serves the learning project's static roots. The automation VM deliberately stopped earlier: packages are installed, but Nginx is not running. This lets us examine startup changes separately from HTTP behavior and worker processes.
Stopping, disabling and masking are different actions
stop stops the current service. disable removes enablement links but does not itself prohibit another start. mask blocks starting the unit through systemd. The distinction is documented in the systemctl manual.
In our installation sequence, an owned mask and policy-rc.d for Nginx already remain in place. The new step does not remove them. It operates on the package's SysV links and checks that the startup guards remain intact.
Four specific renames
In the verified package state, startup links were named S01nginx in runlevels 2–5. The plan specified the following changes. This is a shortened presentation of actual VM steps, not shell commands for an arbitrary server:
/etc/rc2.d/S01nginx → /etc/rc2.d/K99nginx
/etc/rc3.d/S01nginx → /etc/rc3.d/K99nginx
/etc/rc4.d/S01nginx → /etc/rc4.d/K99nginx
/etc/rc5.d/S01nginx → /etc/rc5.d/K99nginx
Each rename is individually atomic and cannot replace an existing destination. The implementation uses Linux renameat2 with RENAME_NOREPLACE. The four actions together are not one atomic operation: a failure can occur between steps, which is why a journal is needed before they begin.
Apply first checks the original installation and guard plans, packages and source links. If a foreign object already occupies a future K99nginx destination, the CLI refuses. It neither deletes it, follows the link nor claims ownership.
Applying an approved plan
This adapted example requires an existing startup-disable-plan, a private access file, the original guard/package plans and their actual SHA values. Replace the angle-bracket values before execution. Apply uses sudo to change system links and its own journal; the independent recovery console must remain available.
deploy-cli host nginx startup-disable-apply --profile demo \
--request-file /private/administrator.json \
--guard-plan-file /private/guard-plan.json \
--guard-plan-sha256 <GUARD_PLAN_SHA256> \
--package-plan-file /private/packages-plan.json \
--package-plan-sha256 <PACKAGE_PLAN_SHA256> \
--plan-file /private/startup-disable.json \
--plan-sha256 <DISABLE_PLAN_SHA256> \
--approve-privileges
The shortened actual response from the first application in the VM contained these fields. Hashes and other fields are omitted:
{
"status": "passed",
"write_performed": true,
"write_state": "changed",
"action": "startup-disable-apply",
"access_verified": true
}
After writing, the CLI opened a separate SSH session and verified the same completed result. The original startup guards, administrator access and firewall settings remained in place.
A repeated call does not repeat the write
For an already completed operation, the CLI reads its journal, current links and startup guards. An exact match returns a result without another rename. These are the corresponding fields from the repeated call in the VM:
{
"status": "passed",
"write_performed": false,
"write_state": "none",
"action": "already-completed",
"access_verified": true
}
If state has changed, a completed-operation record grants no permission to repair it silently. A foreign startup link caused a refusal in the experiment. The fixture removed that link after checking its own object; the CLI did not.
Verification after a reboot
The separate read command uses the same original request and exact plan, without write approval:
deploy-cli host nginx startup-disable-verify --profile demo \
--request-file /private/administrator.json \
--guard-plan-file /private/guard-plan.json \
--guard-plan-sha256 <GUARD_PLAN_SHA256> \
--package-plan-file /private/packages-plan.json \
--package-plan-sha256 <PACKAGE_PLAN_SHA256> \
--plan-file /private/startup-disable.json \
--plan-sha256 <DISABLE_PLAN_SHA256>
After a normal reboot, verify accepted the retained result and the new actual state. Nginx remained inactive, MainPID was 0 and UnitFileState was masked. No startup S-links remained; together with the preserved stop links, the result was seven K-links.
A repeated apply using the old console evidence after reboot was rejected. Reading completed state and authorizing a new change have different access freshness requirements. A new change requires the relevant preparation again.
An unfinished journal is not automatically cleared, and there is no automatic rollback. If the connection is lost, first use retained access to compare the journal and links. Completing this step establishes controlled disabled startup; starting Nginx requires a separately prepared configuration and a transition of the startup guards.

