diff --git a/banner/Makefile b/banner/Makefile index b1f26a45f2069ded5cf4b1f5a5efdd88ead1b3c3..f0fc10159b4f04803fb7cd0f9e30c4b3080dd6a2 100644 --- a/banner/Makefile +++ b/banner/Makefile @@ -9,9 +9,10 @@ PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) include $(GLUONDIR)/include/package.mk define Package/ffnw-banner - SECTION:=config + SECTION:= networke CATEGORY:=Freifunk Nordwest TITLE:=Nordwest freifunk shell banner + DEPENDS:= ffnw-hoodselector endef define Package/ffnw-banner/description diff --git a/banner/files/lib/ffnw/banner/banner b/banner/files/lib/ffnw/banner/banner index f0c66ff002b85e28e6bf95b315ae7ee56aaa6daa..f9da7d66f1e5a7b86f8f4a207bc97d75bd7aae95 100644 --- a/banner/files/lib/ffnw/banner/banner +++ b/banner/files/lib/ffnw/banner/banner @@ -16,4 +16,5 @@ ------------------------------------------------------ %A %B +%C ------------------------------------------------------ diff --git a/banner/files/lib/gluon/upgrade/550-ffnw-banner b/banner/files/lib/gluon/upgrade/550-ffnw-banner new file mode 100755 index 0000000000000000000000000000000000000000..3f398068ccab2ed3691ec7bd24df3320bfc8a304 --- /dev/null +++ b/banner/files/lib/gluon/upgrade/550-ffnw-banner @@ -0,0 +1,7 @@ +#!/bin/sh + +rm /etc/banner +touch /tmp/ffnw-banner +ln -s /tmp/ffnw-banner /etc/banner + +lua /usr/sbin/ffnw-banner \ No newline at end of file diff --git a/banner/files/usr/lib/micron.d/ffnw-banner b/banner/files/usr/lib/micron.d/ffnw-banner new file mode 100644 index 0000000000000000000000000000000000000000..32bf664eb74f4382d1a2c447f963865c1aa0dfc9 --- /dev/null +++ b/banner/files/usr/lib/micron.d/ffnw-banner @@ -0,0 +1 @@ +*/5 * * * * lua /usr/sbin/ffnw-banner diff --git a/banner/luasrc/lib/gluon/upgrade/550-ffnw-banner b/banner/luasrc/lib/gluon/upgrade/550-ffnw-banner deleted file mode 100755 index 993df8feecdd39038fee9dcfe017bc213da4bb0b..0000000000000000000000000000000000000000 --- a/banner/luasrc/lib/gluon/upgrade/550-ffnw-banner +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/lua - - - -local srcFile = "/lib/ffnw/banner/banner" -local srcBanner = io.open(srcFile, "r") - -if srcBanner~=nil then - local delDir = "/lib/ffnw/banner/" - local desFile = "/etc/banner" - local openwrtRelease = io.open("/etc/openwrt_release", "r") - local gluonVersion = io.open("/lib/gluon/gluon-version", "r") - local gluonRelease = io.open("/lib/gluon/release", "r") - local infoHeader = {} - infoHeader["openwrtRelease"] = "" - infoHeader["revision"] = "" - infoHeader["gluonVersion"] = "" - infoHeader["gluonRelease"] = "" - - if openwrtRelease~=nil then - for line in openwrtRelease:lines() do - -- Get openwrtRelease - if line:match("DISTRIB_DESCRIPTION") then - for v in string.gmatch(line, "([^=]+)") do - if not v:match("DISTRIB_DESCRIPTION") then - infoHeader["openwrtRelease"] = string.gsub(v,"'","") - end - end - end - -- Get openwrt revision - if line:match("DISTRIB_REVISION") then - for v in string.gmatch(line, "([^=]+)") do - if not v:match("DISTRIB_REVISION") then - infoHeader["revision"] = string.gsub(v,"'","") - end - end - end - end - end - - if gluonVersion~=nil then - for line in gluonVersion:lines() do - if line ~= nil then - infoHeader["gluonVersion"] = line - end - end - end - - if gluonRelease~=nil then - for line in gluonRelease:lines() do - if line ~= nil then - infoHeader["gluonRelease"] = line - end - end - end - - local firstLine ="OpenWRT Version: " .. infoHeader["openwrtRelease"].. " (" .. infoHeader["revision"] .. ")" - local secondLine ="Gluon Version: " .. infoHeader["gluonVersion"] .. " Gluon Release: " .. infoHeader["gluonRelease"] - os.execute('sed -i \'/%A/c\\' .. firstLine .. '\' ' .. srcFile) - os.execute('sed -i \'/%B/c\\' .. secondLine .. '\' ' .. srcFile) - os.execute('cp '..srcFile..' '..desFile) - os.execute('rm -rf '..delDir) -end diff --git a/banner/luasrc/usr/sbin/ffnw-banner b/banner/luasrc/usr/sbin/ffnw-banner new file mode 100755 index 0000000000000000000000000000000000000000..66fba57db8b70ec2d75c12aeab5fa90b83813b07 --- /dev/null +++ b/banner/luasrc/usr/sbin/ffnw-banner @@ -0,0 +1,66 @@ +#!/usr/bin/lua + + +local srcFile = "/lib/ffnw/banner/banner" +local desFile = "/tmp/ffnw-banner" + + +local uci = require('luci.model.uci').cursor() +os.execute('cp '..srcFile..' '..desFile) + +local openwrtRelease = io.open("/etc/openwrt_release", "r") +local gluonVersion = io.open("/lib/gluon/gluon-version", "r") +local gluonRelease = io.open("/lib/gluon/release", "r") +local infoHeader = {} +infoHeader["openwrtRelease"] = "" +infoHeader["revision"] = "" +infoHeader["gluonVersion"] = "" +infoHeader["gluonRelease"] = "" +infoHeader["hoodname"] = uci:get('hoodselector', 'hoodselector', 'hood') +if infoHeader["hoodname"] == nil then + infoHeader["hoodname"] = "" +end + +if openwrtRelease~=nil then + for line in openwrtRelease:lines() do + -- Get openwrtRelease + if line:match("DISTRIB_DESCRIPTION") then + for v in string.gmatch(line, "([^=]+)") do + if not v:match("DISTRIB_DESCRIPTION") then + infoHeader["openwrtRelease"] = string.gsub(v,"'","") + end + end + end + -- Get openwrt revision + if line:match("DISTRIB_REVISION") then + for v in string.gmatch(line, "([^=]+)") do + if not v:match("DISTRIB_REVISION") then + infoHeader["revision"] = string.gsub(v,"'","") + end + end + end + end +end + +if gluonVersion~=nil then + for line in gluonVersion:lines() do + if line ~= nil then + infoHeader["gluonVersion"] = line + end + end +end + +if gluonRelease~=nil then + for line in gluonRelease:lines() do + if line ~= nil then + infoHeader["gluonRelease"] = line + end + end +end + +local firstLine ="OpenWRT Version: " .. infoHeader["openwrtRelease"].. " (" .. infoHeader["revision"] .. ")" +local secondLine ="Gluon Version: " .. infoHeader["gluonVersion"] .. " Gluon Release: " .. infoHeader["gluonRelease"] +local thirdLine = "Selected Hood: " .. infoHeader["hoodname"] +os.execute('sed -i \'/%A/c\\' .. firstLine .. '\' ' .. desFile) +os.execute('sed -i \'/%B/c\\' .. secondLine .. '\' ' .. desFile) +os.execute('sed -i \'/%C/c\\' .. thirdLine .. '\' ' .. desFile)