iron out motd issues #14

Merged
kleb merged 2 commits from fix/motd.sh into main 2025-12-12 10:52:27 +01:00
Owner
No description provided.
Collaborator

PR Code Suggestions

No code suggestions found for the PR.

## PR Code Suggestions ✨ No code suggestions found for the PR.
Author
Owner

/improve

/improve
Collaborator

PR Code Suggestions

No code suggestions found for the PR.

## PR Code Suggestions ✨ No code suggestions found for the PR.
Author
Owner

/ask Check motd.sh, do you see any issues?

/ask Check motd.sh, do you see any issues?
Collaborator

Ask

Check motd.sh, do you see any issues?

Answer:

Short answer:
No, the change you made to motd.sh is safe and improves robustness. The only real modification is adding double‑quotes around the variable expansions that split the service status lines. That prevents word‑splitting and globbing on the label and status values, which is exactly what you want.

Below are a few points to keep in mind when reviewing the rest of the script (the diff you posted only shows the quoting change, but it’s worth double‑checking the surrounding logic):

Area What to look for Why it matters
Variable quoting All variables that can contain spaces or glob characters should be quoted. Prevents accidental word‑splitting or pathname expansion.
printf format string "$format_label_value" should contain exactly two %s (or equivalent) placeholders. If the format string changes, the arguments you pass ($label: and $status) may not line up, leading to garbled output.
Colon handling You’re appending a colon to the label ("$label:"). This is fine because the format string already expects a label and a value. Just make sure you’re consistent (you already do that for the hard‑coded labels).
Empty or malformed entries If an entry in serviceStatusLines does not contain a colon, status will be empty. That’s usually acceptable, but if you want to guard against it you could add a check: [[ $entry == *:* ]] && ….
Special characters in status If a status string contains % characters, printf will treat them as format specifiers. In practice, service status messages rarely contain %, but if you ever do, you’ll need to escape them or use printf '%s\n' "$status".
Checksum update The SHA‑256 checksum for motd.sh (and update.sh) has changed. Make sure the new file is exactly what you intend to ship. If you’re running automated checksum verification, the updated values will now match.

Quick sanity check

# Run the script in a test environment
./installer/system/files/motd.sh

# Verify that the output looks correct
# e.g. “Zabbix agent: running” or “Zabbix agent 2: not installed”

If the output is as expected, the change is fine. If you see any unexpected word‑splitting or globbing, double‑check that all variables are quoted in the same way.


Bottom line: The quoted change is a good practice and should not introduce any regressions. No other issues are apparent from the diff snippet you provided. If you run the script in a staging environment and the MOTD renders correctly, you’re good to go.

### **Ask**❓ Check motd.sh, do you see any issues? ### **Answer:** **Short answer:** No, the change you made to `motd.sh` is safe and improves robustness. The only real modification is adding double‑quotes around the variable expansions that split the service status lines. That prevents word‑splitting and globbing on the `label` and `status` values, which is exactly what you want. Below are a few points to keep in mind when reviewing the rest of the script (the diff you posted only shows the quoting change, but it’s worth double‑checking the surrounding logic): | Area | What to look for | Why it matters | |------|------------------|----------------| | **Variable quoting** | All variables that can contain spaces or glob characters should be quoted. | Prevents accidental word‑splitting or pathname expansion. | | **`printf` format string** | `"$format_label_value"` should contain exactly two `%s` (or equivalent) placeholders. | If the format string changes, the arguments you pass (`$label:` and `$status`) may not line up, leading to garbled output. | | **Colon handling** | You’re appending a colon to the label (`"$label:"`). | This is fine because the format string already expects a label and a value. Just make sure you’re consistent (you already do that for the hard‑coded labels). | | **Empty or malformed entries** | If an entry in `serviceStatusLines` does not contain a colon, `status` will be empty. | That’s usually acceptable, but if you want to guard against it you could add a check: `[[ $entry == *:* ]] && …`. | | **Special characters in status** | If a status string contains `%` characters, `printf` will treat them as format specifiers. | In practice, service status messages rarely contain `%`, but if you ever do, you’ll need to escape them or use `printf '%s\n' "$status"`. | | **Checksum update** | The SHA‑256 checksum for `motd.sh` (and `update.sh`) has changed. | Make sure the new file is exactly what you intend to ship. If you’re running automated checksum verification, the updated values will now match. | ### Quick sanity check ```bash # Run the script in a test environment ./installer/system/files/motd.sh # Verify that the output looks correct # e.g. “Zabbix agent: running” or “Zabbix agent 2: not installed” ``` If the output is as expected, the change is fine. If you see any unexpected word‑splitting or globbing, double‑check that all variables are quoted in the same way. --- **Bottom line:** The quoted change is a good practice and should not introduce any regressions. No other issues are apparent from the diff snippet you provided. If you run the script in a staging environment and the MOTD renders correctly, you’re good to go.
kleb changed title from WIP: iron out motd issues to iron out motd issues 2025-12-12 10:52:21 +01:00
kleb merged commit 8961f2b362 into main 2025-12-12 10:52:27 +01:00
kleb deleted branch fix/motd.sh 2025-12-12 10:52:27 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kleb/kInit!14
No description provided.