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 2db5094
Show file tree
Hide file tree
Showing 3 changed files with 35 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%
-----------------------------
22 changes: 22 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,13 @@ local banner_path = "/etc/banner"
local banner_backup_path = "/etc/banner.original"
local banner_template_path = "/etc/banner.gluon"


-- check if the customer banner is 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 +76,20 @@ 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 not site.custom_banner.map_url()
and false -- TODO: remove
then
-- if there is not map link in the site, strip MAP_LINK and whitespaces around it
new_banner = string.gsub(new_banner, "\s*%%MAP_LINK%%\s*\n?", "")
else
local map_url = site.custom_banner.map_url() or "https://map.ffmuc.net/#!/"
-- 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%%", map_url .. map_mac)
end

print(new_banner)

-- 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 2db5094

Please sign in to comment.