Dietpi banner upgrades - #8172
Conversation
|
Outstanding items I know of:
|
MichaIng
left a comment
There was a problem hiding this comment.
A great extension! But there is some cleanup/polishing needed to reduce the overhead (in code an UI), and make it work for expected use cases.
3dde41b to
78d815c
Compare
68a40de to
2cdb0c2
Compare
|
Just as an overview, the things I'd still want to do before merging. But will do so before DietPi v10.6 release (which will be delayed anyway because of a spontaneous holiday trip consuming some time this week):
|
|
I went through the open points you mentioned at the top. Regarding clearing the terminal in VS Code: See |
…d a safer delimiter
…ttern submenu. added migration of disk_rootfs and disk_userdata (removed them from the menu).
…hed aCUSTOM_COMMANDS to use associative indices to take advantage of Print_Item_State for display consistency; still TODO: update the submenu for associative indexing
…upgraded custom commands submenu to match the style of disk_usage patterns submenu; added custom command migration (needs testing)
…the banner is displayed
…s handled in Print_Banner, and `dietpi-banner 0` should not care
… surrounded by whitespace sometimes
* "systemd" is explicitly written with a lower-case "s". It would be "okay" to use an upper-case "s" at the beginning of a sentence, but we keep strict lower-case everywhere else in DietPi texts as well. To quote the makers: "The only situation where we find it OK to use an uppercase letter in the name (but don't like it either) is if you start a sentence with systemd."
* Use single-quotes for string, where no variable expension is intended, except in (the left-side of) bash conditionals "[[ ]]", where quotation has no effect.
* newline after loop condition before "do", same like after if condition before "then"
* Skip double-quotes when assigning a single variable or command substitution, as it is not needed in this case. Skip as well for "case" input pattern, where it is not needed either.
* Replace some on-line if-then(-else) with && (||)
* Skip "-n" and "-z" in bash conditionals, only use "!" to check for empty expressions. Also avoid redundant "${var:-}" to replace an empty variable with an empty string, redundant in modern shells.
* Avoid muting STDERR where it is not expected (findmnt call), especially for testing/beta phase
* Use "$" for variable calls in bash arithmetics as well. It is not needed, but makes it easier to distinguish between variable calls and assignments when reviewing a script, especially if editors do syntax highlighting, or when searching for those via grep.
* Use %s for printf placeholders instead of %b, if no ANSI code expansion or similar is expected.
* Use -v flag explicitly when "unset"ing variables. Very rare chance that the same name is used for a function, especially in a called (instead of sourced) script, but I started with this convention at some point.
* Always print closing CLI_LINE, as it was done before. The multi-line blocks with subheader print a leading CLI_LINE but no trailing one. * Restore empty line before credits, update notifications, dietpi-* commands, but remove additional newline after banner (the migration messages will be removed, all done during dietpi-update). If a color reset is missing somewhere, we should fix it in the respective Print_* command, but so far I couldn't find any, especially after Print_Custom_Commands uses Print_Item_State as well.
…" is used The dark gray really is dark. For info which was explicitly selected by users, use the default white/bright grey, like all of the upper entry values do. This is already different from the "highlight" and "alert" colors used for all other output states where "weak" was used, so this does not cause overlaps. Keep "weak" color for the credits only as before. If we want to use it more widely in the banner, IMO never for keys or values, only for separation/ordering symbols or such things.
The ASCII V and W contain literal upper-case V characters.
* IPv6 are not trivial to match selectively, due to the possible shortenings of 0000 hextets, even on both ends. * For Fail2Ban stats, it makes sense to match those widely, to not miss if e.g. the localhost itself got banned. The output syntax is luckily specific enough for this to still reliably only match the banned IPs. * "ip -br a" has simple output format as well, with the 1st IP being the 3rd argument. There is no need to filter this, it is either an IP or empty. * For matching public IPs, the regex for IPv6 can be narrowed down much, since only the 2000::/3 block is globally routable. * Merge Get_WAN_IP and printing the IP address line into Print_Data_Usage, to deduplicate the ns_cmd_prefix crafting. Sadly, the whole function cannot simply be called with the namespace prefix, since we'd need to add all used functions and variables into the subshell, too. It would require some reorder for this to be reasonable, e.g. to obtain only the raw values with a simple dash-compatible function, and craft the colored output lines afterwards in the parent function. But this can be done in a future PR. * Make some variables local, and omit or rename some others
|
Ah dammit, I never think about that rebasing always causes a pain when aiming to sync it back to a(nother) local client 🙈. Sorry. |
W was accidentally excluded
Make MENU_ITEMS array readonly, along with some other variables that are not intended to be change. Remove "unknown menu selection" error and "every other valid one" match instead. There is not really a way whiptail can return a value other than what MENU_ITEMS contains, and it makes maintainance/adding new items easier. If we'd really want to make a failsafe check for debugging purpose, we should instead check whether the returned value is in the MENU_ITEMS array.
It overrides "--real" and shows tmpfs and udev mountpoints that way, which are not commonly interesting for disk space info.
|
Okay, only left point from my end is to move the migration into |
Enhancing dietpi-banner.