diff --git a/ffmuc-custom-banner/README.md b/ffmuc-custom-banner/README.md index f2f9ae6a..84dc2ddf 100644 --- a/ffmuc-custom-banner/README.md +++ b/ffmuc-custom-banner/README.md @@ -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/#!/', + }, +``` diff --git a/ffmuc-custom-banner/files/etc/banner.gluon b/ffmuc-custom-banner/files/etc/banner.gluon index 952fc32d..acd2015c 100644 --- a/ffmuc-custom-banner/files/etc/banner.gluon +++ b/ffmuc-custom-banner/files/etc/banner.gluon @@ -6,4 +6,5 @@ ----------------------------- %SITE_NAME% %FIRMWARE_VERSION% %MODEL% + %MAP_LINK% ----------------------------- diff --git a/ffmuc-custom-banner/luasrc/lib/gluon/upgrade/520-custom-banner b/ffmuc-custom-banner/luasrc/lib/gluon/upgrade/520-custom-banner index ff4ca667..6caf62ce 100755 --- a/ffmuc-custom-banner/luasrc/lib/gluon/upgrade/520-custom-banner +++ b/ffmuc-custom-banner/luasrc/lib/gluon/upgrade/520-custom-banner @@ -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") @@ -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)