Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delegate to unified strip-marker-sections script (#1722)
Resolves #1710. Stacked on #1720. Based on the [simplifications in `unset-static-ip`](#1719), this PR removes the code redundancies in the `unset-static-ip` and `change-hostname` privileged scripts, and calls the new, unified `strip-marker-sections` script instead. ## Notes - `change-hostname`: - Naively speaking, it would seem simpler to *append* the new entry to the file. I remembered, however, that the prepending was done on purpose, because in `/etc/hosts` the first matching entry takes precedence. I captured that as a comment therefore. - I slightly reordered the code so that all `/etc/hosts`-related logic is close together now (i.e., clearing the markers, then rewriting the file). - `unset-static-ip` - ~I couldn’t figure out why we have been using `tee` previously to write to the config file, because we discarded `tee`’s stdout output by redirecting to `/dev/null`. I’m also not sure why we used `sudo` for invoking `tee` – [we already execute the script with `root` privileges](https://github.com/tiny-pilot/tinypilot-pro/blob/cfb99f88a3039d587a9108d427e7ecfa81b7d190/app/static_ip.py#L128). It’s a bit odd, because I cannot imagine we did that without good reason~ 🤔 (We [had been using `sudo tee` to avoid permission issues](#1722 (comment)) when writing the file.) <a data-ca-tag href="https://codeapprove.com/pr/tiny-pilot/tinypilot/1722"><img src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review on CodeApprove" /></a> --------- Co-authored-by: Jan Heuermann <[email protected]>
- Loading branch information