Skip to content

Commit

Permalink
WIP: add map link to banner
Browse files Browse the repository at this point in the history
  • Loading branch information
grische committed Jun 9, 2024
1 parent 8578f5d commit 4147333
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ffmuc-custom-banner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,15 @@
This package modifies the /etc/banner that is shown during SSH login.

⚠️ This package will consume an additional 2x the banner size, one for the template and one for the final banner. Make sure to have enough flash size available.


### Configuration

You should use something like the following in the site.conf:

```lua
custom_banner = {
enabled = true,
map_url = 'https://map.ffmuc.net/#!/',
},
```
1 change: 1 addition & 0 deletions ffmuc-custom-banner/files/etc/banner.gluon
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
-----------------------------
%SITE_NAME% %FIRMWARE_VERSION%
%MODEL%
%MAP_LINK%
-----------------------------
15 changes: 15 additions & 0 deletions ffmuc-custom-banner/luasrc/lib/gluon/upgrade/520-custom-banner
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ local banner_path = "/etc/banner"
local banner_backup_path = "/etc/banner.original"
local banner_template_path = "/etc/banner.gluon"


-- don't update the banner if customer banner is explicitly disabled
if site.custom_banner() and site.custom_banner.enabled() == false then
os.exit()
end

local function file_exists(path)
local file = io.open(path, "r")

Expand Down Expand Up @@ -69,5 +75,14 @@ new_banner = string.gsub(new_banner, "%%FIRMWARE_VERSION%%", gluon_info.firmware
new_banner = string.gsub(new_banner, "%%GLUON_VERSION%%", gluon_info.gluon_version)
new_banner = string.gsub(new_banner, "%%MODEL%%", model)

if site.custom_banner.map_url() then
-- TODO: confirm that this is "the way" to get the map link!
local map_mac = string.gsub(uci:get("network", "client","macaddr"), ":", "")
new_banner = string.gsub(new_banner, "%%MAP_LINK%%", site.custom_banner.map_url() .. map_mac)
else
-- if there is not map link in the site, strip MAP_LINK, whitespaces around it and a single final newline
new_banner = string.gsub(new_banner, "[ ]*%%MAP_LINK%%[ ]*\n?", "")
end

-- TODO: write this file to RAM (and regen on reboot) and link symlink it, to save space
write_file(banner_path, new_banner)

0 comments on commit 4147333

Please sign in to comment.